SOLR-10469: Move CloudSolrClient.setParallelUpdates to its Builder

This commit is contained in:
David Smiley 2017-11-09 15:48:35 -05:00
parent 0546a64acf
commit df3b01744c
2 changed files with 26 additions and 16 deletions

View File

@ -155,6 +155,8 @@ Other Changes
* SOLR-9120: Reduce log level for inconsequential NoSuchFileException that LukeRequestHandler may encounter (hossman)
* SOLR-10469: Move CloudSolrClient.setParallelUpdates to its Builder. (David Smiley)
================== 7.1.0 ==================
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.

View File

@ -115,7 +115,7 @@ public class CloudSolrClient extends SolrClient {
private final boolean updatesToLeaders;
private final boolean directUpdatesToLeadersOnly;
private boolean parallelUpdates = true;
private boolean parallelUpdates; //TODO final
private ExecutorService threadPool = ExecutorUtil
.newMDCAwareCachedThreadPool(new SolrjNamedThreadFactory(
"CloudSolrClient ThreadPool"));
@ -279,6 +279,7 @@ public class CloudSolrClient extends SolrClient {
if (builder.loadBalancedSolrClient == null) builder.loadBalancedSolrClient = createLBHttpSolrClient(builder, myClient);
this.lbClient = builder.loadBalancedSolrClient;
this.updatesToLeaders = builder.shardLeadersOnly;
this.parallelUpdates = builder.parallelUpdates;
this.directUpdatesToLeadersOnly = builder.directUpdatesToLeadersOnly;
}
@ -376,6 +377,17 @@ public class CloudSolrClient extends SolrClient {
assertZKStateProvider().zkClientTimeout = zkClientTimeout;
}
/** Gets whether direct updates are sent in parallel */
public boolean isParallelUpdates() {
return parallelUpdates;
}
/** @deprecated since 7.2 Use {@link Builder} methods instead. */
@Deprecated
public void setParallelUpdates(boolean parallelUpdates) {
this.parallelUpdates = parallelUpdates;
}
/**
* Connect to the zookeeper ensemble.
* This is an optional method that may be used to force a connect before any other requests are sent.
@ -409,10 +421,6 @@ public class CloudSolrClient extends SolrClient {
throw new TimeoutException("Timed out waiting for cluster");
}
public void setParallelUpdates(boolean parallelUpdates) {
this.parallelUpdates = parallelUpdates;
}
private ZkClientClusterStateProvider assertZKStateProvider() {
if (stateProvider instanceof ZkClientClusterStateProvider) {
return (ZkClientClusterStateProvider) stateProvider;
@ -1339,22 +1347,16 @@ public class CloudSolrClient extends SolrClient {
* Constructs {@link CloudSolrClient} instances from provided configuration.
*/
public static class Builder extends SolrClientBuilder<Builder> {
protected Collection<String> zkHosts;
protected List<String> solrUrls;
protected Collection<String> zkHosts = new ArrayList<>();
protected List<String> solrUrls = new ArrayList<>();
protected String zkChroot;
protected LBHttpSolrClient loadBalancedSolrClient;
protected LBHttpSolrClient.Builder lbClientBuilder;
protected boolean shardLeadersOnly;
protected boolean directUpdatesToLeadersOnly;
protected boolean shardLeadersOnly = true;
protected boolean directUpdatesToLeadersOnly = false;
protected boolean parallelUpdates = true;
protected ClusterStateProvider stateProvider;
public Builder() {
this.zkHosts = new ArrayList();
this.solrUrls = new ArrayList();
this.shardLeadersOnly = true;
}
/**
* Provide a ZooKeeper client endpoint to be used when configuring {@link CloudSolrClient} instances.
*
@ -1469,6 +1471,12 @@ public class CloudSolrClient extends SolrClient {
return this;
}
/** Should direct updates to shards be done in parallel (the default) or if not then synchronously? */
public Builder withParallelUpdates(boolean parallelUpdates) {
this.parallelUpdates = parallelUpdates;
return this;
}
public Builder withClusterStateProvider(ClusterStateProvider stateProvider) {
this.stateProvider = stateProvider;
return this;