0
我正在使用Infinispan 5.2.1,並試圖通過我的Java程序訪問MBeans。但沒有運氣。我假設Infinispan MBean已在Platform MBean服務器中註冊。我可以在Jconsole中正確地看到所有MBean,但不能在程序中看到。以編程方式訪問Infinispan MBeans
我的Infinispan配置
<globalJmxStatistics enabled="true" allowDuplicateDomains="true"/>
我的Java程序。
MBeanServerConnection mBeanServer = ManagementFactory.getPlatformMBeanServer();
String jmxQuery = "org.infinispan:type=Cache,name=" + "\"" + cacheName + "(" + cacheMode + ")" + "\""
+ ",manager=" + "\"" + "DefaultCacheManager" + "\""
+ ",component=Statistics";
Set<ObjectInstance> queryResults = mBeanServer.queryMBeans(new ObjectName(jmxQuery), null);
for (ObjectInstance objectInstance : queryResults) {
ObjectName objectName = objectInstance.getObjectName();
long cacheHits = (Long) mBeanServer.getAttribute(objectName, "Hits");
long removeHits = (Long) mBeanServer.getAttribute(objectName, "RemoveHits");
totalHits = cacheHits + removeHits;
}
任何幫助欣賞。
我希望您的Java程序不會與Infinispan在相同的JVM中運行。那是對的嗎? – 2013-05-07 08:53:47
是的,這是正確的。 – era 2013-05-07 10:21:53