1 |
54128
|
claudio.at
|
package eu.dnetlib.openaire.directindex.api;
|
2 |
|
|
|
3 |
59343
|
claudio.at
|
import eu.dnetlib.functionality.index.utils.ZkServers;
|
4 |
54128
|
claudio.at
|
import org.apache.commons.logging.Log;
|
5 |
|
|
import org.apache.commons.logging.LogFactory;
|
6 |
59343
|
claudio.at
|
import org.apache.solr.client.solrj.impl.CloudSolrClient;
|
7 |
54128
|
claudio.at
|
|
8 |
59343
|
claudio.at
|
public class IndexClientManager {
|
9 |
54128
|
claudio.at
|
|
10 |
59343
|
claudio.at
|
private static final Log log = LogFactory.getLog(IndexClientManager.class);
|
11 |
54128
|
claudio.at
|
|
12 |
59343
|
claudio.at
|
private CloudSolrClient client = null;
|
13 |
54128
|
claudio.at
|
|
14 |
59343
|
claudio.at
|
public CloudSolrClient getClient(IndexDsInfo info) {
|
15 |
54128
|
claudio.at
|
|
16 |
59343
|
claudio.at
|
if (client == null) {
|
17 |
|
|
log.info(String.format("Initializing solr client (%s) with collection %s", info.getIndexBaseUrl(), info.getColl()));
|
18 |
|
|
ZkServers zk = ZkServers.newInstance(info.getIndexBaseUrl());
|
19 |
|
|
CloudSolrClient.Builder builder = new CloudSolrClient.Builder(zk.getHosts(), zk.getChroot()).withParallelUpdates(true);
|
20 |
|
|
client = builder.build();
|
21 |
55013
|
claudio.at
|
}
|
22 |
59343
|
claudio.at
|
client.setDefaultCollection(info.getColl());
|
23 |
|
|
return client;
|
24 |
54128
|
claudio.at
|
}
|
25 |
|
|
|
26 |
55761
|
claudio.at
|
}
|