Search in sources :

Example 11 with SolrPingResponse

use of org.apache.solr.client.solrj.response.SolrPingResponse in project ddf by codice.

the class SolrClientAdapter method clientPing.

@SuppressWarnings("squid:S1181")
private SolrPingResponse clientPing(String collection) throws SolrServerException, IOException {
    try {
        lastPing.set(System.currentTimeMillis());
        final SolrPingResponse response;
        if (collection != null) {
            response = pingClient.ping(collection);
        } else {
            response = pingClient.ping();
        }
        if (response == null) {
            LOGGER.debug(SolrClientAdapter.FAILED_TO_PING, core, "null response");
            setConnecting(realClient, new UnavailableSolrClient(new UnavailableSolrException("ping failed with no response")), true, State.CONNECTED);
            return response;
        }
        final Object status = response.getResponse().get("status");
        if (SolrClientAdapter.OK_STATUS.equals(status)) {
            setConnected(true);
        } else {
            LOGGER.debug(SolrClientAdapter.FAILED_TO_PING_WITH_STATUS, core, status);
            setConnecting(realClient, new UnavailableSolrClient(new UnavailableSolrException("ping failed with " + status + " status")), true, State.CONNECTED);
        }
        return response;
    } catch (UnavailableSolrException | VirtualMachineError e) {
        throw e;
    } catch (Throwable t) {
        LOGGER.debug(SolrClientAdapter.FAILED_TO_PING, core, t, t);
        setConnecting(realClient, new UnavailableSolrClient(t), true, State.CONNECTED);
        throw t;
    }
}
Also used : SolrPingResponse(org.apache.solr.client.solrj.response.SolrPingResponse) UnavailableSolrException(org.codice.solr.client.solrj.UnavailableSolrException)

Aggregations

SolrPingResponse (org.apache.solr.client.solrj.response.SolrPingResponse)11 Test (org.junit.Test)4 IOException (java.io.IOException)2 SolrClient (org.apache.solr.client.solrj.SolrClient)2 CloudSolrClient (org.apache.solr.client.solrj.impl.CloudSolrClient)2 NamedList (org.apache.solr.common.util.NamedList)2 UnavailableSolrException (org.codice.solr.client.solrj.UnavailableSolrException)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 File (java.io.File)1 URI (java.net.URI)1 EmbeddedSolrServerConfiguration (org.apache.jackrabbit.oak.plugins.index.solr.configuration.EmbeddedSolrServerConfiguration)1 SolrServerException (org.apache.solr.client.solrj.SolrServerException)1 JettySolrRunner (org.apache.solr.client.solrj.embedded.JettySolrRunner)1 HttpSolrClient (org.apache.solr.client.solrj.impl.HttpSolrClient)1 SolrPing (org.apache.solr.client.solrj.request.SolrPing)1 MiniSolrCloudCluster (org.apache.solr.cloud.MiniSolrCloudCluster)1 SolrException (org.apache.solr.common.SolrException)1 SolrClient (org.codice.solr.client.solrj.SolrClient)1