View Javadoc

1    /****************************************************************************
2    * Copyright (c) 2005, 2006, 2007, 2008, 2009 Imola Informatica.
3    * All rights reserved. This program and the accompanying materials
4    * are made available under the terms of the LGPL License v2.1
5    * which accompanies this distribution, and is available at
6    * http://www.gnu.org/licenses/lgpl.html
7    ****************************************************************************/
8   package it.imolinfo.jbi4corba.jbi.component;
9   
10  import javax.management.MBeanException;
11  import javax.management.openmbean.TabularData;
12  import javax.management.openmbean.OpenDataException;
13  
14  import net.java.hulp.measure.Group;
15  
16  import com.sun.jbi.eManager.provider.PerformanceMeasurement;
17  
18  /**
19   *
20   * 
21   */
22  public class Jbi4CorbaPerformanceMeasurement implements PerformanceMeasurement {
23  
24      public static final String JBI4CORBA_BC_SOURCE_FILTER = "it.imolinfo.jbi4corba.*";
25      
26      /** 
27       * Retrieves the performance insturmentation measurement for the specified endpoint. 
28       * @param endpoint The endpoint name qualified by service name.
29       * @return An instance of TabularData which holds the performance instrumentation measurement for the specified endpoint.
30       * @throws OpenDataException if there's an error related to the openmbean data.
31       * @throws MBeanException if the endpoint does not exist for the component.
32       */
33       public TabularData getPerformanceInstrumentationMeasurement(String endpoint) throws OpenDataException, MBeanException {
34          Group gr = Group.createGroup();
35          gr.addPattern(JBI4CORBA_BC_SOURCE_FILTER, endpoint, getPerfCatFilter());
36          return gr.fetchData();
37      }
38  
39      /** 
40       * Resets the performance measurements on the endpoint.
41       * @param endpoint The endpoint name qualified by service name.
42       * @throws MBeanException if the endpoint does not exist for the component.
43       */
44      public void clearPeformaceInstrumentationMeasurement (String endpoint) throws MBeanException {
45          Group gr = Group.createGroup();
46          gr.addPattern(JBI4CORBA_BC_SOURCE_FILTER, endpoint, getPerfCatFilter());
47          gr.clearData();
48      }
49  
50      private String getPerfCatFilter() {
51          StringBuffer perfCatFilter = new StringBuffer();
52          for (int i=0; i < Jbi4CorbaLifeCycle.JBI4CORBABC_PERF_CATEGORIES.length; i++) {
53              perfCatFilter.append(Jbi4CorbaLifeCycle.JBI4CORBABC_PERF_CATEGORIES[i]);
54              if (i < Jbi4CorbaLifeCycle.JBI4CORBABC_PERF_CATEGORIES.length-1) {
55                  perfCatFilter.append('|');
56              }
57          }
58          return perfCatFilter.toString();
59      }
60  }