use of org.apache.solr.core.CoreContainer 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.CoreContainer in project lucene-solr by apache.
the class ChaosMonkey method start.
public static boolean start(JettySolrRunner jetty) throws Exception {
monkeyLog("starting jetty! " + jetty.getLocalPort());
IpTables.unblockPort(jetty.getLocalPort());
try {
jetty.start();
} catch (Exception e) {
jetty.stop();
Thread.sleep(3000);
try {
jetty.start();
} catch (Exception e2) {
jetty.stop();
Thread.sleep(10000);
try {
jetty.start();
} catch (Exception e3) {
jetty.stop();
Thread.sleep(30000);
try {
jetty.start();
} catch (Exception e4) {
log.error("Could not get the port to start jetty again", e4);
// we coud not get the port
jetty.stop();
return false;
}
}
}
}
CoreContainer cores = jetty.getCoreContainer();
if (cores != null) {
if (cores.isZooKeeperAware()) {
int zklocalport = ((InetSocketAddress) cores.getZkController().getZkClient().getSolrZooKeeper().getSocketAddress()).getPort();
IpTables.unblockPort(zklocalport);
}
}
return true;
}
use of org.apache.solr.core.CoreContainer in project lucene-solr by apache.
the class ChaosMonkey method causeConnectionLoss.
public static void causeConnectionLoss(JettySolrRunner jetty) {
CoreContainer cores = jetty.getCoreContainer();
if (cores != null) {
monkeyLog("Will cause connection loss on " + jetty.getLocalPort());
SolrZkClient zkClient = cores.getZkController().getZkClient();
zkClient.getSolrZooKeeper().closeCnxn();
}
}
use of org.apache.solr.core.CoreContainer in project lucene-solr by apache.
the class TrackingShardHandlerFactory method setTrackingQueue.
/**
* Sets the tracking queue for all nodes participating in this cluster. Once this method returns,
* all search and core admin requests distributed to shards will be submitted to the given queue.
*
* @param runners a list of {@link org.apache.solr.client.solrj.embedded.JettySolrRunner} nodes
* @param queue an implementation of {@link java.util.Queue} which
* accepts {@link org.apache.solr.handler.component.TrackingShardHandlerFactory.ShardRequestAndParams}
* instances
*/
public static void setTrackingQueue(List<JettySolrRunner> runners, Queue<ShardRequestAndParams> queue) {
for (JettySolrRunner runner : runners) {
CoreContainer container = runner.getCoreContainer();
ShardHandlerFactory factory = container.getShardHandlerFactory();
assert factory instanceof TrackingShardHandlerFactory : "not a TrackingShardHandlerFactory: " + factory.getClass();
TrackingShardHandlerFactory trackingShardHandlerFactory = (TrackingShardHandlerFactory) factory;
trackingShardHandlerFactory.setTrackingQueue(queue);
}
}
use of org.apache.solr.core.CoreContainer in project lucene-solr by apache.
the class SuggestComponentTest method reloadCore.
private void reloadCore(boolean createNewCore) throws Exception {
if (createNewCore) {
CoreContainer cores = h.getCoreContainer();
SolrCore core = h.getCore();
String dataDir1 = core.getDataDir();
CoreDescriptor cd = core.getCoreDescriptor();
h.close();
createCore();
SolrCore createdCore = h.getCore();
assertEquals(dataDir1, createdCore.getDataDir());
assertEquals(createdCore, h.getCore());
} else {
h.reload();
// On regular reloading, wait until the new searcher is registered
waitForWarming();
}
assertQ(req("qt", "standard", "q", "*:*"), "//*[@numFound='11']");
}
Aggregations