本文整理汇总了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);
}