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."));
}
}
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);
}
}
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;
}
Aggregations