You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2011/12/08 23:14:04 UTC

svn commit: r1212165 - /hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java

Author: stack
Date: Thu Dec  8 22:14:04 2011
New Revision: 1212165

URL: http://svn.apache.org/viewvc?rev=1212165&view=rev
Log:
HBASE-4973 On failure, HBaseAdmin sleeps one time too many

Modified:
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java?rev=1212165&r1=1212164&r2=1212165&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java Thu Dec  8 22:14:04 2011
@@ -100,11 +100,14 @@ public class HBaseAdmin implements Abort
     this.numRetries = this.conf.getInt("hbase.client.retries.number", 10);
     this.retryLongerMultiplier = this.conf.getInt(
         "hbase.client.retries.longer.multiplier", 10);
+
     int tries = 0;
-    for (; tries < numRetries; ++tries) {
+    while ( true ){
       try {
+
         this.connection.getMaster();
-        break;
+        return;
+
       } catch (MasterNotRunningException mnre) {
         HConnectionManager.deleteStaleConnection(this.connection);
         this.connection = HConnectionManager.getConnection(this.conf);
@@ -112,20 +115,24 @@ public class HBaseAdmin implements Abort
         HConnectionManager.deleteStaleConnection(this.connection);
         this.connection = HConnectionManager.getConnection(this.conf);
       }
-      try { // Sleep
+
+      tries++;
+      if (tries >= numRetries) {
+        // we should delete connection between client and zookeeper
+        HConnectionManager.deleteStaleConnection(this.connection);
+        throw new MasterNotRunningException("Retried " + numRetries + " times");
+      }
+
+      try {
         Thread.sleep(getPauseTime(tries));
       } catch (InterruptedException e) {
         Thread.currentThread().interrupt();
         // we should delete connection between client and zookeeper
         HConnectionManager.deleteStaleConnection(this.connection);
-        throw new MasterNotRunningException("Interrupted");
+        throw new MasterNotRunningException(
+          "Interrupted after "+tries+" tries");
       }
     }
-    if (tries >= numRetries) {
-      // we should delete connection between client and zookeeper
-      HConnectionManager.deleteStaleConnection(this.connection);
-      throw new MasterNotRunningException("Retried " + numRetries + " times");
-    }
   }
 
   /**