use of org.apache.solr.metrics.reporters.SolrJmxReporter in project lucene-solr by apache.
the class TestJmxIntegration method beforeClass.
@BeforeClass
public static void beforeClass() throws Exception {
// Make sure that at least one MBeanServer is available
// prior to initializing the core
//
// (test configs are setup to use existing server if any,
// otherwise skip JMX)
MBeanServer platformServer = ManagementFactory.getPlatformMBeanServer();
initCore("solrconfig.xml", "schema.xml");
// we should be able to see that the core has JmxIntegration enabled
registryName = h.getCore().getCoreMetricManager().getRegistryName();
SolrMetricManager manager = h.getCoreContainer().getMetricManager();
Map<String, SolrMetricReporter> reporters = manager.getReporters(registryName);
assertEquals(1, reporters.size());
SolrMetricReporter reporter = reporters.values().iterator().next();
assertTrue(reporter instanceof SolrJmxReporter);
SolrJmxReporter jmx = (SolrJmxReporter) reporter;
assertTrue("JMX not enabled", jmx.isActive());
// and we should be able to see that the reporter
// refers to the JMX server we started
mbeanServer = jmx.getMBeanServer();
assertNotNull("No JMX server found in the reporter", mbeanServer);
// NOTE: we can't guarantee that "mbeanServer == platformServer"
// the JVM may have multiple MBean servers running when the test started
// and the contract of not specifying one when configuring solr.xml without
// agetnId or serviceUrl is that it will use whatever the "first" MBean server
// returned by the JVM is.
nameFactory = new JmxObjectNameFactory("default", registryName);
}
Aggregations