public class MXBeanStatisticsMetadata extends BasicStatisticsMetadata
MXBeanStatisticsMetadata
extends BasicStatisticsMetadata
to
provide the JMX-specific properties objectName
and attributeName
.
The objectName
is the path of the MBean or MXBean inside of the MBean server and
the attributeName
is the name of the attribute within that MBean or MXBean
that represents the desired statistic value.
However since an attribute maybe one of the complex types:
CompositeData
,
TabularData
, or
array of it,xpath
property is used to specify an accessor to a node within
the complex type that is Numeric in nature.
xpath
value should be for a given attribute value.xpath
string is
simply "/<attributeName>"
because that also happens to be the Numeric node.CompositeData
or TabularData
with a Numeric field of interest
embedded somewhere inside the complex type, then the xpath
accessor string gets more interesting.
See examples below.CompositeData
value is mapped to a java.util.Map
with keys
being the fields inside it. TabularData
attribute value is also mapped to a java.util.Map
with each value in the Map
being CompositeData
. The key of this Map is a String representation of the set of indexes
used to access the TabularData
. See Example 4
below.
Note: Statistics defined usingMXBeanStatisticsMetadata
must be used in conjunction with anMXBeanStatisticsProvider
to achieve automatic lookup of MBean attributes.
Also, the SilverFabric broker do not make use in its classpath any interfaces nor classes from a remote application whose statistics is being collected. This avoids any potential classpath and classloading issues associated with creating a proxy for the MBean or MXBean.
Here is an example of a Tomcat-specific property:
Statistic Name | JMX ObjectName | Attribute Name | XPath to Numeric node |
---|---|---|---|
Tomcat JVM Heap Memory Usage Comitted | java.lang:type=Memory | HeapMemoryUsage | /HeapMemoryUsage/comitted |
MXBeanStatisticsMetadata
in XML as shown below:
<statisticsProvider class="com.datasynapse.fabric.stats.provider.MXBeanStatisticsProvider"> <mBeanServerRef class="TomcatMBeanServerRef"/> <supportedStatistic class="com.datasynapse.fabric.stats.MXBeanStatisticsMetadata"> <property name="name" value="Tomcat JVM Heap Memory Usage Committed"/> <property name="description" value="JVM Heap Memory Usage that is comitted"/> <property name="objectName" value="java.lang:type=Memory"/> <property name="attributeName" value="HeapMemoryUsage"/> <property name="xpath" value="/HeapMemoryUsage/comitted"/> <property name="default" value="true"/> <property name="units" value="MB"/> <aggregator class="SourceAveragedAggregator"/> </supportedStatistic> ... </statisticsProvider>
Some more examples of usage and format of the xpath property to retrieve value of interest:
Example 1: Get the "bytesReceived" attribute for a MBean with registered ObjectName "Catalina:type=GlobalRequestProcessor,name=\"http-apr-9090\"". where the attribute is a Long.<property name="objectName" value="Catalina:type=GlobalRequestProcessor,name=\"http-apr-9090\""/> <property name="attributeName" value="bytesReceived"/> <property name="xpath" value="/bytesReceived"/>
Example 2: Get the "max" memory value from the "HeapMemoryUsage" attribute for a MXBean with registered ObjectName "java.lang:type=Memory". where the attribute is a CompositeData object.<property name="objectName" value="java.lang:type=Memory"/> <property name="attributeName" value="HeapMemoryUsage"/> <property name="xpath" value="/HeapMemoryUsage[@name='max']"/>
Example 3: Get the "used" memory value from the attribute LastGcInfo, with a TabularData value "memoryUsageBeforeGc", and accessible with TabularData key "[Perm Gen [shared-rw]]" for the MXBean registered as "java.lang:type=GarbageCollector,name=Copy".<property name="objectName" value="java.lang:type=GarbageCollector,name=Copy"/> <property name="attributeName" value="LastGcInfo"/> <property name="xpath" value="/LastGcInfo/memoryUsageBeforeGc[@name='[Perm Gen [shared-rw]]']/value[@name='used']"/>
Example 4: Aggregate all active sessions from the attribute "activeSessions" related to all MBeans registered like "Catalina:type=Manager,*" .<property name="objectName" value="Catalina:type=Manager,*"/> <property name="attributeName" value="activeSessions"/> <property name="xpath" value="/activeSessions"/>
Constructor and Description |
---|
MXBeanStatisticsMetadata() |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
String |
getAttributeName()
Returns the attribute name of the statistic
|
String |
getObjectName()
Returns the JMX object name of the MXBean that provides the statistic
|
String |
getXpath()
Returns the xpath of the statistic
|
int |
hashCode() |
void |
setAttributeName(String attributeName)
The setter for the attribute name of the statistic
|
void |
setObjectName(String objectName)
The setter for the object name of the MXBean that provides statistic
|
void |
setXpath(String xpath)
The setter for the xpath of the statistic
|
getAggregator, getDescription, getEvaluator, getName, getUnits, isDefault, isEnabled, isShared, setAggregator, setDefault, setDescription, setEvaluator, setName, setShared, setUnits, toString
public boolean equals(Object obj)
equals
in class BasicStatisticsMetadata
public int hashCode()
hashCode
in class BasicStatisticsMetadata
public String getObjectName()
public void setObjectName(String objectName)
objectName
- the object namepublic String getAttributeName()
public void setAttributeName(String attributeName)
attributeName
- the attribute namepublic void setXpath(String xpath)
xpath
- public String getXpath()
xpath
- Copyright © 2017 TIBCO Software, Inc. All Rights Reserved.