public static class CloudHttp2SolrClient.Builder extends Object
CloudHttp2SolrClient
instances from provided configuration.Modifier and Type | Field and Description |
---|---|
protected boolean |
directUpdatesToLeadersOnly |
protected Http2SolrClient |
httpClient |
protected Http2SolrClient.Builder |
internalClientBuilder |
protected boolean |
parallelUpdates |
protected boolean |
shardLeadersOnly |
protected List<String> |
solrUrls |
protected ClusterStateProvider |
stateProvider |
protected String |
zkChroot |
protected Collection<String> |
zkHosts |
Constructor and Description |
---|
Builder(List<String> solrUrls)
Provide a series of Solr URLs to be used when configuring
CloudHttp2SolrClient instances. |
Builder(List<String> zkHosts,
Optional<String> zkChroot)
Provide a series of ZK hosts which will be used when configuring
CloudHttp2SolrClient instances. |
Modifier and Type | Method and Description |
---|---|
CloudHttp2SolrClient |
build()
Create a
CloudHttp2SolrClient based on the provided configuration. |
CloudHttp2SolrClient.Builder |
sendDirectUpdatesToAnyShardReplica()
Tells
CloudHttp2SolrClient.Builder that created clients can send updates to any shard replica (shard leaders and non-leaders). |
CloudHttp2SolrClient.Builder |
sendDirectUpdatesToShardLeadersOnly()
Tells
CloudHttp2SolrClient.Builder that created clients should send direct updates to shard leaders only. |
CloudHttp2SolrClient.Builder |
withHttpClient(Http2SolrClient httpClient) |
CloudHttp2SolrClient.Builder |
withInternalClientBuilder(Http2SolrClient.Builder internalClientBuilder)
If provided, the CloudHttp2SolrClient will build it's internal Http2SolrClient using this builder
(instead of the empty default one).
|
CloudHttp2SolrClient.Builder |
withParallelUpdates(boolean parallelUpdates)
Tells
CloudHttp2SolrClient.Builder whether created clients should send shard updates serially or in parallel
When an UpdateRequest affects multiple shards, CloudHttp2SolrClient splits it up and sends a request
to each affected shard. |
protected Collection<String> zkHosts
protected String zkChroot
protected Http2SolrClient httpClient
protected boolean shardLeadersOnly
protected boolean directUpdatesToLeadersOnly
protected boolean parallelUpdates
protected ClusterStateProvider stateProvider
protected Http2SolrClient.Builder internalClientBuilder
public Builder(List<String> solrUrls)
CloudHttp2SolrClient
instances.
The solr client will use these urls to understand the cluster topology, which solr nodes are active etc.
Provided Solr URLs are expected to point to the root Solr path ("http://hostname:8983/solr"); they should not
include any collections, cores, or other path components.
Usage example:
final List<String> solrBaseUrls = new ArrayList<String>(); solrBaseUrls.add("http://solr1:8983/solr"); solrBaseUrls.add("http://solr2:8983/solr"); solrBaseUrls.add("http://solr3:8983/solr"); final SolrClient client = new CloudHttp2SolrClient.Builder(solrBaseUrls).build();
public Builder(List<String> zkHosts, Optional<String> zkChroot)
CloudHttp2SolrClient
instances.
Usage example when Solr stores data at the ZooKeeper root ('/'):
final List<String> zkServers = new ArrayList<String>(); zkServers.add("zookeeper1:2181"); zkServers.add("zookeeper2:2181"); zkServers.add("zookeeper3:2181"); final SolrClient client = new CloudHttp2SolrClient.Builder(zkServers, Optional.empty()).build();Usage example when Solr data is stored in a ZooKeeper chroot:
final List<String> zkServers = new ArrayList<String>(); zkServers.add("zookeeper1:2181"); zkServers.add("zookeeper2:2181"); zkServers.add("zookeeper3:2181"); final SolrClient client = new CloudHttp2SolrClient.Builder(zkServers, Optional.of("/solr")).build();
zkHosts
- a List of at least one ZooKeeper host and port (e.g. "zookeeper1:2181")zkChroot
- the path to the root ZooKeeper node containing Solr data. Provide java.util.Optional.empty()
if no ZK chroot is used.public CloudHttp2SolrClient.Builder sendDirectUpdatesToShardLeadersOnly()
CloudHttp2SolrClient.Builder
that created clients should send direct updates to shard leaders only.
UpdateRequests whose leaders cannot be found will "fail fast" on the client side with a SolrException
public CloudHttp2SolrClient.Builder sendDirectUpdatesToAnyShardReplica()
CloudHttp2SolrClient.Builder
that created clients can send updates to any shard replica (shard leaders and non-leaders).
Shard leaders are still preferred, but the created clients will fallback to using other replicas if a leader
cannot be found.public CloudHttp2SolrClient.Builder withParallelUpdates(boolean parallelUpdates)
CloudHttp2SolrClient.Builder
whether created clients should send shard updates serially or in parallel
When an UpdateRequest
affects multiple shards, CloudHttp2SolrClient
splits it up and sends a request
to each affected shard. This setting chooses whether those sub-requests are sent serially or in parallel.
If not set, this defaults to 'true' and sends sub-requests in parallel.
public CloudHttp2SolrClient.Builder withHttpClient(Http2SolrClient httpClient)
public CloudHttp2SolrClient.Builder withInternalClientBuilder(Http2SolrClient.Builder internalClientBuilder)
internalClientBuilder
- the builder to use for creating the internal http client.public CloudHttp2SolrClient build()
CloudHttp2SolrClient
based on the provided configuration.Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.