@Override public SolrPingResponse ping() throws SolrServerException, IOException { LOGGER.trace("ping"); return server.ping(); }
@Override public SolrPingResponse ping() throws SolrServerException, IOException { LOGGER.trace("ping"); return client.ping(); }
@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; }
/** * 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."); } }
@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."); }
@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 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()); }
@Test public void testEmbeddedSolrServerInitialization() throws Exception { URI uri = getClass().getResource("/solr").toURI(); File file = new File(uri); EmbeddedSolrServerConfiguration solrServerConfiguration = new EmbeddedSolrServerConfiguration(file.getAbsolutePath(), "oak"); EmbeddedSolrServerProvider embeddedSolrServerProvider = new EmbeddedSolrServerProvider(solrServerConfiguration); SolrClient solrServer = embeddedSolrServerProvider.getSolrServer(); assertNotNull(solrServer); SolrPingResponse ping = solrServer.ping(); assertNotNull(ping); assertEquals(0, ping.getStatus()); }
@After public void tearDown() throws Exception { if (server != null && server.ping() != null) { server.deleteByQuery("*:*"); server.commit(); server = null; } }
solr.ping(); } catch (Exception e) {
@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); } }
@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()); }