use of org.apache.solr.core.NodeConfig in project lucene-solr by apache.
the class TestEmbeddedSolrServerConstructors method testNodeConfigConstructor.
@Test
public void testNodeConfigConstructor() throws Exception {
Path path = createTempDir();
SolrResourceLoader loader = new SolrResourceLoader(path);
NodeConfig config = new NodeConfig.NodeConfigBuilder("testnode", loader).setConfigSetBaseDirectory(Paths.get(TEST_HOME()).resolve("configsets").toString()).build();
try (EmbeddedSolrServer server = new EmbeddedSolrServer(config, "newcore")) {
CoreAdminRequest.Create createRequest = new CoreAdminRequest.Create();
createRequest.setCoreName("newcore");
createRequest.setConfigSet("minimal");
server.request(createRequest);
SolrInputDocument doc = new SolrInputDocument();
doc.addField("articleid", "test");
server.add("newcore", doc);
server.commit();
assertEquals(1, server.query(new SolrQuery("*:*")).getResults().getNumFound());
assertEquals(1, server.query("newcore", new SolrQuery("*:*")).getResults().getNumFound());
}
}
use of org.apache.solr.core.NodeConfig in project lucene-solr by apache.
the class MetricsConfigTest method testCustomSupplier.
@Test
public void testCustomSupplier() throws Exception {
System.setProperty("counter.class", MockCounterSupplier.class.getName());
System.setProperty("meter.class", MockMeterSupplier.class.getName());
System.setProperty("timer.class", MockTimerSupplier.class.getName());
System.setProperty("histogram.class", MockHistogramSupplier.class.getName());
NodeConfig cfg = loadNodeConfig();
SolrMetricManager mgr = new SolrMetricManager(loader, cfg.getMetricsConfig());
assertTrue(mgr.getCounterSupplier() instanceof MockCounterSupplier);
assertTrue(mgr.getMeterSupplier() instanceof MockMeterSupplier);
assertTrue(mgr.getTimerSupplier() instanceof MockTimerSupplier);
assertTrue(mgr.getHistogramSupplier() instanceof MockHistogramSupplier);
// assert setter-based configuration
MockCounterSupplier mockCounterSupplier = ((MockCounterSupplier) mgr.getCounterSupplier());
assertEquals("bar", mockCounterSupplier.foo);
MockMeterSupplier mockMeterSupplier = ((MockMeterSupplier) mgr.getMeterSupplier());
assertEquals("bar", mockMeterSupplier.foo);
MockTimerSupplier mockTimerSupplier = ((MockTimerSupplier) mgr.getTimerSupplier());
assertEquals(true, mockTimerSupplier.boolParam);
assertEquals("strParam", mockTimerSupplier.strParam);
assertEquals(-100, mockTimerSupplier.intParam);
// assert PluginInfoInitialized-based configuration
MockHistogramSupplier mockHistogramSupplier = ((MockHistogramSupplier) mgr.getHistogramSupplier());
assertNotNull(mockHistogramSupplier.info);
}
use of org.apache.solr.core.NodeConfig in project lucene-solr by apache.
the class SolrTestCaseJ4 method createCoreContainer.
public static CoreContainer createCoreContainer(String coreName, String dataDir, String solrConfig, String schema) {
NodeConfig nodeConfig = TestHarness.buildTestNodeConfig(new SolrResourceLoader(TEST_PATH()));
CoresLocator locator = new TestHarness.TestCoresLocator(coreName, dataDir, solrConfig, schema);
CoreContainer cc = createCoreContainer(nodeConfig, locator);
h.coreName = coreName;
return cc;
}
use of org.apache.solr.core.NodeConfig in project lucene-solr by apache.
the class SolrGraphiteReporterTest method testReporter.
@Test
public void testReporter() throws Exception {
int jmxReporter = JmxUtil.findFirstMBeanServer() != null ? 1 : 0;
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");
MockGraphite mock = new MockGraphite();
try {
mock.start();
Thread.sleep(1000);
// define the port where MockGraphite is running
System.setProperty("mock-graphite-port", String.valueOf(mock.port));
String solrXml = FileUtils.readFileToString(Paths.get(home.toString(), "solr-graphitereporter.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");
assertEquals(1 + jmxReporter, reporters.size());
SolrMetricReporter reporter = reporters.get("test");
assertNotNull(reporter);
assertTrue(reporter instanceof SolrGraphiteReporter);
Thread.sleep(5000);
assertTrue(mock.lines.size() >= 3);
String[] frozenLines = (String[]) mock.lines.toArray(new String[mock.lines.size()]);
for (String line : frozenLines) {
assertTrue(line, line.startsWith("test.solr.node.CONTAINER.cores."));
}
} finally {
mock.close();
}
}
use of org.apache.solr.core.NodeConfig in project lucene-solr by apache.
the class TestHarness method buildTestNodeConfig.
public static NodeConfig buildTestNodeConfig(SolrResourceLoader loader) {
CloudConfig cloudConfig = new CloudConfig.CloudConfigBuilder(System.getProperty("host"), Integer.getInteger("hostPort", 8983), System.getProperty("hostContext", "")).setZkClientTimeout(Integer.getInteger("zkClientTimeout", 30000)).build();
if (System.getProperty("zkHost") == null)
cloudConfig = null;
UpdateShardHandlerConfig updateShardHandlerConfig = new UpdateShardHandlerConfig(UpdateShardHandlerConfig.DEFAULT_MAXUPDATECONNECTIONS, UpdateShardHandlerConfig.DEFAULT_MAXUPDATECONNECTIONSPERHOST, 30000, 30000, UpdateShardHandlerConfig.DEFAULT_METRICNAMESTRATEGY, UpdateShardHandlerConfig.DEFAULT_MAXRECOVERYTHREADS);
// universal default metric reporter
Map<String, Object> attributes = new HashMap<>();
attributes.put("name", "default");
attributes.put("class", SolrJmxReporter.class.getName());
PluginInfo defaultPlugin = new PluginInfo("reporter", attributes);
MetricsConfig metricsConfig = new MetricsConfig.MetricsConfigBuilder().setMetricReporterPlugins(new PluginInfo[] { defaultPlugin }).build();
return new NodeConfig.NodeConfigBuilder("testNode", loader).setUseSchemaCache(Boolean.getBoolean("shareSchema")).setCloudConfig(cloudConfig).setUpdateShardHandlerConfig(updateShardHandlerConfig).setMetricsConfig(metricsConfig).build();
}
Aggregations