本文整理匯總了Java中org.apache.solr.core.JmxMonitoredMap.SolrDynamicMBean類的典型用法代碼示例。如果您正苦於以下問題:Java SolrDynamicMBean類的具體用法?Java SolrDynamicMBean怎麽用?Java SolrDynamicMBean使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
SolrDynamicMBean類屬於org.apache.solr.core.JmxMonitoredMap包,在下文中一共展示了SolrDynamicMBean類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testJmxRegistration
import org.apache.solr.core.JmxMonitoredMap.SolrDynamicMBean; //導入依賴的package包/類
@Test
public void testJmxRegistration() throws Exception {
List<MBeanServer> servers = MBeanServerFactory.findMBeanServer(null);
log.info("Servers in testJmxRegistration: " + servers);
assertNotNull("MBeanServers were null", servers);
assertFalse("No MBeanServer was found", servers.isEmpty());
MBeanServer mbeanServer = servers.get(0);
assertTrue("No MBeans found in server", mbeanServer.getMBeanCount() > 0);
Set<ObjectInstance> objects = mbeanServer.queryMBeans(null, null);
assertFalse("No SolrInfoMBean objects found in mbean server", objects
.isEmpty());
for (ObjectInstance o : objects) {
MBeanInfo mbeanInfo = mbeanServer.getMBeanInfo(o.getObjectName());
if (mbeanInfo.getClassName().endsWith(SolrDynamicMBean.class.getName())) {
assertTrue("No Attributes found for mbean: " + mbeanInfo, mbeanInfo
.getAttributes().length > 0);
}
}
}
示例2: testJmxRegistration
import org.apache.solr.core.JmxMonitoredMap.SolrDynamicMBean; //導入依賴的package包/類
@Test
public void testJmxRegistration() throws Exception {
assertTrue("No MBeans found in server", mbeanServer.getMBeanCount() > 0);
Set<ObjectInstance> objects = mbeanServer.queryMBeans(null, null);
assertFalse("No objects found in mbean server", objects
.isEmpty());
int numDynamicMbeans = 0;
for (ObjectInstance o : objects) {
assertNotNull("Null name on: " + o.toString(), o.getObjectName());
MBeanInfo mbeanInfo = mbeanServer.getMBeanInfo(o.getObjectName());
if (mbeanInfo.getClassName().endsWith(SolrDynamicMBean.class.getName())) {
numDynamicMbeans++;
MBeanAttributeInfo[] attrs = mbeanInfo.getAttributes();
assertTrue("No Attributes found for mbean: " + mbeanInfo,
0 < attrs.length);
for (MBeanAttributeInfo attr : attrs) {
// ensure every advertised attribute is gettable
try {
Object trash = mbeanServer.getAttribute(o.getObjectName(), attr.getName());
} catch (javax.management.AttributeNotFoundException e) {
throw new RuntimeException("Unable to featch attribute for " + o.getObjectName()
+ ": " + attr.getName(), e);
}
}
}
}
assertTrue("No SolrDynamicMBeans found", 0 < numDynamicMbeans);
}