Example usage for org.apache.solr.client.solrj.request SolrPing SolrPing

List of usage examples for org.apache.solr.client.solrj.request SolrPing SolrPing

Introduction

In this page you can find the example usage for org.apache.solr.client.solrj.request SolrPing SolrPing.

Prototype

public SolrPing() 

Source Link

Document

Create a new SolrPing object.

Usage

From source file:com.francelabs.datafari.service.search.SolrServers.java

License:Apache License

public static SolrClient getSolrServer(Core core) throws Exception {
    // Zookeeper Hosts
    String solrHosts = ScriptConfiguration.getProperty("SOLRHOSTS");
    if (!solrClients.containsKey(core)) {
        try {//from   w w  w .  j  ava 2  s . co m
            // TODO : change for ZK ensemble
            CloudSolrClient solrClient = new CloudSolrClient(solrHosts);
            solrClient.setDefaultCollection(core.toString());
            solrClient.setZkClientTimeout(60000);
            SolrPing ping = new SolrPing();
            solrClient.request(ping);
            solrClients.put(core, solrClient);
        } catch (Exception e) {
            // test default param
            try {
                CloudSolrClient solrClient = new CloudSolrClient(defaultURL);
                solrClient.setDefaultCollection(core.toString());
                SolrPing ping = new SolrPing();
                solrClient.request(ping);
                solrClients.put(core, solrClient);
            } catch (Exception e2) {
                LOGGER.error("Cannot instanciate Solr Client for core : " + core.toString(), e);
                throw new Exception("Cannot instanciate Solr Client for core : " + core.toString());
            }
        }
    }
    return solrClients.get(core);
}

From source file:org.opencb.commons.datastore.solr.SolrManager.java

License:Apache License

public boolean isAlive(String collection) {
    try {/*w  ww.  ja v a  2s  .  co  m*/
        SolrPing solrPing = new SolrPing();
        SolrPingResponse response = solrPing.process(solrClient, collection);
        return ("OK").equals(response.getResponse().get("status"));
    } catch (SolrServerException | IOException | SolrException e) {
        return false;
    }
}