//(1) Try to activate missing cores on the CoreContainer
if(!activeByMetadata.isEmpty()){
log.info("The following active managed Cores are not available on " +
"the SolrServer: {}",activeByMetadata);
for(String indexName : activeByMetadata){
IndexMetadata metadata = managedCores.getIndexMetadata(indexName);
try {
activateCore(metadata, server);
log.info(" ... index {} successfully started!",indexName);
} catch (IOException e) {
metadata.setError(e);
log.error("Unable to activate previously active SolrIndex '"+
metadata.getIndexReference()+"'!",e);
} catch (SAXException e) {
metadata.setError(e);
log.error("Unable to activate previously active SolrIndex '"+
metadata.getIndexReference()+"'!",e);
} catch (RuntimeException e) {
metadata.setError(e);
log.error("Unable to activate previously active SolrIndex '"+
metadata.getIndexReference()+"'!",e);
//} finally { The metadata are not modified anyway!
// managedCores.store(metadata);
}
}
}
//(2) Process active SolrCores on the CoreContainer that are not active
// based on the configuration
if(!activeOnSolrServer.isEmpty()){
log.info("The following Cores active on the SolrServer are not " +
"marked as active in the Metadata: {}",activeOnSolrServer);
log.info("Based on the Metadata (UNKNOWN ... no Index for that name):");
for(String indexName : activeOnSolrServer){
IndexMetadata metadata = managedCores.getIndexMetadata(indexName);
ManagedIndexState state = metadata != null ? metadata.getState() : null;
log.info(" - {} has state {}",indexName, state != null ? state : "UNKNOWN");
if(metadata == null){
//unknown core ... deactivate
deactivateCore(indexName, server);
log.info(" ... deactiaved UNKOWN SolrCore {} on managed Solr Server {}",
indexName, serverName);
} else if(state == ManagedIndexState.INACTIVE){
////the metadata way this core should be deactivated!
deactivateCore(indexName, server);
log.info(" ... deactiaved INACTIVE SolrCore {} on managed Solr Server {}",
indexName, serverName);
} else if(state == ManagedIndexState.ERROR){
//looks like that the error was resolved ...
// ... maybe someone has manually edited some files and
// restarted this server
metadata.setState(ManagedIndexState.ACTIVE);
managedCores.store(metadata);
log.info(" ... successfully ACTIVATED SolrCore {} on managed Solr Server {}",
indexName, serverName);
} else if(state == ManagedIndexState.UNINITIALISED){
//looks like someone has copied the required files manually
//to the solrServer ... update the metadata an activate
ManagementUtils.updateMetadata(metadata, server.getCore(indexName));
metadata.setState(ManagedIndexState.ACTIVE);
managedCores.store(metadata);
log.info(" ... successfully ACTIVATED SolrCore {} on managed Solr Server {}",
indexName, serverName);
}
}