use of org.apache.solr.client.solrj.impl.CloudSolrClient.Builder in project lucene-solr by apache.
the class FacetStream method open.
public void open() throws IOException {
if (cache != null) {
cloudSolrClient = cache.getCloudSolrClient(zkHost);
} else {
cloudSolrClient = new Builder().withZkHost(zkHost).build();
}
FieldComparator[] adjustedSorts = adjustSorts(buckets, bucketSorts);
String json = getJsonFacetString(buckets, metrics, adjustedSorts, bucketSizeLimit);
ModifiableSolrParams paramsLoc = new ModifiableSolrParams(params);
paramsLoc.set("json.facet", json);
paramsLoc.set("rows", "0");
QueryRequest request = new QueryRequest(paramsLoc);
try {
NamedList response = cloudSolrClient.request(request, collection);
getTuples(response, buckets, metrics);
Collections.sort(tuples, getStreamSort());
} catch (Exception e) {
throw new IOException(e);
}
}
use of org.apache.solr.client.solrj.impl.CloudSolrClient.Builder in project lucene-solr by apache.
the class TopicStream method open.
public void open() throws IOException {
this.tuples = new TreeSet();
this.solrStreams = new ArrayList();
this.eofTuples = Collections.synchronizedMap(new HashMap());
if (checkpoints.size() == 0 && streamContext.numWorkers > 1) {
//Each worker must maintain it's own checkpoints
this.id = this.id + "_" + streamContext.workerID;
}
if (streamContext.getSolrClientCache() != null) {
cloudSolrClient = streamContext.getSolrClientCache().getCloudSolrClient(zkHost);
} else {
cloudSolrClient = new Builder().withZkHost(zkHost).build();
this.cloudSolrClient.connect();
}
if (checkpoints.size() == 0) {
getPersistedCheckpoints();
if (checkpoints.size() == 0) {
getCheckpoints();
}
}
constructStreams();
openStreams();
}
use of org.apache.solr.client.solrj.impl.CloudSolrClient.Builder in project lucene-solr by apache.
the class TimeSeriesStream method open.
public void open() throws IOException {
if (cache != null) {
cloudSolrClient = cache.getCloudSolrClient(zkHost);
} else {
cloudSolrClient = new Builder().withZkHost(zkHost).build();
}
String json = getJsonFacetString(field, metrics, start, end, gap);
ModifiableSolrParams paramsLoc = new ModifiableSolrParams(params);
paramsLoc.set("json.facet", json);
paramsLoc.set("rows", "0");
QueryRequest request = new QueryRequest(paramsLoc);
try {
NamedList response = cloudSolrClient.request(request, collection);
getTuples(response, field, metrics);
} catch (Exception e) {
throw new IOException(e);
}
}
use of org.apache.solr.client.solrj.impl.CloudSolrClient.Builder in project lucene-solr by apache.
the class CloudSolrClientBuilderTest method testSeveralZkHostsSpecifiedTogether.
@Test
public void testSeveralZkHostsSpecifiedTogether() throws IOException {
final ArrayList<String> zkHosts = new ArrayList<String>();
zkHosts.add(ANY_ZK_HOST);
zkHosts.add(ANY_OTHER_ZK_HOST);
try (CloudSolrClient createdClient = new Builder().withZkHost(zkHosts).withZkChroot(ANY_CHROOT).build()) {
final String clientZkHost = createdClient.getZkHost();
assertTrue(clientZkHost.contains(ANY_ZK_HOST));
assertTrue(clientZkHost.contains(ANY_OTHER_ZK_HOST));
}
}
use of org.apache.solr.client.solrj.impl.CloudSolrClient.Builder in project lucene-solr by apache.
the class UpdateStream method setCloudSolrClient.
private void setCloudSolrClient() {
if (this.cache != null) {
this.cloudSolrClient = this.cache.getCloudSolrClient(zkHost);
} else {
this.cloudSolrClient = new Builder().withZkHost(zkHost).build();
this.cloudSolrClient.connect();
}
}
Aggregations