Java Code Examples for org.apache.solr.core.SolrCore#getCoreDescriptor()
The following examples show how to use
org.apache.solr.core.SolrCore#getCoreDescriptor() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SuggestComponentTest.java From lucene-solr with Apache License 2.0 | 6 votes |
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", "/select", "q", "*:*"), "//*[@numFound='11']" ); }
Example 2
Source File: RoutedAliasUpdateProcessor.java From lucene-solr with Apache License 2.0 | 5 votes |
public static UpdateRequestProcessor wrap(SolrQueryRequest req, UpdateRequestProcessor next) { String aliasName = null; // Demeter please don't arrest us... hide your eyes :( // todo: a core should have a more direct way of finding a collection name, and the collection properties SolrCore core = req.getCore(); CoreDescriptor coreDescriptor = core.getCoreDescriptor(); CloudDescriptor cloudDescriptor = coreDescriptor.getCloudDescriptor(); if (cloudDescriptor != null) { String collectionName = cloudDescriptor.getCollectionName(); CoreContainer coreContainer = core.getCoreContainer(); ZkController zkController = coreContainer.getZkController(); ZkStateReader zkStateReader = zkController.getZkStateReader(); Map<String, String> collectionProperties = zkStateReader.getCollectionProperties(collectionName, CACHE_FOR_MILLIS); aliasName = collectionProperties.get(RoutedAlias.ROUTED_ALIAS_NAME_CORE_PROP); } // fall back on core properties (legacy) if (StringUtils.isBlank(aliasName)) { aliasName = coreDescriptor.getCoreProperty(RoutedAlias.ROUTED_ALIAS_NAME_CORE_PROP, null); } final DistribPhase shardDistribPhase = DistribPhase.parseParam(req.getParams().get(DISTRIB_UPDATE_PARAM)); final DistribPhase aliasDistribPhase = DistribPhase.parseParam(req.getParams().get(ALIAS_DISTRIB_UPDATE_PARAM)); if (aliasName == null || aliasDistribPhase != DistribPhase.NONE || shardDistribPhase != DistribPhase.NONE) { // if aliasDistribPhase is not NONE, then there is no further collection routing to be done here. // TODO this may eventually not be true but at the moment it is // if shardDistribPhase is not NONE, then the phase is after the scope of this URP return next; } else { try { RoutedAlias alias = RoutedAlias.fromProps(aliasName, getAliasProps(req, aliasName)); return new RoutedAliasUpdateProcessor(req, next, aliasDistribPhase, alias); } catch (Exception e) { // ensure we throw SERVER_ERROR not BAD_REQUEST at this stage throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Routed alias has invalid properties: " + e, e); } } }
Example 3
Source File: RecoveryStrategy.java From lucene-solr with Apache License 2.0 | 5 votes |
final public void doRecovery(SolrCore core) throws Exception { // we can lose our core descriptor, so store it now this.coreDescriptor = core.getCoreDescriptor(); if (this.coreDescriptor.getCloudDescriptor().requiresTransactionLog()) { doSyncOrReplicateRecovery(core); } else { doReplicateOnlyRecovery(core); } }
Example 4
Source File: SchemaManager.java From lucene-solr with Apache License 2.0 | 5 votes |
private void waitForOtherReplicasToUpdate(TimeOut timeOut, int latestVersion) { SolrCore core = req.getCore(); CoreDescriptor cd = core.getCoreDescriptor(); String collection = cd.getCollectionName(); if (collection != null) { 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, core.getCoreContainer().getZkController(), (int) timeOut.timeLeft(TimeUnit.SECONDS)); } }
Example 5
Source File: SentryTestBase.java From incubator-sentry with Apache License 2.0 | 5 votes |
public static void closeCore(SolrCore coreToClose, CloudDescriptor cloudDescriptor) throws Exception { if (cloudDescriptor != null) { CoreDescriptor coreDescriptor = coreToClose.getCoreDescriptor(); Field cloudDescField = CoreDescriptor.class.getDeclaredField("cloudDesc"); cloudDescField.setAccessible(true); cloudDescField.set(coreDescriptor, cloudDescriptor); } coreToClose.close(); }
Example 6
Source File: SentryTestBase.java From incubator-sentry with Apache License 2.0 | 5 votes |
protected SolrQueryRequest prepareCollAndUser(SolrCore core, SolrQueryRequest request, String collection, String user, boolean onlyOnce) throws Exception { CloudDescriptor mCloudDescriptor = EasyMock.createMock(CloudDescriptor.class); IExpectationSetters getCollNameExpect = EasyMock.expect(mCloudDescriptor.getCollectionName()).andReturn(collection); getCollNameExpect.anyTimes(); IExpectationSetters getShardIdExpect = EasyMock.expect(mCloudDescriptor.getShardId()).andReturn("shard1"); getShardIdExpect.anyTimes(); EasyMock.replay(mCloudDescriptor); CoreDescriptor coreDescriptor = core.getCoreDescriptor(); Field cloudDescField = CoreDescriptor.class.getDeclaredField("cloudDesc"); cloudDescField.setAccessible(true); cloudDescField.set(coreDescriptor, mCloudDescriptor); HttpServletRequest httpServletRequest = EasyMock.createMock(HttpServletRequest.class); IExpectationSetters getAttributeUserExpect = EasyMock.expect(httpServletRequest.getAttribute(USER_NAME)).andReturn(user); if (!onlyOnce) { getAttributeUserExpect.anyTimes(); } IExpectationSetters getAttributeDoAsUserExpect = EasyMock.expect(httpServletRequest.getAttribute(DO_AS_USER_NAME)).andReturn(null); if (!onlyOnce) { getAttributeDoAsUserExpect.anyTimes(); } EasyMock.replay(httpServletRequest); request.getContext().put("httpRequest", httpServletRequest); return request; }
Example 7
Source File: MDCLoggingContext.java From lucene-solr with Apache License 2.0 | 4 votes |
/** * Sets multiple information from the params. * REMEMBER TO CALL {@link #clear()} in a finally! */ public static void setCore(SolrCore core) { CoreContainer coreContainer = core == null ? null : core.getCoreContainer(); CoreDescriptor coreDescriptor = core == null ? null : core.getCoreDescriptor(); setCoreDescriptor(coreContainer, coreDescriptor); }
Example 8
Source File: SimpleCollectionCreateDeleteTest.java From lucene-solr with Apache License 2.0 | 4 votes |
@Test @ShardsFixed(num = 1) public void test() throws Exception { String overseerNode = OverseerCollectionConfigSetProcessor.getLeaderNode(cloudClient.getZkStateReader().getZkClient()); String notOverseerNode = null; for (CloudJettyRunner cloudJetty : cloudJettys) { if (!overseerNode.equals(cloudJetty.nodeName)) { notOverseerNode = cloudJetty.nodeName; break; } } String collectionName = "SimpleCollectionCreateDeleteTest"; CollectionAdminRequest.Create create = CollectionAdminRequest.createCollection(collectionName,1,1) .setCreateNodeSet(overseerNode); NamedList<Object> request = create.process(cloudClient).getResponse(); if (request.get("success") != null) { assertTrue(cloudClient.getZkStateReader().getZkClient().exists(ZkStateReader.COLLECTIONS_ZKNODE + "/" + collectionName, false)); @SuppressWarnings({"rawtypes"}) CollectionAdminRequest delete = CollectionAdminRequest.deleteCollection(collectionName); cloudClient.request(delete); assertFalse(cloudClient.getZkStateReader().getZkClient().exists(ZkStateReader.COLLECTIONS_ZKNODE + "/" + collectionName, false)); // currently, removing a collection does not wait for cores to be unloaded TimeOut timeout = new TimeOut(30, TimeUnit.SECONDS, TimeSource.NANO_TIME); while (true) { if( timeout.hasTimedOut() ) { throw new TimeoutException("Timed out waiting for all collections to be fully removed."); } boolean allContainersEmpty = true; for(JettySolrRunner jetty : jettys) { Collection<SolrCore> cores = jetty.getCoreContainer().getCores(); for (SolrCore core : cores) { CoreDescriptor cd = core.getCoreDescriptor(); if (cd != null) { if (cd.getCloudDescriptor().getCollectionName().equals(collectionName)) { allContainersEmpty = false; } } } } if (allContainersEmpty) { break; } } // create collection again on a node other than the overseer leader create = CollectionAdminRequest.createCollection(collectionName,1,1) .setCreateNodeSet(notOverseerNode); request = create.process(cloudClient).getResponse(); assertTrue("Collection creation should not have failed", request.get("success") != null); } }