Class CloudHttp2SolrClient.Builder
- java.lang.Object
-
- org.apache.solr.client.solrj.impl.CloudHttp2SolrClient.Builder
-
- Direct Known Subclasses:
CloudSolrClient.Builder
- Enclosing class:
- CloudHttp2SolrClient
public static class CloudHttp2SolrClient.Builder extends Object
ConstructsCloudHttp2SolrClientinstances from provided configuration.
-
-
Field Summary
Fields Modifier and Type Field Description protected booleandirectUpdatesToLeadersOnlyprotected Http2SolrClienthttpClientprotected Http2SolrClient.BuilderinternalClientBuilderprotected booleanparallelUpdatesprotected booleanshardLeadersOnlyprotected List<String>solrUrlsprotected ClusterStateProviderstateProviderprotected StringzkChrootprotected Collection<String>zkHosts
-
Constructor Summary
Constructors Constructor Description Builder(List<String> solrUrls)Provide a series of Solr URLs to be used when configuringCloudHttp2SolrClientinstances.Builder(List<String> zkHosts, Optional<String> zkChroot)Provide a series of ZK hosts which will be used when configuringCloudHttp2SolrClientinstances.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description CloudHttp2SolrClientbuild()Create aCloudHttp2SolrClientbased on the provided configuration.CloudHttp2SolrClient.BuildersendDirectUpdatesToAnyShardReplica()TellsCloudHttp2SolrClient.Builderthat created clients can send updates to any shard replica (shard leaders and non-leaders).CloudHttp2SolrClient.BuildersendDirectUpdatesToShardLeadersOnly()TellsCloudHttp2SolrClient.Builderthat created clients should send direct updates to shard leaders only.CloudHttp2SolrClient.BuildersendUpdatesOnlyToShardLeaders()TellsCloudHttp2SolrClient.Builderthat created clients should be configured such thatCloudSolrClient.isUpdatesToLeaders()returnstrue.CloudHttp2SolrClient.BuildersendUpdatesToAnyReplica()TellsCloudHttp2SolrClient.Builderthat created clients should be configured such thatCloudSolrClient.isUpdatesToLeaders()returnsfalse.CloudHttp2SolrClient.BuildersetParallelCacheRefreshes(int parallelCacheRefreshesLocks)Deprecated.Please usewithParallelCacheRefreshes(int)CloudHttp2SolrClient.BuildersetRetryExpiryTime(int secs)Deprecated.Please usewithRetryExpiryTime(long, TimeUnit)CloudHttp2SolrClient.BuilderwithCollectionCacheTtl(int timeToLiveSeconds)Deprecated.Please usewithCollectionCacheTtl(long, TimeUnit)CloudHttp2SolrClient.BuilderwithCollectionCacheTtl(long timeToLive, TimeUnit unit)Sets the cache ttl for DocCollection Objects cached.CloudHttp2SolrClient.BuilderwithDefaultCollection(String collection)Sets the default collection for request.CloudHttp2SolrClient.BuilderwithHttpClient(Http2SolrClient httpClient)Set the internal http client.CloudHttp2SolrClient.BuilderwithInternalClientBuilder(Http2SolrClient.Builder internalClientBuilder)If provided, the CloudHttp2SolrClient will build it's internal Http2SolrClient using this builder (instead of the empty default one).CloudHttp2SolrClient.BuilderwithParallelCacheRefreshes(int parallelCacheRefreshesLocks)When caches are expired then they are refreshed after acquiring a lock.CloudHttp2SolrClient.BuilderwithParallelUpdates(boolean parallelUpdates)TellsCloudHttp2SolrClient.Builderwhether created clients should send shard updates serially or in parallelCloudHttp2SolrClient.BuilderwithRequestWriter(RequestWriter requestWriter)Provides aRequestWriterfor created clients to use when handing requests.CloudHttp2SolrClient.BuilderwithResponseParser(ResponseParser responseParser)Provides aResponseParserfor created clients to use when handling requests.CloudHttp2SolrClient.BuilderwithRetryExpiryTime(long expiryTime, TimeUnit unit)This is the time to wait to refetch the state after getting the same state version from ZKCloudHttp2SolrClient.BuilderwithZkClientTimeout(int zkClientTimeout, TimeUnit unit)Sets the Zk client session timeoutCloudHttp2SolrClient.BuilderwithZkConnectTimeout(int zkConnectTimeout, TimeUnit unit)Sets the Zk connection timeout
-
-
-
Field Detail
-
zkHosts
protected Collection<String> zkHosts
-
zkChroot
protected String zkChroot
-
httpClient
protected Http2SolrClient httpClient
-
shardLeadersOnly
protected boolean shardLeadersOnly
-
directUpdatesToLeadersOnly
protected boolean directUpdatesToLeadersOnly
-
parallelUpdates
protected boolean parallelUpdates
-
stateProvider
protected ClusterStateProvider stateProvider
-
internalClientBuilder
protected Http2SolrClient.Builder internalClientBuilder
-
-
Constructor Detail
-
Builder
public Builder(List<String> solrUrls)
Provide a series of Solr URLs to be used when configuringCloudHttp2SolrClientinstances. 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();
-
Builder
public Builder(List<String> zkHosts, Optional<String> zkChroot)
Provide a series of ZK hosts which will be used when configuringCloudHttp2SolrClientinstances.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();- Parameters:
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. Providejava.util.Optional.empty()if no ZK chroot is used.
-
-
Method Detail
-
sendUpdatesOnlyToShardLeaders
public CloudHttp2SolrClient.Builder sendUpdatesOnlyToShardLeaders()
TellsCloudHttp2SolrClient.Builderthat created clients should be configured such thatCloudSolrClient.isUpdatesToLeaders()returnstrue.
-
sendUpdatesToAnyReplica
public CloudHttp2SolrClient.Builder sendUpdatesToAnyReplica()
TellsCloudHttp2SolrClient.Builderthat created clients should be configured such thatCloudSolrClient.isUpdatesToLeaders()returnsfalse.
-
sendDirectUpdatesToShardLeadersOnly
public CloudHttp2SolrClient.Builder sendDirectUpdatesToShardLeadersOnly()
TellsCloudHttp2SolrClient.Builderthat 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
-
sendDirectUpdatesToAnyShardReplica
public CloudHttp2SolrClient.Builder sendDirectUpdatesToAnyShardReplica()
TellsCloudHttp2SolrClient.Builderthat 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.
-
withRequestWriter
public CloudHttp2SolrClient.Builder withRequestWriter(RequestWriter requestWriter)
Provides aRequestWriterfor created clients to use when handing requests.
-
withResponseParser
public CloudHttp2SolrClient.Builder withResponseParser(ResponseParser responseParser)
Provides aResponseParserfor created clients to use when handling requests.
-
withParallelUpdates
public CloudHttp2SolrClient.Builder withParallelUpdates(boolean parallelUpdates)
TellsCloudHttp2SolrClient.Builderwhether created clients should send shard updates serially or in parallelWhen an
UpdateRequestaffects multiple shards,CloudHttp2SolrClientsplits 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.
-
setParallelCacheRefreshes
@Deprecated(since="9.2") public CloudHttp2SolrClient.Builder setParallelCacheRefreshes(int parallelCacheRefreshesLocks)
Deprecated.Please usewithParallelCacheRefreshes(int)When caches are expired then they are refreshed after acquiring a lock. Use this to set the number of locks.Defaults to 3.
-
withParallelCacheRefreshes
public CloudHttp2SolrClient.Builder withParallelCacheRefreshes(int parallelCacheRefreshesLocks)
When caches are expired then they are refreshed after acquiring a lock. Use this to set the number of locks.Defaults to 3.
-
setRetryExpiryTime
@Deprecated(since="9.2") public CloudHttp2SolrClient.Builder setRetryExpiryTime(int secs)
Deprecated.Please usewithRetryExpiryTime(long, TimeUnit)This is the time to wait to refetch the state after getting the same state version from ZK
-
withRetryExpiryTime
public CloudHttp2SolrClient.Builder withRetryExpiryTime(long expiryTime, TimeUnit unit)
This is the time to wait to refetch the state after getting the same state version from ZK
-
withDefaultCollection
public CloudHttp2SolrClient.Builder withDefaultCollection(String collection)
Sets the default collection for request.
-
withCollectionCacheTtl
@Deprecated(since="9.2") public CloudHttp2SolrClient.Builder withCollectionCacheTtl(int timeToLiveSeconds)
Deprecated.Please usewithCollectionCacheTtl(long, TimeUnit)Sets the cache ttl for DocCollection Objects cached.- Parameters:
timeToLiveSeconds- ttl value in seconds
-
withCollectionCacheTtl
public CloudHttp2SolrClient.Builder withCollectionCacheTtl(long timeToLive, TimeUnit unit)
Sets the cache ttl for DocCollection Objects cached.- Parameters:
timeToLive- ttl value
-
withHttpClient
public CloudHttp2SolrClient.Builder withHttpClient(Http2SolrClient httpClient)
Set the internal http client.Note: closing the httpClient instance is at the responsibility of the caller.
- Parameters:
httpClient- http client- Returns:
- this
-
withInternalClientBuilder
public 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). Providing this builder allows users to configure the internal clients (authentication, timeouts, etc).- Parameters:
internalClientBuilder- the builder to use for creating the internal http client.- Returns:
- this
-
withZkConnectTimeout
public CloudHttp2SolrClient.Builder withZkConnectTimeout(int zkConnectTimeout, TimeUnit unit)
Sets the Zk connection timeout- Parameters:
zkConnectTimeout- timeout valueunit- time unit
-
withZkClientTimeout
public CloudHttp2SolrClient.Builder withZkClientTimeout(int zkClientTimeout, TimeUnit unit)
Sets the Zk client session timeout- Parameters:
zkClientTimeout- timeout valueunit- time unit
-
build
public CloudHttp2SolrClient build()
Create aCloudHttp2SolrClientbased on the provided configuration.
-
-