lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From markrmil...@apache.org
Subject svn commit: r1442771 - /lucene/dev/trunk/solr/core/src/java/org/apache/solr/cloud/ZkController.java
Date Tue, 05 Feb 2013 22:31:57 GMT
Author: markrmiller
Date: Tue Feb  5 22:31:57 2013
New Revision: 1442771

URL: http://svn.apache.org/viewvc?rev=1442771&view=rev
Log:
bail early from retry loop when closed

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=1442771&r1=1442770&r2=1442771&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 Tue Feb  5
22:31:57 2013
@@ -1220,35 +1220,43 @@ public final class ZkController {
     if (!isLeader && !SKIP_AUTO_RECOVERY) {
       HttpSolrServer server = null;
       server = new HttpSolrServer(leaderBaseUrl);
-      server.setConnectionTimeout(15000);
-      server.setSoTimeout(120000);
-      WaitForState prepCmd = new WaitForState();
-      prepCmd.setCoreName(leaderCoreName);
-      prepCmd.setNodeName(getNodeName());
-      prepCmd.setCoreNodeName(coreZkNodeName);
-      prepCmd.setState(ZkStateReader.DOWN);
-      
-      // let's retry a couple times - perhaps the leader just went down,
-      // or perhaps he is just not quite ready for us yet
-      retries = 6;
-      for (int i = 0; i < retries; i++) {
-        try {
-          server.request(prepCmd);
-          break;
-        } catch (Exception e) {
-          SolrException.log(log, "There was a problem making a request to the leader", e);
-          try {
-            Thread.sleep(2000);
-          } catch (InterruptedException e1) {
-            Thread.currentThread().interrupt();
+      try {
+        server.setConnectionTimeout(15000);
+        server.setSoTimeout(120000);
+        WaitForState prepCmd = new WaitForState();
+        prepCmd.setCoreName(leaderCoreName);
+        prepCmd.setNodeName(getNodeName());
+        prepCmd.setCoreNodeName(coreZkNodeName);
+        prepCmd.setState(ZkStateReader.DOWN);
+        
+        // let's retry a couple times - perhaps the leader just went down,
+        // or perhaps he is just not quite ready for us yet
+        retries = 6;
+        for (int i = 0; i < retries; i++) {
+          if (isClosed) {
+            throw new SolrException(ErrorCode.SERVICE_UNAVAILABLE,
+                "We have been closed");
           }
-          if (i == retries - 1) {
-            throw new SolrException(ErrorCode.SERVER_ERROR, "There was a problem making a
request to the leader");
+          try {
+            server.request(prepCmd);
+            break;
+          } catch (Exception e) {
+            SolrException.log(log,
+                "There was a problem making a request to the leader", 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 making a request to the leader");
+            }
           }
         }
+      } finally {
+        server.shutdown();
       }
-      
-      server.shutdown();
     }
     return leaderProps;
   }



Mime
View raw message