lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elyog...@apache.org
Subject svn commit: r1620185 - in /lucene/dev/branches/branch_4x: ./ solr/ solr/core/ solr/core/src/test/org/apache/solr/cloud/ solr/solrj/ solr/solrj/src/java/org/apache/solr/client/solrj/impl/ solr/test-framework/ solr/test-framework/src/java/org/apache/solr...
Date Sun, 24 Aug 2014 20:19:44 GMT
Author: elyograg
Date: Sun Aug 24 20:19:44 2014
New Revision: 1620185

URL: http://svn.apache.org/r1620185
Log:
SOLR-6390: CloudSolrServer constructor improvements. (merge trunk r1620146)

Modified:
    lucene/dev/branches/branch_4x/   (props changed)
    lucene/dev/branches/branch_4x/solr/   (props changed)
    lucene/dev/branches/branch_4x/solr/CHANGES.txt   (contents, props changed)
    lucene/dev/branches/branch_4x/solr/core/   (props changed)
    lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java
    lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/ShardSplitTest.java
    lucene/dev/branches/branch_4x/solr/solrj/   (props changed)
    lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrServer.java
    lucene/dev/branches/branch_4x/solr/test-framework/   (props changed)
    lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java

Modified: lucene/dev/branches/branch_4x/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/CHANGES.txt?rev=1620185&r1=1620184&r2=1620185&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_4x/solr/CHANGES.txt Sun Aug 24 20:19:44 2014
@@ -60,6 +60,10 @@ Other Changes
 * LUCENE-5650: Tests can no longer write to CWD. Update log dir is now made relative
   to the instance dir if it is not an absolute path. (Ryan Ernst, Dawid Weiss)
 
