public class MBeanStatisticsProvider extends AbstractStatisticsProvider
MBeanStatisticsProvider is an implementation of the
StatisticsProvider interface that takes advantage of the JMX
protocol.
Since JMX exposes an API for accessing MBeans and their properties, the statistics collection can be generalized. The provider looks up the MBean using the object name specified in the statistic metadata and then queries the value of the attribute based on the attribute name of the statistic.
Implementations wishing to utilize this simplified JMX stat retrieval
mechanism need only provide an implementation of the
MBeanServerRef interface to provide access to the MBean
server.
For example, the XML definition of the MBeanStatisticsProvider used by JBossContainer is shown below:
<statisticsProvider class="com.datasynapse.fabric.stats.provider.MBeanStatisticsProvider">
<mBeanServerRef class="JBossMBeanServerRef"/>
<supportedStatistic class="com.datasynapse.fabric.stats.MBeanStatisticsMetadata">
<property name="name" value="JBoss Thread Count"/>
<property name="description" value="The number of busy threads."/>
<property name="objectName" value="jboss.web:name=http-0.0.0.0-${container.getPort()},type=ThreadPool"/>
<property name="attributeName" value="currentThreadsBusy"/>
<property name="default" value="true"/>
<property name="units" value="threads"/>
<aggregator class="SourceAveragedAggregator"/>
</supportedStatistic>
...
</statisticsProvider>
MBeanStatisticsMetadata,
MBeanServerRefSUPPORTED_STATISTIC_PROPERTY| Constructor and Description |
|---|
MBeanStatisticsProvider() |
| Modifier and Type | Method and Description |
|---|---|
MBeanServerRef |
getMBeanServerRef()
Retrieve the
MBeanServerRef used to communicate with the
MBean server |
Statistic |
getStatistic(StatisticsMetadata stat)
This method is called to retrieve a single statistic value for the
given statistics metadata.
|
void |
init(Container container,
Domain domain,
ProcessWrapper process,
RuntimeContext runtimeContext)
This method is called so that StatisticsProvider implementations can be initialized with the given parameters.
|
void |
setMBeanServerRef(MBeanServerRef mBeanServerRef)
Set the
MBeanServerRef used to communicate with the MBean
server |
addSupportedStatistic, getCollectionLock, getKeys, getLogger, getSourceId, getStatistics, getStatisticsNames, getSupportedStatistic, getSupportedStatisticCount, getSupportedStatistics, isEnabled, isTestingMode, newRecord, removeSupportedStatistic, reset, retrieveAndEvaluateStats, setCollectionLock, setSourceId, setTestingModepublic void init(Container container, Domain domain, ProcessWrapper process, RuntimeContext runtimeContext)
AbstractStatisticsProviderinit in class AbstractStatisticsProvidercontainer - a reference to the current Enablerdomain - a reference to the current Componentprocess - the ProcessWrapper representing the subprocess used by an ExecContainer. If the Enabler
is not an ExecContainer, or is defined to be non-blocking, this will be nullruntimeContext - the resolved and overlaid RuntimeContext for the current Enabler and Component. This is equivalent to container.getRuntimeContext().public Statistic getStatistic(StatisticsMetadata stat)
AbstractStatisticsProvider
If an Evaluator is defined for the StatisticsMetadata, the
statistic value returned by this method will subsequently be passed to the evaluator's
evaluate() method for post-processing before it is reported to the Broker.
getStatistic in class AbstractStatisticsProviderstat - the metadata definition of the statistic to retrieveStatistic containing the name and the current value of the statisticpublic MBeanServerRef getMBeanServerRef()
MBeanServerRef used to communicate with the
MBean serverMBeanServerRefpublic void setMBeanServerRef(MBeanServerRef mBeanServerRef)
MBeanServerRef used to communicate with the MBean
servermBeanServerRef - the MBeanServerRefCopyright © 2016 TIBCO Software, Inc. All Rights Reserved.