Search in sources :

Example 1 with Builder

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);
    }
}
Also used : QueryRequest(org.apache.solr.client.solrj.request.QueryRequest) NamedList(org.apache.solr.common.util.NamedList) Builder(org.apache.solr.client.solrj.impl.CloudSolrClient.Builder) FieldComparator(org.apache.solr.client.solrj.io.comp.FieldComparator) MultipleFieldComparator(org.apache.solr.client.solrj.io.comp.MultipleFieldComparator) IOException(java.io.IOException) ModifiableSolrParams(org.apache.solr.common.params.ModifiableSolrParams) IOException(java.io.IOException)

Example 2 with Builder

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();
}
Also used : HashMap(java.util.HashMap) TreeSet(java.util.TreeSet) Builder(org.apache.solr.client.solrj.impl.CloudSolrClient.Builder) ArrayList(java.util.ArrayList)

Example 3 with Builder

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);
    }
}
Also used : QueryRequest(org.apache.solr.client.solrj.request.QueryRequest) NamedList(org.apache.solr.common.util.NamedList) Builder(org.apache.solr.client.solrj.impl.CloudSolrClient.Builder) IOException(java.io.IOException) ModifiableSolrParams(org.apache.solr.common.params.ModifiableSolrParams) IOException(java.io.IOException)

Example 4 with Builder

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));
    }
}
Also used : Builder(org.apache.solr.client.solrj.impl.CloudSolrClient.Builder) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 5 with Builder

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();
    }
}
Also used : Builder(org.apache.solr.client.solrj.impl.CloudSolrClient.Builder)

Aggregations

Builder (org.apache.solr.client.solrj.impl.CloudSolrClient.Builder)6 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 QueryRequest (org.apache.solr.client.solrj.request.QueryRequest)2 ModifiableSolrParams (org.apache.solr.common.params.ModifiableSolrParams)2 NamedList (org.apache.solr.common.util.NamedList)2 Test (org.junit.Test)2 HashMap (java.util.HashMap)1 TreeSet (java.util.TreeSet)1 FieldComparator (org.apache.solr.client.solrj.io.comp.FieldComparator)1 MultipleFieldComparator (org.apache.solr.client.solrj.io.comp.MultipleFieldComparator)1