Revision 48991
Added by Claudio Atzori over 6 years ago
CloudIndexClientFactory.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import org.apache.commons.logging.Log; |
4 | 4 |
import org.apache.commons.logging.LogFactory; |
5 |
import org.apache.solr.client.solrj.impl.CloudSolrServer;
|
|
5 |
import org.apache.solr.client.solrj.impl.CloudSolrClient;
|
|
6 | 6 |
import org.apache.solr.client.solrj.response.SolrPingResponse; |
7 | 7 |
|
8 | 8 |
/** |
... | ... | |
14 | 14 |
|
15 | 15 |
public static CloudIndexClient newIndexClient(final String baseURL, final String collection, final boolean parallelUpdates) |
16 | 16 |
throws CloudIndexClientException { |
17 |
CloudSolrServer solrServer = null; |
|
18 |
try { |
|
19 | 17 |
|
18 |
try(final CloudSolrClient solrServer = new CloudSolrClient.Builder().withZkHost(baseURL).build()) { |
|
19 |
|
|
20 | 20 |
log.info(String.format("Initializing solr server (%s) ...", baseURL)); |
21 |
solrServer = new CloudSolrServer(baseURL); |
|
22 | 21 |
|
23 | 22 |
solrServer.connect(); |
24 | 23 |
|
... | ... | |
30 | 29 |
log.error("Invalid connection to solr Server (status = 0)"); |
31 | 30 |
throw new CloudIndexClientException("Invalid connection to solr Server (status = 0)"); |
32 | 31 |
} |
33 |
|
|
34 | 32 |
return new CloudIndexClient(solrServer); |
35 | 33 |
} catch (Throwable e) { |
36 |
if (solrServer != null) { |
|
37 |
solrServer.shutdown(); |
|
38 |
} |
|
39 | 34 |
log.error("The initialization of indexClient is FAILED", e); |
40 | 35 |
throw new CloudIndexClientException("The initialization of indexClient is FAILED", e); |
41 | 36 |
} |
42 | 37 |
} |
38 |
|
|
43 | 39 |
} |
Also available in: Unified diff
depending on protobuf specific version, getting rid of person entities, updated solrj version