@Override public boolean isReady() { boolean ready = false; try { SolrPingResponse response = server.ping(); ready = (response != null && response.getStatus() == STATUS_OK); if (!ready) { if (response == null) { LOGGER.error("Search engine returned null response from ping()"); } else { LOGGER.error("Search engine is not ready: ", response.getResponse()); } } } catch (SolrServerException e) { LOGGER.error("Server exception from ping(): {}", e.getMessage()); } catch (IOException e) { LOGGER.error("IO exception when calling server: {}", e.getMessage()); } return ready; }
@Override protected SolrPingResponse createResponse(SolrClient client) { return new SolrPingResponse(); }
@Override public SolrResponse process(SolrServer server) throws SolrServerException, IOException { long startTime = System.currentTimeMillis(); SolrPingResponse res = new SolrPingResponse(); res.setResponse( server.request( this ) ); res.setElapsedTime( System.currentTimeMillis()-startTime ); return res; }
@Override public boolean execute() throws PingNotConfiguredException { try { SolrPingResponse response = server.ping(); if(response.getStatus() == 0) { return true; } } catch (SolrServerException e) { return false; } catch (IOException e) { return false; } catch (SolrException e) { if(e.getMessage().startsWith("pingQuery_not_configured")) { throw new PingNotConfiguredException("Ping command is not configured on server."); } return false; } return false; }
/** * Creates an instance of SolrSearch server allowing to avoid the schema validity check. * @param client SolrClient to connect to. * @param check true to perform local schema validity check against remote schema, false otherwise. */ protected SolrSearchServer(SolrClient client, boolean check) { solrClient = client; //In order to perform unit tests with mocked solrClient, we do not need to do the schema check. if(check && client != null) { try { final SolrPingResponse ping = solrClient.ping(); if (ping.getStatus() == 0) { log.debug("Pinged Solr in {}", ping.getQTime()); } } catch (SolrServerException | IOException e) { log.error("Cannot connect to solr server", e); throw new RuntimeException(); } log.info("Connection to solr server successful"); checkVersionAndSchema(); } else { log.warn("Solr ping and schema validity check has been deactivated."); } }
try { SolrPingResponse pingResponse = this.solrPsmServer.ping(); if ((pingResponse.getStatus() == 0) && pingResponse.getElapsedTime() < MAX_ELAPSED_TIME_PING_QUERY) { } else { logger.error("[TRY " + numTries + " Solr server too busy!"); logger.error("PING response status: " + pingResponse.getStatus()); logger.error("PING elapsed time: " + pingResponse.getElapsedTime()); logger.error("Re-trying in " + SECONDS_TO_WAIT + " seconds..."); waitSecs();
@Override public void start(ILifecycleProgressMonitor monitor) throws SiteWhereException { LOGGER.info("Solr search provider starting."); if (getSolr() == null) { throw new SiteWhereException("No Solr configuration provided to " + getClass().getName()); } try { LOGGER.info("Attempting to ping Solr server to verify availability..."); SolrPingResponse response = getSolr().getSolrClient().ping(); int pingTime = response.getQTime(); LOGGER.info("Solr server location verified. Ping responded in " + pingTime + " ms."); } catch (SolrServerException e) { throw new SiteWhereException("Ping failed. Verify that Solr server is available.", e); } catch (IOException e) { throw new SiteWhereException("Exception in ping. Verify that Solr server is available.", e); } LOGGER.info("Solr search provider started."); }
protected HttpSolrServer createCore(HttpSolrServer solr, String coreName) throws IOException, SolrServerException { String solrDir = configurationService.getProperty("dspace.dir") + File.separator + "solr" + File.separator; String baseSolrUrl = solr.getBaseURL().replace("statistics", ""); //DS-3458: Test to see if a solr core already exists. If it exists, return that server. Otherwise create a // new one. HttpSolrServer returnServer = new HttpSolrServer(baseSolrUrl + "/" + coreName); try { SolrPingResponse ping = returnServer.ping(); log.debug(String.format("Ping of Solr Core [%s] Returned with Status [%d]", coreName, ping.getStatus())); return returnServer; } catch (Exception e) { log.debug(String.format("Ping of Solr Core [%s] Failed with [%s]. New Core Will be Created", coreName, e.getClass().getName())); } //Unfortunately, this class is documented as "experimental and subject to change" on the Lucene website. //http://lucene.apache.org/solr/4_4_0/solr-solrj/org/apache/solr/client/solrj/request/CoreAdminRequest.html CoreAdminRequest.Create create = new CoreAdminRequest.Create(); create.setCoreName(coreName); //The config files for a statistics shard reside wihtin the statistics repository create.setInstanceDir("statistics"); create.setDataDir(solrDir + coreName + File.separator + "data"); HttpSolrServer solrServer = new HttpSolrServer(baseSolrUrl); create.process(solrServer); log.info("Created core with name: " + coreName); return returnServer; }
try { SolrPingResponse pingResponse = this.spectrumSolrServer.ping(); if ((pingResponse.getStatus() == 0) && pingResponse.getElapsedTime() < MAX_ELAPSED_TIME_PING_QUERY) { } else { logger.info("[TRY " + numTries + " Solr server too busy!"); logger.info("PING response status: " + pingResponse.getStatus()); logger.info("PING elapsed time: " + pingResponse.getElapsedTime()); logger.info("Re-trying in " + SECONDS_TO_WAIT + " seconds..."); waitSecs();
@Override public void start(ILifecycleProgressMonitor monitor) throws SiteWhereException { // Required for filters. super.start(monitor); if (getSolr() == null) { throw new SiteWhereException("No Solr configuration provided to " + getClass().getName()); } try { LOGGER.info("Attempting to ping Solr server to verify availability..."); SolrPingResponse response = getSolr().getSolrClient().ping(); int pingTime = response.getQTime(); LOGGER.info("Solr server location verified. Ping responded in " + pingTime + " ms."); } catch (SolrServerException e) { throw new SiteWhereException("Ping failed. Verify that Solr server is available.", e); } catch (IOException e) { throw new SiteWhereException("Exception in ping. Verify that Solr server is available.", e); } LOGGER.info("Solr event processor indexing events to server at: " + getSolr().getSolrServerUrl()); executor.execute(new SolrDocumentQueueProcessor()); }
if (server.ping().getStatus() == 0) { return server; } else {
@Override public SolrPingResponse ping() { return new SolrPingResponse(); }
@Override public boolean isSearchEngineReady() { boolean ready = false; try { SolrPingResponse response = getServer().ping(); ready = (response != null && response.getStatus() == 0); if (!ready) { if (response == null) { getLogger().error("Search engine returned null response from ping()"); } else { getLogger().error("Search engine is not ready: ", response.getResponse()); } } } catch (SolrServerException e) { getLogger().error("Server exception from ping(): {}", e.getMessage()); } catch (IOException e) { getLogger().error("IO exception when calling server: {}", e.getMessage()); } return ready; }
@Override public SolrPingResponse process( SolrServer server ) throws SolrServerException, IOException { long startTime = System.currentTimeMillis(); SolrPingResponse res = new SolrPingResponse(); res.setResponse( server.request( this ) ); res.setElapsedTime( System.currentTimeMillis()-startTime ); return res; } }
@Override public void start(ILifecycleProgressMonitor monitor) throws SiteWhereException { if (getSolrConfiguration() == null) { throw new SiteWhereException("No Solr configuration provided."); } try { // Create and start Solr connection. this.solrConnection = new SolrConnection(getSolrConfiguration()); getSolrConnection().start(monitor); getLogger().info("Attempting to ping Solr server to verify availability..."); SolrPingResponse response = getSolrConnection().getSolrClient().ping(); int pingTime = response.getQTime(); getLogger().info("Solr server location verified. Ping responded in " + pingTime + " ms."); } catch (SolrServerException e) { throw new SiteWhereException("Ping failed. Verify that Solr server is available.", e); } catch (IOException e) { throw new SiteWhereException("Exception in ping. Verify that Solr server is available.", e); } }
if (server.ping().getStatus() == 0) { return server; } else {
@Override public SolrPingResponse ping() throws SolrServerException, IOException { return new SolrPingResponse(); }
@Override public void start(ILifecycleProgressMonitor monitor) throws SiteWhereException { // Required for filters. super.start(monitor); if (getSolrConfiguration() == null) { throw new SiteWhereException("No Solr configuration provided."); } try { // Create and start Solr connection. this.solrConnection = new SolrConnection(getSolrConfiguration()); getSolrConnection().start(monitor); getLogger().info("Attempting to ping Solr server to verify availability..."); SolrPingResponse response = getSolrConnection().getSolrClient().ping(); int pingTime = response.getQTime(); getLogger().info("Solr server location verified. Ping responded in " + pingTime + " ms."); } catch (SolrServerException e) { throw new SiteWhereException("Ping failed. Verify that Solr server is available.", e); } catch (IOException e) { throw new SiteWhereException("Exception in ping. Verify that Solr server is available.", e); } getLogger().info( "Solr event processor indexing events to server at: " + getSolrConfiguration().getSolrServerUrl()); executor.execute(new SolrDocumentQueueProcessor()); }
private SolrClient initializeWithExistingHttpServer() throws IOException, SolrServerException { // try basic Solr HTTP client HttpSolrClient httpSolrServer = new HttpSolrClient(remoteSolrServerConfiguration.getSolrHttpUrls()[0]); httpSolrServer.setConnectionTimeout(remoteSolrServerConfiguration.getConnectionTimeout()); httpSolrServer.setSoTimeout(remoteSolrServerConfiguration.getSocketTimeout()); SolrPingResponse ping = httpSolrServer.ping(); if (ping != null && 0 == ping.getStatus()) { return httpSolrServer; } else { httpSolrServer.close(); throw new IOException("the found HTTP Solr server is not alive"); } }
@Override public SolrPingResponse ping() { return new SolrPingResponse(); }