|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.management.NotificationBroadcasterSupport
org.perf4j.helpers.StatisticsExposingMBean
public class StatisticsExposingMBean
This class provides a wrapper around GroupedTimingStatistics data so that this performance information can be exposed through JMX.
Field Summary | |
---|---|
protected Map<AcceptableRangeConfiguration,Boolean> |
acceptableRanges
These AcceptableRangeConfigurations force a notification to be sent if a statistic is updated to a value outside the allowable range. |
protected Pattern |
attributeNamePattern
Pattern used to parse requested attribute names into the tag name and the statistic name |
protected GroupedTimingStatistics |
currentTimingStatistics
The current underlying timing statistics whose values are exposed as MBean attributes. |
static String |
DEFAULT_MBEAN_NAME
Logging classes use this as the default ObjectName of this MBean when registering it with an MBeanServer. |
protected MBeanInfo |
managementInterface
This MBeanInfo exposes this MBean's management interface to the MBeanServer. |
protected ObjectName |
mBeanName
The name under which this MBean is registered in the MBean server. |
static String |
OUT_OF_RANGE_NOTIFICATION_TYPE
The type of the Notifications sent when a statistics value is outside of the acceptable range. |
protected long |
outOfRangeNotificationSeqNo
This sequence number is required by the JMX Notification API. |
protected ExecutorService |
outOfRangeNotifierThread
This single thread pool is used to send notifications if any values are outside of the acceptable ranges (this is necessary because the JMX spec states that the sendNotification method may be synchronous). |
protected Collection<String> |
tagsToExpose
The tags whose statistics values are being exposed. |
Constructor Summary | |
---|---|
StatisticsExposingMBean(String mBeanName,
Collection<String> tagsToExpose,
Collection<AcceptableRangeConfiguration> acceptableRanges)
Creates a new StatisticsExposingMBean whose management interface exposes performance attributes for the tags specified, and that sends notifications if attributes are outside of the acceptable ranges. |
Method Summary | |
---|---|
protected MBeanInfo |
createMBeanInfoFromTagNames(Collection<String> tagNames)
Helper method creates an MBeanInfo object that contains 6 read only attributes for each tag name, each attribute representing a different statistic. |
void |
exposeTag(String tagName)
This MBean operation method allows the caller to add a tag whose statistics should be exposed as attributes at runtime. |
Object |
getAttribute(String attribute)
|
AttributeList |
getAttributes(String[] attributeNames)
|
MBeanInfo |
getMBeanInfo()
|
MBeanNotificationInfo[] |
getNotificationInfo()
|
protected Map<String,StatsValueRetriever> |
getStatsValueRetrievers()
Overridable helper method gets the Map of statistic name to StatsValueRetriever. |
Object |
invoke(String actionName,
Object[] params,
String[] signature)
|
boolean |
removeTag(String tagName)
This MBean operation method allows the caller to remove, at runtime, a tag whose statistics are exposed. |
protected void |
sendNotificationsIfValuesNotAcceptable()
This helper method sends notifications if any of the acceptable ranges detects an attribute value that is outside of the specified range. |
protected void |
sendOutOfRangeNotification(double attributeValue,
AcceptableRangeConfiguration acceptableRange)
Helper method is used to send the JMX notification because the attribute value doesn't fall within the acceptable range. |
void |
setAttribute(Attribute attribute)
|
AttributeList |
setAttributes(AttributeList attributes)
|
void |
updateCurrentTimingStatistics(GroupedTimingStatistics currentTimingStatistics)
This method should be called to update the underlying timing statistics, which will correspondingly change the values of the exposed attributes. |
Methods inherited from class javax.management.NotificationBroadcasterSupport |
---|
addNotificationListener, handleNotification, removeNotificationListener, removeNotificationListener, sendNotification |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String DEFAULT_MBEAN_NAME
public static final String OUT_OF_RANGE_NOTIFICATION_TYPE
protected ObjectName mBeanName
protected MBeanInfo managementInterface
protected Collection<String> tagsToExpose
protected Map<AcceptableRangeConfiguration,Boolean> acceptableRanges
protected ExecutorService outOfRangeNotifierThread
protected long outOfRangeNotificationSeqNo
protected GroupedTimingStatistics currentTimingStatistics
protected Pattern attributeNamePattern
Constructor Detail |
---|
public StatisticsExposingMBean(String mBeanName, Collection<String> tagsToExpose, Collection<AcceptableRangeConfiguration> acceptableRanges)
mBeanName
- The name under which this MBean is registered in the MBean servertagsToExpose
- The names of the tags whose statistics should exposed. For each tag specified there will
be 6 attributes whose getters are exposed: tagNameMean, tagNameStdDev, tagNameMin,
tagNameMax, and tagNameCount and tagNameTPSacceptableRanges
- These acceptable ranges are used to send notifications if any of the monitored
attributes go outside of the range.Method Detail |
---|
public void updateCurrentTimingStatistics(GroupedTimingStatistics currentTimingStatistics)
currentTimingStatistics
- The TimingStatistics to set, may not be nullpublic void exposeTag(String tagName)
tagName
- The name of the tag whose statistics should be exposed.public boolean removeTag(String tagName)
tagName
- The name of the tag whose statistics should be removed as attributes from this MBean.
public Object getAttribute(String attribute) throws AttributeNotFoundException, MBeanException, ReflectionException
getAttribute
in interface DynamicMBean
AttributeNotFoundException
MBeanException
ReflectionException
public void setAttribute(Attribute attribute) throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException
setAttribute
in interface DynamicMBean
AttributeNotFoundException
InvalidAttributeValueException
MBeanException
ReflectionException
public AttributeList getAttributes(String[] attributeNames)
getAttributes
in interface DynamicMBean
public AttributeList setAttributes(AttributeList attributes)
setAttributes
in interface DynamicMBean
public Object invoke(String actionName, Object[] params, String[] signature) throws MBeanException, ReflectionException
invoke
in interface DynamicMBean
MBeanException
ReflectionException
public MBeanInfo getMBeanInfo()
getMBeanInfo
in interface DynamicMBean
public MBeanNotificationInfo[] getNotificationInfo()
getNotificationInfo
in interface NotificationBroadcaster
getNotificationInfo
in class NotificationBroadcasterSupport
protected Map<String,StatsValueRetriever> getStatsValueRetrievers()
protected MBeanInfo createMBeanInfoFromTagNames(Collection<String> tagNames)
tagNames
- The name of the tags whose statistics should be exposed as MBeanAttributes.
protected void sendNotificationsIfValuesNotAcceptable()
protected void sendOutOfRangeNotification(double attributeValue, AcceptableRangeConfiguration acceptableRange)
attributeValue
- The attribute value that falls outside the thresholdacceptableRange
- The AcceptableRangeConfiguration used to constrain the acceptable value
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |