use of org.apache.stanbol.commons.solr.managed.standalone.StandaloneManagedSolrServer in project stanbol by apache.
the class SolrYardIndexingDestination method initialise.
@Override
public void initialise() {
log.info("initialise {}", getClass().getSimpleName());
//The constructors and the setConfiguration(..) only validate the parsed
//parameters and initialise the member variables. This method performs
//the the actual initialisation of the SolrYard!
//copy a custom configuration (if present)
EmbeddedSolrServer server;
IndexReference solrServerRef = IndexReference.parse(solrYardConfig.getSolrServerLocation());
if (solrIndexConfig != null) {
//copy the configuration
try {
log.info(" ... copy Solr Configuration form {} to {}", solrIndexConfig, solrIndexLocation);
FileUtils.copyDirectory(solrIndexConfig, solrIndexLocation);
} catch (IOException e) {
throw new IllegalStateException(String.format("Unable to copy the Solr index configuration from %s to %s!", solrIndexConfig, solrIndexLocation), e);
}
solrYardConfig.setAllowInitialisation(Boolean.FALSE);
server = StandaloneEmbeddedSolrServerProvider.getInstance().getSolrServer(solrServerRef, solrServerRef.getIndex());
this.core = server.getCoreContainer().getCore(solrServerRef.getIndex());
} else {
//allow the default initialisation
solrYardConfig.setAllowInitialisation(Boolean.TRUE);
StandaloneEmbeddedSolrServerProvider.getInstance();
server = StandaloneEmbeddedSolrServerProvider.getInstance().getSolrServer(solrServerRef, solrYardConfig.getIndexConfigurationName());
if (server != null) {
log.info(" ... initialised SolrCore with default configuration");
this.core = server.getCoreContainer().getCore(solrServerRef.getIndex());
} else if (solrServerRef.isPath() && new File(solrServerRef.getIndex()).isAbsolute()) {
//the parsed absolute path is not within the managed SolrServer
//so we need to create some CoreContainer and init/register
//the core at the parsed location
StandaloneManagedSolrServer s;
if (solrServerRef.getServer() == null) {
s = StandaloneManagedSolrServer.getManagedServer();
} else {
s = StandaloneManagedSolrServer.getManagedServer(solrServerRef.getServer());
}
CoreContainer cc = s.getCoreContainer();
CoreDescriptor cd = new CoreDescriptor(cc, "dummy", solrServerRef.getIndex());
this.core = cc.create(cd);
cc.register(core, false);
server = new EmbeddedSolrServer(cc, "dummy");
log.info(" ... initialised existing SolrCore at {}", solrServerRef.getIndex());
} else {
throw new IllegalStateException("Unable to initialise SolrCore " + solrServerRef);
}
}
log.info(" ... create SolrYard");
this.solrYard = new SolrYard(server, solrYardConfig, namespacePrefixService);
}
Aggregations