Search in sources :

Example 1 with JmxObjectNameFactory

use of org.apache.solr.metrics.reporters.JmxObjectNameFactory 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);
}
Also used : JmxObjectNameFactory(org.apache.solr.metrics.reporters.JmxObjectNameFactory) SolrMetricManager(org.apache.solr.metrics.SolrMetricManager) MBeanServer(javax.management.MBeanServer) SolrMetricReporter(org.apache.solr.metrics.SolrMetricReporter) SolrJmxReporter(org.apache.solr.metrics.reporters.SolrJmxReporter) BeforeClass(org.junit.BeforeClass)

Aggregations

MBeanServer (javax.management.MBeanServer)1 SolrMetricManager (org.apache.solr.metrics.SolrMetricManager)1 SolrMetricReporter (org.apache.solr.metrics.SolrMetricReporter)1 JmxObjectNameFactory (org.apache.solr.metrics.reporters.JmxObjectNameFactory)1 SolrJmxReporter (org.apache.solr.metrics.reporters.SolrJmxReporter)1 BeforeClass (org.junit.BeforeClass)1