use of org.apache.solr.core.CoreDescriptor 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']");
}
use of org.apache.solr.core.CoreDescriptor in project lucene-solr by apache.
the class TestIndexSearcher method createCoreAndValidateListeners.
private void createCoreAndValidateListeners(int numTimesCalled, int numTimesCalledFirstSearcher, int numTimesCalledAfterGetSearcher, int numTimesCalledFirstSearcherAfterGetSearcher) throws Exception {
CoreContainer cores = h.getCoreContainer();
CoreDescriptor cd = h.getCore().getCoreDescriptor();
SolrCore newCore = null;
// reset counters
MockSearcherListener.numberOfTimesCalled = new AtomicInteger();
MockSearcherListener.numberOfTimesCalledFirstSearcher = new AtomicInteger();
try {
// Create a new core, this should call all the firstSearcherListeners
newCore = cores.create("core1", cd.getInstanceDir(), ImmutableMap.of("config", "solrconfig-searcher-listeners1.xml"), false);
//validate that the new core was created with the correct solrconfig
assertNotNull(newCore.getSearchComponent("mock"));
assertEquals(MockSearchComponent.class, newCore.getSearchComponent("mock").getClass());
assertFalse(newCore.getSolrConfig().useColdSearcher);
doQuery(newCore);
assertEquals(numTimesCalled, MockSearcherListener.numberOfTimesCalled.get());
assertEquals(numTimesCalledFirstSearcher, MockSearcherListener.numberOfTimesCalledFirstSearcher.get());
addDummyDoc(newCore);
// Open a new searcher, this should call the newSearcherListeners
Future<?>[] future = new Future[1];
newCore.getSearcher(true, false, future);
future[0].get();
assertEquals(numTimesCalledAfterGetSearcher, MockSearcherListener.numberOfTimesCalled.get());
assertEquals(numTimesCalledFirstSearcherAfterGetSearcher, MockSearcherListener.numberOfTimesCalledFirstSearcher.get());
} finally {
if (newCore != null) {
cores.unload("core1");
}
}
}
use of org.apache.solr.core.CoreDescriptor in project lucene-solr by apache.
the class SchemaManager method waitForOtherReplicasToUpdate.
private void waitForOtherReplicasToUpdate(TimeOut timeOut, int latestVersion) {
CoreDescriptor cd = req.getCore().getCoreDescriptor();
String collection = cd.getCollectionName();
if (collection != null) {
ZkSolrResourceLoader zkLoader = (ZkSolrResourceLoader) managedIndexSchema.getResourceLoader();
if (timeOut.hasTimedOut()) {
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Not enough time left to update replicas. However, the schema is updated already.");
}
ManagedIndexSchema.waitForSchemaZkVersionAgreement(collection, cd.getCloudDescriptor().getCoreNodeName(), latestVersion, zkLoader.getZkController(), (int) timeOut.timeLeft(TimeUnit.SECONDS));
}
}
use of org.apache.solr.core.CoreDescriptor in project lucene-solr by apache.
the class ZkController method markAllAsNotLeader.
private void markAllAsNotLeader(final CurrentCoreDescriptorProvider registerOnReconnect) {
List<CoreDescriptor> descriptors = registerOnReconnect.getCurrentDescriptors();
if (descriptors != null) {
for (CoreDescriptor descriptor : descriptors) {
descriptor.getCloudDescriptor().setLeader(false);
descriptor.getCloudDescriptor().setHasRegistered(false);
}
}
}
use of org.apache.solr.core.CoreDescriptor in project lucene-solr by apache.
the class ZkControllerTest method testPublishAndWaitForDownStates.
@AwaitsFix(bugUrl = "https://issues.apache.org/jira/browse/SOLR-7736")
public void testPublishAndWaitForDownStates() throws Exception {
String zkDir = createTempDir("testPublishAndWaitForDownStates").toFile().getAbsolutePath();
CoreContainer cc = null;
ZkTestServer server = new ZkTestServer(zkDir);
try {
server.run();
AbstractZkTestCase.tryCleanSolrZkNode(server.getZkHost());
AbstractZkTestCase.makeSolrZkNode(server.getZkHost());
cc = getCoreContainer();
ZkController zkController = null;
try {
CloudConfig cloudConfig = new CloudConfig.CloudConfigBuilder("127.0.0.1", 8983, "solr").build();
zkController = new ZkController(cc, server.getZkAddress(), TIMEOUT, cloudConfig, new CurrentCoreDescriptorProvider() {
@Override
public List<CoreDescriptor> getCurrentDescriptors() {
// do nothing
return null;
}
});
HashMap<String, DocCollection> collectionStates = new HashMap<>();
HashMap<String, Replica> replicas = new HashMap<>();
// than this ZkController instance
for (int i = 1; i <= 2; i++) {
Replica r = new Replica("core_node" + i, map(ZkStateReader.STATE_PROP, i == 1 ? "active" : "down", ZkStateReader.NODE_NAME_PROP, i == 1 ? "127.0.0.1:8983_solr" : "non_existent_host", ZkStateReader.CORE_NAME_PROP, "collection1"));
replicas.put("core_node" + i, r);
}
HashMap<String, Object> sliceProps = new HashMap<>();
sliceProps.put("state", Slice.State.ACTIVE.toString());
Slice slice = new Slice("shard1", replicas, sliceProps);
DocCollection c = new DocCollection("testPublishAndWaitForDownStates", map("shard1", slice), Collections.emptyMap(), DocRouter.DEFAULT);
ClusterState state = new ClusterState(0, Collections.emptySet(), map("testPublishAndWaitForDownStates", c));
byte[] bytes = Utils.toJSON(state);
zkController.getZkClient().makePath(ZkStateReader.getCollectionPath("testPublishAndWaitForDownStates"), bytes, CreateMode.PERSISTENT, true);
zkController.getZkStateReader().forceUpdateCollection("testPublishAndWaitForDownStates");
assertTrue(zkController.getZkStateReader().getClusterState().hasCollection("testPublishAndWaitForDownStates"));
assertNotNull(zkController.getZkStateReader().getClusterState().getCollection("testPublishAndWaitForDownStates"));
long now = System.nanoTime();
long timeout = now + TimeUnit.NANOSECONDS.convert(ZkController.WAIT_DOWN_STATES_TIMEOUT_SECONDS, TimeUnit.SECONDS);
zkController.publishAndWaitForDownStates();
assertTrue("The ZkController.publishAndWaitForDownStates should have timed out but it didn't", System.nanoTime() >= timeout);
} finally {
if (zkController != null)
zkController.close();
}
} finally {
if (cc != null) {
cc.shutdown();
}
server.shutdown();
}
}
Aggregations