+* SOLR-6390: Remove unnecessary checked exception for CloudSolrServer
+  constructors, improve javadocs for CloudSolrServer constructors.
+  (Steve Davids via Shawn Heisey)
+
 ==================  4.10.0 =================
 
 Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release

Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java?rev=1620185&r1=1620184&r2=1620185&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java
(original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java
Sun Aug 24 20:19:44 2014
@@ -18,7 +18,6 @@ package org.apache.solr.cloud;
  */
 
 import java.io.IOException;
-import java.net.MalformedURLException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
@@ -1148,16 +1147,12 @@ public class BasicDistributedZkTest exte
   protected CloudSolrServer getCommonCloudSolrServer() {
     if (commondCloudSolrServer == null) {
       synchronized(this) {
-        try {
-          commondCloudSolrServer = new CloudSolrServer(zkServer.getZkAddress(), random().nextBoolean());
-          commondCloudSolrServer.setParallelUpdates(random().nextBoolean());
-          commondCloudSolrServer.setDefaultCollection(DEFAULT_COLLECTION);
-          commondCloudSolrServer.getLbServer().setConnectionTimeout(15000);
-          commondCloudSolrServer.getLbServer().setSoTimeout(30000);
-          commondCloudSolrServer.connect();
-        } catch (MalformedURLException e) {
-          throw new RuntimeException(e);
-        }
+        commondCloudSolrServer = new CloudSolrServer(zkServer.getZkAddress(), random().nextBoolean());
+        commondCloudSolrServer.setParallelUpdates(random().nextBoolean());
+        commondCloudSolrServer.setDefaultCollection(DEFAULT_COLLECTION);
+        commondCloudSolrServer.getLbServer().setConnectionTimeout(15000);
+        commondCloudSolrServer.getLbServer().setSoTimeout(30000);
+        commondCloudSolrServer.connect();
       }
     }
     return commondCloudSolrServer;

Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/ShardSplitTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/ShardSplitTest.java?rev=1620185&r1=1620184&r2=1620185&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/ShardSplitTest.java
(original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/ShardSplitTest.java
Sun Aug 24 20:19:44 2014
@@ -614,7 +614,7 @@ public class ShardSplitTest extends Basi
   }
 
   @Override
-  protected CloudSolrServer createCloudClient(String defaultCollection) throws MalformedURLException
{
+  protected CloudSolrServer createCloudClient(String defaultCollection) {
     CloudSolrServer client = super.createCloudClient(defaultCollection);
     client.getLbServer().getHttpClient().getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT,
5 * 60 * 1000);
     return client;

Modified: lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrServer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrServer.java?rev=1620185&r1=1620184&r2=1620185&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrServer.java
(original)
+++ lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrServer.java
Sun Aug 24 20:19:44 2014
@@ -18,7 +18,6 @@ package org.apache.solr.client.solrj.imp
  */
 
 import java.io.IOException;
-import java.net.MalformedURLException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -113,24 +112,38 @@ public class CloudSolrServer extends Sol
 
   }
 
-
-
   /**
-   * @param zkHost The client endpoint of the zookeeper quorum containing the cloud state,
-   * in the form HOST:PORT.
+   * Create a new client object that connects to Zookeeper and is always aware
+   * of the SolrCloud state. If there is a fully redundant Zookeeper quorum and
+   * SolrCloud has enough replicas for every shard in a collection, there is no
+   * single point of failure. Updates will be sent to shard leaders by default.
+   * 
+   * @param zkHost
+   *          The client endpoint of the zookeeper quorum containing the cloud
+   *          state. The full specification for this string is one or more comma
+   *          separated HOST:PORT values, followed by an optional chroot value
+   *          that starts with a forward slash. Using a chroot allows multiple
+   *          applications to coexist in one ensemble. For full details, see the
+   *          Zookeeper documentation. Some examples:
+   *          <p/>
+   *          "host1:2181"
+   *          <p/>
+   *          "host1:2181,host2:2181,host3:2181/mysolrchroot"
+   *          <p/>
+   *          "zoo1.example.com:2181,zoo2.example.com:2181,zoo3.example.com:2181"
    */
   public CloudSolrServer(String zkHost) {
-      this.zkHost = zkHost;
-      this.myClient = HttpClientUtil.createClient(null);
-      this.lbServer = new LBHttpSolrServer(myClient);
-      this.lbServer.setRequestWriter(new BinaryRequestWriter());
-      this.lbServer.setParser(new BinaryResponseParser());
-      this.updatesToLeaders = true;
-      shutdownLBHttpSolrServer = true;
+      this(zkHost, true);
   }
   
-  public CloudSolrServer(String zkHost, boolean updatesToLeaders)
-      throws MalformedURLException {
+  /**
+   * @param zkHost
+   *          A zookeeper client endpoint.
+   * @param updatesToLeaders
+   *          If true, sends updates only to shard leaders.
+   * @see #CloudSolrServer(String) for full description and details on zkHost
+   */
+  public CloudSolrServer(String zkHost, boolean updatesToLeaders) {
     this.zkHost = zkHost;
     this.myClient = HttpClientUtil.createClient(null);
     this.lbServer = new LBHttpSolrServer(myClient);
@@ -141,22 +154,24 @@ public class CloudSolrServer extends Sol
   }
 
   /**
-   * @param zkHost The client endpoint of the zookeeper quorum containing the cloud state,
-   * in the form HOST:PORT.
-   * @param lbServer LBHttpSolrServer instance for requests. 
+   * @param zkHost
+   *          A zookeeper client endpoint.
+   * @param lbServer
+   *          LBHttpSolrServer instance for requests.
+   * @see #CloudSolrServer(String) for full description and details on zkHost
    */
   public CloudSolrServer(String zkHost, LBHttpSolrServer lbServer) {
-    this.zkHost = zkHost;
-    this.lbServer = lbServer;
-    this.updatesToLeaders = true;
-    shutdownLBHttpSolrServer = false;
+    this(zkHost, lbServer, true);
   }
   
   /**
-   * @param zkHost The client endpoint of the zookeeper quorum containing the cloud state,
-   * in the form HOST:PORT.
-   * @param lbServer LBHttpSolrServer instance for requests. 
-   * @param updatesToLeaders sends updates only to leaders - defaults to true
+   * @param zkHost
+   *          A zookeeper client endpoint.
+   * @param lbServer
+   *          LBHttpSolrServer instance for requests.
+   * @param updatesToLeaders
+   *          If true, sends updates only to shard leaders.
+   * @see #CloudSolrServer(String) for full description and details on zkHost
    */
   public CloudSolrServer(String zkHost, LBHttpSolrServer lbServer, boolean updatesToLeaders)
{
     this.zkHost = zkHost;

Modified: lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java?rev=1620185&r1=1620184&r2=1620185&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java
(original)
+++ lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java
Sun Aug 24 20:19:44 2014
@@ -25,7 +25,6 @@ import static org.apache.solr.common.clo
 
 import java.io.File;
 import java.io.IOException;
-import java.net.MalformedURLException;
 import java.net.URI;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -251,13 +250,8 @@ public abstract class AbstractFullDistri
   protected void initCloud() throws Exception {
     assert(cloudInit == false);
     cloudInit = true;
-    try {
-      cloudClient = createCloudClient(DEFAULT_COLLECTION);
-      
-      cloudClient.connect();
-    } catch (MalformedURLException e) {
-      throw new RuntimeException(e);
-    }
+    cloudClient = createCloudClient(DEFAULT_COLLECTION);
+    cloudClient.connect();
     
     ZkStateReader zkStateReader = cloudClient.getZkStateReader();
     
@@ -265,8 +259,7 @@ public abstract class AbstractFullDistri
         shardToJetty, shardToLeaderJetty);
   }
   
-  protected CloudSolrServer createCloudClient(String defaultCollection)
-      throws MalformedURLException {
+  protected CloudSolrServer createCloudClient(String defaultCollection) {
     CloudSolrServer server = new CloudSolrServer(zkServer.getZkAddress(), random().nextBoolean());
     server.setParallelUpdates(random().nextBoolean());
     if (defaultCollection != null) server.setDefaultCollection(defaultCollection);
@@ -1668,16 +1661,12 @@ public abstract class AbstractFullDistri
   protected CloudSolrServer getCommonCloudSolrServer() {
     synchronized (this) {
       if (commondCloudSolrServer == null) {
-        try {
-          commondCloudSolrServer = new CloudSolrServer(zkServer.getZkAddress(),
-              random().nextBoolean());
-          commondCloudSolrServer.getLbServer().setConnectionTimeout(30000);
-          commondCloudSolrServer.setParallelUpdates(random().nextBoolean());
-          commondCloudSolrServer.setDefaultCollection(DEFAULT_COLLECTION);
-          commondCloudSolrServer.connect();
-        } catch (MalformedURLException e) {
-          throw new RuntimeException(e);
-        }
+        commondCloudSolrServer = new CloudSolrServer(zkServer.getZkAddress(),
+            random().nextBoolean());
+        commondCloudSolrServer.getLbServer().setConnectionTimeout(30000);
+        commondCloudSolrServer.setParallelUpdates(random().nextBoolean());
+        commondCloudSolrServer.setDefaultCollection(DEFAULT_COLLECTION);
+        commondCloudSolrServer.connect();
       }
     }
     return commondCloudSolrServer;



Mime
View raw message