public class PerformanceMonitorMBean extends AbstractDynamicMBean implements PerformanceCollector
performanceMonitor
interceptor. Creates for each intercepted method 5 MBean attributes: Number of Calls, Minimum,
maximum, average and last execution timeModifier and Type | Field and Description |
---|---|
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 and Description |
---|
PerformanceMonitorMBean(java.util.Set methods)
Creates a new instance
|
Modifier and Type | Method and Description |
---|---|
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
|
createMBeanConstructorInfo, createMBeanNotificationInfo, createMBeanOperationInfo, getAttributes, getMBeanClassName, getMBeanDescription, getMBeanInfo, getMBeanServer, invoke, postDeregister, postRegister, preDeregister, preRegister, setAttribute, setAttributes, setMBeanInfo
protected static final java.lang.String DATA_TYPE_MAXIMUM_TIME
protected static final java.lang.String DATA_TYPE_MINIMUM_TIME
protected static final java.lang.String DATA_TYPE_LAST_TIME
protected static final java.lang.String DATA_TYPE_AVERAGE_TIME
protected static final java.lang.String DATA_TYPE_COUNT
public PerformanceMonitorMBean(java.util.Set methods)
methods
- Set with instances of MethodSignature
.
Contains the methods for that calls can be counted by this MBeanprotected void initCounters()
protected void initAttributes(java.util.List mBeanAttributeInfoList, org.apache.hivemind.management.mbeans.Counter counter, org.apache.hivemind.service.MethodSignature method)
protected java.lang.String buildAttributeName(org.apache.hivemind.service.MethodSignature method, java.lang.String performanceDataType)
performanceDataType
for the method.protected java.lang.String buildAttributeNameDefensive(org.apache.hivemind.service.MethodSignature method, java.lang.String performanceDataType)
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)
.public void addMeasurement(org.apache.hivemind.service.MethodSignature method, long executionTime)
PerformanceCollector
addMeasurement
in interface PerformanceCollector
method
- the executed methodexecutionTime
- the duration of the method executionPerformanceCollector.addMeasurement(MethodSignature, long)
protected javax.management.MBeanAttributeInfo[] createMBeanAttributeInfo()
AbstractDynamicMBean
createMBeanAttributeInfo
in class AbstractDynamicMBean
public java.lang.Object getAttribute(java.lang.String attribute) throws javax.management.AttributeNotFoundException, javax.management.MBeanException, javax.management.ReflectionException
getAttribute
in interface javax.management.DynamicMBean
getAttribute
in class AbstractDynamicMBean
javax.management.AttributeNotFoundException
javax.management.MBeanException
javax.management.ReflectionException
AbstractDynamicMBean.getAttribute(java.lang.String)