Class CloudLegacySolrClient.Builder
- java.lang.Object
-
- org.apache.solr.client.solrj.impl.SolrClientBuilder<CloudLegacySolrClient.Builder>
-
- org.apache.solr.client.solrj.impl.CloudLegacySolrClient.Builder
-
- Enclosing class:
- CloudLegacySolrClient
public static class CloudLegacySolrClient.Builder extends SolrClientBuilder<CloudLegacySolrClient.Builder>
ConstructsCloudLegacySolrClient
instances from provided configuration.
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
directUpdatesToLeadersOnly
protected LBHttpSolrClient.Builder
lbClientBuilder
protected LBHttpSolrClient
loadBalancedSolrClient
protected boolean
parallelUpdates
protected long
retryExpiryTimeNano
protected boolean
shardLeadersOnly
protected List<String>
solrUrls
protected ClusterStateProvider
stateProvider
protected String
zkChroot
protected Collection<String>
zkHosts
-
Fields inherited from class org.apache.solr.client.solrj.impl.SolrClientBuilder
connectionTimeoutMillis, defaultCollection, followRedirects, httpClient, requestWriter, responseParser, socketTimeoutMillis, timeToLiveSeconds, urlParamNames, useMultiPartPost
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
Builder()
Constructor for use by subclasses.Builder(List<String> solrUrls)
Provide a series of Solr URLs to be used when configuringCloudLegacySolrClient
instances.Builder(List<String> zkHosts, Optional<String> zkChroot)
Provide a series of ZK hosts which will be used when configuringCloudLegacySolrClient
instances.Builder(ClusterStateProvider stateProvider)
Provide an already createdClusterStateProvider
instance
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description CloudLegacySolrClient
build()
Create aCloudLegacySolrClient
based on the provided configuration.CloudLegacySolrClient.Builder
canUseZkACLs(boolean canUseZkACLs)
Whether to use the default ZK ACLs when building a ZK Client.CloudLegacySolrClient.Builder
getThis()
The solution for the unchecked cast warning.CloudLegacySolrClient.Builder
sendDirectUpdatesToAnyShardReplica()
TellsCloudLegacySolrClient.Builder
that created clients can send updates to any shard replica (shard leaders and non-leaders).CloudLegacySolrClient.Builder
sendDirectUpdatesToShardLeadersOnly()
TellsCloudLegacySolrClient.Builder
that created clients should send direct updates to shard leaders only.CloudLegacySolrClient.Builder
sendUpdatesOnlyToShardLeaders()
TellsCloudLegacySolrClient.Builder
that created clients should be configured such thatCloudSolrClient.isUpdatesToLeaders()
returnstrue
.CloudLegacySolrClient.Builder
sendUpdatesToAllReplicasInShard()
Deprecated.Never supportedCloudLegacySolrClient.Builder
sendUpdatesToAnyReplica()
TellsCloudLegacySolrClient.Builder
that created clients should be configured such thatCloudSolrClient.isUpdatesToLeaders()
returnsfalse
.CloudLegacySolrClient.Builder
withCollectionCacheTtl(int seconds)
Sets the cache ttl for DocCollection Objects cached.CloudLegacySolrClient.Builder
withLBHttpSolrClient(LBHttpSolrClient loadBalancedSolrClient)
Provides aLBHttpSolrClient
for the builder to use when creating clients.CloudLegacySolrClient.Builder
withLBHttpSolrClientBuilder(LBHttpSolrClient.Builder lbHttpSolrClientBuilder)
Provides aHttpClient
for the builder to use when creating clients.CloudLegacySolrClient.Builder
withParallelUpdates(boolean parallelUpdates)
TellsCloudLegacySolrClient.Builder
whether created clients should send shard updates serially or in parallelCloudLegacySolrClient.Builder
withZkClientTimeout(int zkClientTimeout, TimeUnit unit)
Sets the Zk client session timeoutCloudLegacySolrClient.Builder
withZkConnectTimeout(int zkConnectTimeout, TimeUnit unit)
Sets the Zk connection timeout-
Methods inherited from class org.apache.solr.client.solrj.impl.SolrClientBuilder
allowMultiPartPost, getConnectionTimeoutMillis, getSocketTimeoutMillis, withConnectionTimeout, withConnectionTimeout, withDefaultCollection, withFollowRedirects, withHttpClient, withRequestWriter, withResponseParser, withSocketTimeout, withSocketTimeout, withTheseParamNamesInTheUrl
-
-
-
-
Field Detail
-
zkHosts
protected Collection<String> zkHosts
-
zkChroot
protected String zkChroot
-
loadBalancedSolrClient
protected LBHttpSolrClient loadBalancedSolrClient
-
lbClientBuilder
protected LBHttpSolrClient.Builder lbClientBuilder
-
shardLeadersOnly
protected boolean shardLeadersOnly
-
directUpdatesToLeadersOnly
protected boolean directUpdatesToLeadersOnly
-
parallelUpdates
protected boolean parallelUpdates
-
retryExpiryTimeNano
protected long retryExpiryTimeNano
-
stateProvider
protected ClusterStateProvider stateProvider
-
-
Constructor Detail
-
Builder
protected Builder()
Constructor for use by subclasses. This constructor was public prior to version 9.0
-
Builder
public Builder(List<String> solrUrls)
Provide a series of Solr URLs to be used when configuringCloudLegacySolrClient
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 CloudSolrClient.Builder(solrBaseUrls).build();
-
Builder
public Builder(ClusterStateProvider stateProvider)
Provide an already createdClusterStateProvider
instance
-
Builder
public Builder(List<String> zkHosts, Optional<String> zkChroot)
Provide a series of ZK hosts which will be used when configuringCloudLegacySolrClient
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 CloudSolrClient.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 CloudSolrClient.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
-
canUseZkACLs
public CloudLegacySolrClient.Builder canUseZkACLs(boolean canUseZkACLs)
Whether to use the default ZK ACLs when building a ZK Client.
-
withLBHttpSolrClientBuilder
public CloudLegacySolrClient.Builder withLBHttpSolrClientBuilder(LBHttpSolrClient.Builder lbHttpSolrClientBuilder)
Provides aHttpClient
for the builder to use when creating clients.
-
withLBHttpSolrClient
public CloudLegacySolrClient.Builder withLBHttpSolrClient(LBHttpSolrClient loadBalancedSolrClient)
Provides aLBHttpSolrClient
for the builder to use when creating clients.
-
withCollectionCacheTtl
public CloudLegacySolrClient.Builder withCollectionCacheTtl(int seconds)
Sets the cache ttl for DocCollection Objects cached.- Parameters:
seconds
- ttl value in seconds
-
sendUpdatesOnlyToShardLeaders
public CloudLegacySolrClient.Builder sendUpdatesOnlyToShardLeaders()
TellsCloudLegacySolrClient.Builder
that created clients should be configured such thatCloudSolrClient.isUpdatesToLeaders()
returnstrue
.
-
sendUpdatesToAnyReplica
public CloudLegacySolrClient.Builder sendUpdatesToAnyReplica()
TellsCloudLegacySolrClient.Builder
that created clients should be configured such thatCloudSolrClient.isUpdatesToLeaders()
returnsfalse
.
-
sendUpdatesToAllReplicasInShard
@Deprecated public CloudLegacySolrClient.Builder sendUpdatesToAllReplicasInShard()
Deprecated.Never supportedThis method has no effect.In older versions of Solr, this method was an incorrectly named equivalent to
sendUpdatesToAnyReplica()
, which had no effect because that setting was ignored in the created clients. When the underlyingCloudSolrClient
behavior was fixed, this method was modified to be an explicit No-Op, since the implied behavior of sending updates to all replicas has never been supported, and was never intended to be supported.
-
sendDirectUpdatesToShardLeadersOnly
public CloudLegacySolrClient.Builder sendDirectUpdatesToShardLeadersOnly()
TellsCloudLegacySolrClient.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
-
sendDirectUpdatesToAnyShardReplica
public CloudLegacySolrClient.Builder sendDirectUpdatesToAnyShardReplica()
TellsCloudLegacySolrClient.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 fall back to using other replicas if a leader cannot be found.
-
withParallelUpdates
public CloudLegacySolrClient.Builder withParallelUpdates(boolean parallelUpdates)
TellsCloudLegacySolrClient.Builder
whether created clients should send shard updates serially or in parallelWhen an
UpdateRequest
affects multiple shards,CloudLegacySolrClient
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.
-
withZkConnectTimeout
public CloudLegacySolrClient.Builder withZkConnectTimeout(int zkConnectTimeout, TimeUnit unit)
Sets the Zk connection timeout- Parameters:
zkConnectTimeout
- timeout valueunit
- time unit
-
withZkClientTimeout
public CloudLegacySolrClient.Builder withZkClientTimeout(int zkClientTimeout, TimeUnit unit)
Sets the Zk client session timeout- Parameters:
zkClientTimeout
- timeout valueunit
- time unit
-
build
public CloudLegacySolrClient build()
Create aCloudLegacySolrClient
based on the provided configuration.
-
getThis
public CloudLegacySolrClient.Builder getThis()
Description copied from class:SolrClientBuilder
The solution for the unchecked cast warning.- Specified by:
getThis
in classSolrClientBuilder<CloudLegacySolrClient.Builder>
-
-