try
{
MBeanServer server = ManagementFactory.getPlatformMBeanServer();
ObjectName on = new ObjectName("jboss.cache:service=Cache");
JmxRegistrationManager jmxManager = new JmxRegistrationManager(server, cache, on);
jmxManager.registerAllMBeans();
}
catch (MalformedObjectNameException ex)
{
log.error( CommonUtils.getStackTraceString(ex) );
}
If you want to read cache statistic in the same JVM, get JMX object name of
CacheMgmtInterceptor using jconsole and use it to access its attributes:
MBeanServer server = ManagementFactory.getPlatformMBeanServer();
ObjectName objectName = new ObjectName("jboss.cache:service=Cache,jmx-resource=CacheMgmtInterceptor");
server.getAttribute(objectName,attributeName)
Probably the most interesting attributes are named Hits, Misses, HitMissRatio, Evictions, AverageReadTime, AverageWriteTime, ReadWriteRatio and NumberOfNodes. More can be found in documentation. Note that Hits and Misses are on attribute level so if work with whole nodes, these values are useless, also when putting whole nodes into the cache the interceptor is probably bypassed.
No comments:
Post a Comment