Search in sources :

Example 11 with NodeConfig

use of org.apache.solr.core.NodeConfig in project lucene-solr by apache.

the class SolrGangliaReporterTest method testReporter.

@Test
public void testReporter() throws Exception {
    Path home = Paths.get(TEST_HOME());
    // define these properties, they are used in solrconfig.xml
    System.setProperty("solr.test.sys.prop1", "propone");
    System.setProperty("solr.test.sys.prop2", "proptwo");
    GMetric ganglia = mock(GMetric.class);
    final List<String> names = new ArrayList<>();
    doAnswer(invocation -> {
        final Object[] args = invocation.getArguments();
        names.add((String) args[0]);
        return null;
    }).when(ganglia).announce(anyString(), anyString(), any(GMetricType.class), anyString(), any(GMetricSlope.class), anyInt(), anyInt(), anyString());
    String solrXml = FileUtils.readFileToString(Paths.get(home.toString(), "solr-gangliareporter.xml").toFile(), "UTF-8");
    NodeConfig cfg = SolrXmlConfig.fromString(new SolrResourceLoader(home), solrXml);
    CoreContainer cc = createCoreContainer(cfg, new TestHarness.TestCoresLocator(DEFAULT_TEST_CORENAME, initCoreDataDir.getAbsolutePath(), "solrconfig.xml", "schema.xml"));
    h.coreName = DEFAULT_TEST_CORENAME;
    SolrMetricManager metricManager = cc.getMetricManager();
    Map<String, SolrMetricReporter> reporters = metricManager.getReporters("solr.node");
    assertTrue(reporters.toString(), reporters.size() >= 1);
    SolrMetricReporter reporter = reporters.get("test");
    assertNotNull(reporter);
    assertTrue(reporter instanceof SolrGangliaReporter);
    SolrGangliaReporter gangliaReporter = (SolrGangliaReporter) reporter;
    gangliaReporter.setGMetric(ganglia);
    gangliaReporter.start();
    Thread.sleep(5000);
    assertTrue(names.size() >= 3);
    String[] frozenNames = (String[]) names.toArray(new String[names.size()]);
    for (String name : frozenNames) {
        assertTrue(name, name.startsWith("test.solr.node.CONTAINER.cores."));
    }
}
Also used : Path(java.nio.file.Path) GMetricSlope(info.ganglia.gmetric4j.gmetric.GMetricSlope) ArrayList(java.util.ArrayList) GMetricType(info.ganglia.gmetric4j.gmetric.GMetricType) SolrResourceLoader(org.apache.solr.core.SolrResourceLoader) GMetric(info.ganglia.gmetric4j.gmetric.GMetric) CoreContainer(org.apache.solr.core.CoreContainer) TestHarness(org.apache.solr.util.TestHarness) SolrMetricManager(org.apache.solr.metrics.SolrMetricManager) NodeConfig(org.apache.solr.core.NodeConfig) SolrMetricReporter(org.apache.solr.metrics.SolrMetricReporter) Test(org.junit.Test)

Example 12 with NodeConfig

use of org.apache.solr.core.NodeConfig in project lucene-solr by apache.

the class SolrCoreMetricManager method loadReporters.

/**
   * Load reporters configured globally and specific to {@link org.apache.solr.core.SolrInfoBean.Group#core}
   * group or with a registry name specific to this core.
   */
public void loadReporters() {
    NodeConfig nodeConfig = core.getCoreContainer().getConfig();
    PluginInfo[] pluginInfos = nodeConfig.getMetricsConfig().getMetricReporters();
    metricManager.loadReporters(pluginInfos, core.getResourceLoader(), tag, SolrInfoBean.Group.core, registryName);
    if (cloudMode) {
        metricManager.loadShardReporters(pluginInfos, core);
    }
}
Also used : PluginInfo(org.apache.solr.core.PluginInfo) NodeConfig(org.apache.solr.core.NodeConfig)

Example 13 with NodeConfig

use of org.apache.solr.core.NodeConfig in project lucene-solr by apache.

the class SolrDispatchFilter method createCoreContainer.

/**
   * Override this to change CoreContainer initialization
   * @return a CoreContainer to hold this server's cores
   */
protected CoreContainer createCoreContainer(Path solrHome, Properties extraProperties) {
    NodeConfig nodeConfig = loadNodeConfig(solrHome, extraProperties);
    final CoreContainer coreContainer = new CoreContainer(nodeConfig, extraProperties, true);
    coreContainer.load();
    return coreContainer;
}
Also used : CoreContainer(org.apache.solr.core.CoreContainer) NodeConfig(org.apache.solr.core.NodeConfig)

Aggregations

NodeConfig (org.apache.solr.core.NodeConfig)13 Test (org.junit.Test)8 SolrResourceLoader (org.apache.solr.core.SolrResourceLoader)7 Path (java.nio.file.Path)6 CoreContainer (org.apache.solr.core.CoreContainer)5 PluginInfo (org.apache.solr.core.PluginInfo)3 SolrMetricManager (org.apache.solr.metrics.SolrMetricManager)3 SolrMetricReporter (org.apache.solr.metrics.SolrMetricReporter)3 TestHarness (org.apache.solr.util.TestHarness)3 ExponentiallyDecayingReservoir (com.codahale.metrics.ExponentiallyDecayingReservoir)2 Reservoir (com.codahale.metrics.Reservoir)2 SlidingTimeWindowReservoir (com.codahale.metrics.SlidingTimeWindowReservoir)2 UniformReservoir (com.codahale.metrics.UniformReservoir)2 Clock (com.codahale.metrics.Clock)1 GMetric (info.ganglia.gmetric4j.gmetric.GMetric)1 GMetricSlope (info.ganglia.gmetric4j.gmetric.GMetricSlope)1 GMetricType (info.ganglia.gmetric4j.gmetric.GMetricType)1 Paths (java.nio.file.Paths)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1