lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From markrmil...@apache.org
Subject svn commit: r1294347 - /lucene/dev/trunk/solr/core/src/java/org/apache/solr/cloud/ZkController.java
Date Mon, 27 Feb 2012 21:43:50 GMT
Author: markrmiller
Date: Mon Feb 27 21:43:50 2012
New Revision: 1294347

URL: http://svn.apache.org/viewvc?rev=1294347&view=rev
Log:
we need to retry when asking for a leader

Modified:
    lucene/dev/trunk/solr/core/src/java/org/apache/solr/cloud/ZkController.java

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/cloud/ZkController.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/cloud/ZkController.java?rev=1294347&r1=1294346&r2=1294347&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/cloud/ZkController.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/cloud/ZkController.java Mon Feb 27
21:43:50 2012
@@ -200,9 +200,13 @@ public final class ZkController {
                 for (CoreDescriptor descriptor : descriptors) {
                   final String coreZkNodeName = getNodeName() + "_"
                       + descriptor.getName();
-                  publishAsDown(getBaseUrl(), descriptor, coreZkNodeName,
-                      descriptor.getName());
-                  waitForLeaderToSeeDownState(descriptor, coreZkNodeName);
+                  try {
+                    publishAsDown(getBaseUrl(), descriptor, coreZkNodeName,
+                        descriptor.getName());
+                    waitForLeaderToSeeDownState(descriptor, coreZkNodeName);
+                  } catch (Exception e) {
+                    SolrException.log(log, "", e);
+                  }
                 }
               }
               
@@ -1084,16 +1088,25 @@ public final class ZkController {
     CloudDescriptor cloudDesc = descriptor.getCloudDescriptor();
     String collection = cloudDesc.getCollectionName();
     String shard = cloudDesc.getShardId();
-    ZkCoreNodeProps leaderProps;
-    try {
-      // go straight to zk, not the cloud state - we must have current info
-      leaderProps = getLeaderProps(collection, shard);
-    } catch (InterruptedException e) {
-      // Restore the interrupted status
-      Thread.currentThread().interrupt();
-      throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR, "", e);
-    } catch (KeeperException e) {
-      throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR, "", e);
+    ZkCoreNodeProps leaderProps = null;
+    
+    int retries = 6;
+    for (int i = 0; i < retries; i++) {
+      try {
+        // go straight to zk, not the cloud state - we must have current info
+        leaderProps = getLeaderProps(collection, shard);
+        break;
+      } catch (Exception e) {
+        SolrException.log(log, "There was a problem finding the leader in zk", e);
+        try {
+          Thread.sleep(2000);
+        } catch (InterruptedException e1) {
+          Thread.currentThread().interrupt();
+        }
+        if (i == retries - 1) {
+          throw new SolrException(ErrorCode.SERVER_ERROR, "There was a problem finding the
leader in zk");
+        }
+      }
     }
     
     String leaderBaseUrl = leaderProps.getBaseUrl();
@@ -1122,7 +1135,8 @@ public final class ZkController {
       
       // let's retry a couple times - perhaps the leader just went down,
       // or perhaps he is just not quite ready for us yet
-      for (int i = 0; i < 3; i++) {
+      retries = 6;
+      for (int i = 0; i < retries; i++) {
         try {
           server.request(prepCmd);
           break;
@@ -1133,6 +1147,9 @@ public final class ZkController {
           } catch (InterruptedException e1) {
             Thread.currentThread().interrupt();
           }
+          if (i == retries - 1) {
+            throw new SolrException(ErrorCode.SERVER_ERROR, "There was a problem making a
request to the leader");
+          }
         }
       }
       



Mime
View raw message