@Override public Collection<IndexMetadata> getIndexes(ManagedIndexState state) { if(state == ManagedIndexState.ACTIVE){ Collection<IndexMetadata> coreMetadata = new ArrayList<IndexMetadata>(); for(SolrCore core : server.getCores()){ coreMetadata.add(getMetadata(core,serverName)); } return coreMetadata; } else { return Collections.emptyList(); } }
@Override public Collection<IndexMetadata> getIndexes(ManagedIndexState state) { if(state == ManagedIndexState.ACTIVE){ Collection<IndexMetadata> coreMetadata = new ArrayList<IndexMetadata>(); for(SolrCore core : server.getCores()){ coreMetadata.add(getMetadata(core,serverName)); } return coreMetadata; } else { return Collections.emptyList(); } }
private CoreContainer createCoreContainer(String solrHome) throws SolrServerException { CoreContainer coreContainer = new CoreContainer(solrHome); coreContainer.load(); if (coreContainer.getCores().size() == 0) { throw new SolrServerException("Failed to initialize the Solr core. " + "Please check the configuration and log messages."); } else if (coreContainer.getCores().size() > 1) { this.logger.warn("Multiple Solr cores detected: [{}]. Using the first one.", StringUtils.join(coreContainer.getCoreNames(), ", ")); } return coreContainer; }
protected void enableAutoSoftCommit(int time) { log.info("Turning on auto soft commit: " + time); for (List<CloudJettyRunner> jettyList : shardToJetty.values()) { for (CloudJettyRunner jetty : jettyList) { CoreContainer cores = jetty.jetty.getCoreContainer(); for (SolrCore core : cores.getCores()) { ((DirectUpdateHandler2) core.getUpdateHandler()) .getSoftCommitTracker().setTimeUpperBound(time); } } } }
if (coreContainer.getCores().size() == 0) { coreContainer.shutdown();
/** * Shuts down and frees any resources */ public void close() { if (container != null) { for (SolrCore c : container.getCores()) { if (c.getOpenCount() > 1) throw new RuntimeException("SolrCore.getOpenCount()=="+c.getOpenCount()); } } if (container != null) { container.shutdown(); container = null; } }
public String getCoreForDirectory(String coreNameOrPath) { if(coreNameOrPath.charAt(coreNameOrPath.length()-1) != File.separatorChar){ coreNameOrPath = coreNameOrPath+File.separatorChar; } for(SolrCore core : server.getCores()){ String instanceDir = core.getCoreDescriptor().getInstanceDir(); if(FilenameUtils.equalsNormalizedOnSystem( coreNameOrPath, instanceDir)){ return core.getName(); } } return null; } public CoreContainer getCoreContainer() {
public String getCoreForDirectory(String coreNameOrPath) { if(coreNameOrPath.charAt(coreNameOrPath.length()-1) != File.separatorChar){ coreNameOrPath = coreNameOrPath+File.separatorChar; } for(SolrCore core : server.getCores()){ String instanceDir = core.getCoreDescriptor().getInstanceDir(); if(FilenameUtils.equalsNormalizedOnSystem( coreNameOrPath, instanceDir)){ return core.getName(); } } return null; } public CoreContainer getCoreContainer() {
/** * Shuts down and frees any resources */ public void close() { if (container != null) { for (SolrCore c : container.getCores()) { if (c.getOpenCount() > 1) throw new RuntimeException("SolrCore.getOpenCount()=="+core.getOpenCount()); } } if (container != null) { container.shutdown(); container = null; } }
protected void waitForAllWarmingSearchers() throws InterruptedException { for (JettySolrRunner jetty:jettys) { if (!jetty.isRunning()) { continue; } for (SolrCore core:jetty.getCoreContainer().getCores()) { waitForWarming(core); } } }
@Override public void initialize() throws InitializationException { String solrHome = determineHomeDirectory(); try { // Validate and initialize the home directory if needed. validateAndInitializeHomeDirectory(solrHome); // Start embedded Solr server. this.logger.info("Starting embedded Solr server..."); this.logger.info("Using Solr home directory: [{}]", solrHome); // Initialize the SOLR back-end using an embedded server. this.container = createCoreContainer(solrHome); // If we get here then there is at least one core found. We there are more, we use the first one. String coreName = this.container.getCores().iterator().next().getName(); this.server = new EmbeddedSolrServer(container, coreName); this.logger.info("Started embedded Solr server."); } catch (Exception e) { throw new InitializationException(String.format( "Failed to initialize the Solr embedded server with home directory set to [%s]", solrHome), e); } }
Collection<SolrCore> cores = coreContainer.getCores(); SolrCore core = null;
if (! cc.getCores().isEmpty() && cc.isZooKeeperAware()) { try { cc.getZkController().getZkClient().exists("/", false);
/** * Shuts down the Solr core container.<p> */ private void shutDownSolrContainer() { if (m_coreContainer != null) { for (SolrCore core : m_coreContainer.getCores()) { // do not unload spellcheck core because otherwise the core.properties file is removed // even when calling m_coreContainer.unload(core.getName(), false, false, false); if (!core.getName().equals(CmsSolrSpellchecker.SPELLCHECKER_INDEX_CORE)) { m_coreContainer.unload(core.getName(), false, false, true); } } m_coreContainer.shutdown(); if (CmsLog.INIT.isInfoEnabled()) { CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_SOLR_SHUTDOWN_SUCCESS_0)); } m_coreContainer = null; } }
coreContainer = new CoreContainer( homeDir.getAbsolutePath(), coreXmlFile); for (SolrCore aCore : coreContainer.getCores()) { log.info("Loaded core: {}", aCore.getName());
abortOnConfigurationError = false; for (SolrCore c : cores.getCores()) { if (c.getSolrConfig().getBool("abortOnConfigurationError", false)) { abortOnConfigurationError = true;