//init remote server
try {
_server = new HttpSolrServer(indexLocation);
_server.ping(); //test if remove service is available
} catch (RuntimeException e) {
throw new YardException("Unable to connect to remote SolrServer '"+
config.getSolrServerLocation() +"' because of "+e.getMessage(),e);
} catch (SolrServerException e) {
throw new YardException("Unable to initialise to remote SolrServer '"+
config.getSolrServerLocation() +"' because of "+e.getMessage(),e);
} catch (IOException e) {
throw new YardException("Unable to connect to remote SolrServer '"+
config.getSolrServerLocation() +"' because of "+e.getMessage(),e);
}
} else { //locally managed Server
//(1) check if available (also tries to create if not available and
// create is allowed based on the configuration)
IndexReference indexReference = checkManagedSolrIndex(managedSolrServer,config);
if(indexReference != null){
if(context == null){ // outside OSGI
try {
_server = StandaloneEmbeddedSolrServerProvider.getInstance().getSolrServer(indexReference);
} catch (RuntimeException e) {
throw new YardException("Unable to initialise configured SolrServer'"+
config.getSolrServerLocation() +"'!",e);
}
} else { //within OSGI dynamically track the service
try {
_registeredServerTracker = new RegisteredSolrServerTracker(
context.getBundleContext(), indexReference, null);
log.info(" ... start tracking for SolrCore based on {}",indexReference);
_registeredServerTracker.open(); //start tracking
} catch (InvalidSyntaxException e) {
throw new YardException("Unable to track configured SolrServer'"+
config.getSolrServerLocation() +"'!",e);
} catch (RuntimeException e) {
throw new YardException("Unable to initialise configured SolrServer'"+
config.getSolrServerLocation() +"'!",e);
}
}
}
}