org.apache.hivemind.management.mbeans
Class PerformanceMonitorMBean

java.lang.Object
  extended by org.apache.hivemind.management.mbeans.AbstractDynamicMBean
      extended by org.apache.hivemind.management.mbeans.PerformanceMonitorMBean
All Implemented Interfaces:
javax.management.DynamicMBean, javax.management.MBeanRegistration, PerformanceCollector

public class PerformanceMonitorMBean
extends AbstractDynamicMBean
implements PerformanceCollector

MBean that holds and calculates the performance data for service method calls intercepted by the performanceMonitor interceptor. Creates for each intercepted method 5 MBean attributes: Number of Calls, Minimum, maximum, average and last execution time

Since:
1.1
Author:
Achim Huegen

Field Summary
protected static java.lang.String DATA_TYPE_AVERAGE_TIME
           
protected static java.lang.String DATA_TYPE_COUNT
           
protected static java.lang.String DATA_TYPE_LAST_TIME
           
protected static java.lang.String DATA_TYPE_MAXIMUM_TIME
           
protected static java.lang.String DATA_TYPE_MINIMUM_TIME
           
 
Constructor Summary
PerformanceMonitorMBean(java.util.Set methods)
          Creates a new instance
 
Method Summary
 void addMeasurement(org.apache.hivemind.service.MethodSignature method, long executionTime)
          Adds the measurement of a method execution
protected  java.lang.String buildAttributeName(org.apache.hivemind.service.MethodSignature method, java.lang.String performanceDataType)
          Builds the attribute name that holds the measurement data of type performanceDataType for the method.
protected  java.lang.String buildAttributeNameDefensive(org.apache.hivemind.service.MethodSignature method, java.lang.String performanceDataType)
          Builds the attribute name that holds the measurement data of type.
protected  javax.management.MBeanAttributeInfo[] createMBeanAttributeInfo()
          Provides the info which attributes the MBean has.
 java.lang.Object getAttribute(java.lang.String attribute)
           
protected  void initAttributes(java.util.List mBeanAttributeInfoList, org.apache.hivemind.management.mbeans.Counter counter, org.apache.hivemind.service.MethodSignature method)
          Creates for a intercepted method 5 MBean attributes: Number of Calls, Minimum, maximum, average and last execution time
protected  void initCounters()
          Builds two maps for accessing the counters by method signature and method id
 
Methods inherited from class org.apache.hivemind.management.mbeans.AbstractDynamicMBean
createMBeanConstructorInfo, createMBeanNotificationInfo, createMBeanOperationInfo, getAttributes, getMBeanClassName, getMBeanDescription, getMBeanInfo, getMBeanServer, invoke, postDeregister, postRegister, preDeregister, preRegister, setAttribute, setAttributes, setMBeanInfo
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DATA_TYPE_MAXIMUM_TIME

protected static final java.lang.String DATA_TYPE_MAXIMUM_TIME
See Also:
Constant Field Values

DATA_TYPE_MINIMUM_TIME

protected static final java.lang.String DATA_TYPE_MINIMUM_TIME
See Also:
Constant Field Values

DATA_TYPE_LAST_TIME

protected static final java.lang.String DATA_TYPE_LAST_TIME
See Also:
Constant Field Values

DATA_TYPE_AVERAGE_TIME

protected static final java.lang.String DATA_TYPE_AVERAGE_TIME
See Also:
Constant Field Values

DATA_TYPE_COUNT

protected static final java.lang.String DATA_TYPE_COUNT
See Also:
Constant Field Values
Constructor Detail

PerformanceMonitorMBean

public PerformanceMonitorMBean(java.util.Set methods)
Creates a new instance

Parameters:
methods - Set with instances of MethodSignature. Contains the methods for that calls can be counted by this MBean
Method Detail

initCounters

protected void initCounters()
Builds two maps for accessing the counters by method signature and method id


initAttributes

protected void initAttributes(java.util.List mBeanAttributeInfoList,
                              org.apache.hivemind.management.mbeans.Counter counter,
                              org.apache.hivemind.service.MethodSignature method)
Creates for a intercepted method 5 MBean attributes: Number of Calls, Minimum, maximum, average and last execution time


buildAttributeName

protected java.lang.String buildAttributeName(org.apache.hivemind.service.MethodSignature method,
                                              java.lang.String performanceDataType)
Builds the attribute name that holds the measurement data of type performanceDataType for the method.


buildAttributeNameDefensive

protected java.lang.String buildAttributeNameDefensive(org.apache.hivemind.service.MethodSignature method,
                                                       java.lang.String performanceDataType)
Builds the attribute name that holds the measurement data of type. performanceDataType for the method. Some jmx implementations (jboss 3.2.7) don't accept spaces and braces in attribute names. Unlike buildAttributeName(MethodSignature, String) this method doesn't use chars that are not accepted by Character.isJavaIdentifierPart(char).


addMeasurement

public void addMeasurement(org.apache.hivemind.service.MethodSignature method,
                           long executionTime)
Description copied from interface: PerformanceCollector
Adds the measurement of a method execution

Specified by:
addMeasurement in interface PerformanceCollector
Parameters:
method - the executed method
executionTime - the duration of the method execution
See Also:
PerformanceCollector.addMeasurement(MethodSignature, long)

createMBeanAttributeInfo

protected javax.management.MBeanAttributeInfo[] createMBeanAttributeInfo()
Description copied from class: AbstractDynamicMBean
Provides the info which attributes the MBean has. Should be overwritten by the descendants

Overrides:
createMBeanAttributeInfo in class AbstractDynamicMBean

getAttribute

public java.lang.Object getAttribute(java.lang.String attribute)
                              throws javax.management.AttributeNotFoundException,
                                     javax.management.MBeanException,
                                     javax.management.ReflectionException
Specified by:
getAttribute in interface javax.management.DynamicMBean
Overrides:
getAttribute in class AbstractDynamicMBean
Throws:
javax.management.AttributeNotFoundException
javax.management.MBeanException
javax.management.ReflectionException
See Also:
AbstractDynamicMBean.getAttribute(java.lang.String)