You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ab...@apache.org on 2017/11/17 08:33:23 UTC

[02/40] lucene-solr:jira/solr-11285-sim: SOLR-10469: Move CloudSolrClient.setParallelUpdates to its Builder

SOLR-10469: Move CloudSolrClient.setParallelUpdates to its Builder


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/df3b0174
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/df3b0174
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/df3b0174

Branch: refs/heads/jira/solr-11285-sim
Commit: df3b01744c46587db2055e1ffd15393c46c55019
Parents: 0546a64
Author: David Smiley <ds...@apache.org>
Authored: Thu Nov 9 15:48:35 2017 -0500
Committer: David Smiley <ds...@apache.org>
Committed: Thu Nov 9 15:48:35 2017 -0500

----------------------------------------------------------------------
 solr/CHANGES.txt                                |  2 +
 .../solr/client/solrj/impl/CloudSolrClient.java | 40 ++++++++++++--------
 2 files changed, 26 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/df3b0174/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index fdfb738..db55069 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -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.

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/df3b0174/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java
index d746fe6..cdc3770 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java
@@ -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;