hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmhs...@apache.org
Subject svn commit: r1445824 - /hbase/branches/hbase-7290/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
Date Wed, 13 Feb 2013 18:41:28 GMT
Author: jmhsieh
Date: Wed Feb 13 18:41:28 2013
New Revision: 1445824

URL: http://svn.apache.org/r1445824
Log:
HBASE-7352 clone operation from HBaseAdmin can hang forever (Matteo Bertozzi)


Modified:
    hbase/branches/hbase-7290/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java

Modified: hbase/branches/hbase-7290/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
URL: http://svn.apache.org/viewvc/hbase/branches/hbase-7290/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java?rev=1445824&r1=1445823&r2=1445824&view=diff
==============================================================================
--- hbase/branches/hbase-7290/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
(original)
+++ hbase/branches/hbase-7290/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
Wed Feb 13 18:41:28 2013
@@ -689,7 +689,21 @@ public class HBaseAdmin implements Abort
     enableTableAsync(tableName);
 
     // Wait until all regions are enabled
+    waitUntilTableIsEnabled(tableName);
+
+    LOG.info("Enabled table " + Bytes.toString(tableName));
+  }
+
+  /**
+   * Wait for the table to be enabled.
+   * If enabling the table exceeds the retry period, an exception is thrown.
+   * @param tableName name of the table
+   * @throws IOException if a remote or network exception occurs or
+   *    table is not enabled after the retries period.
+   */
+  private void waitUntilTableIsEnabled(final byte[] tableName) throws IOException {
     boolean enabled = false;
+    long start = EnvironmentEdgeManager.currentTimeMillis();
     for (int tries = 0; tries < (this.numRetries * this.retryLongerMultiplier); tries++)
{
       enabled = isTableEnabled(tableName);
       if (enabled) {
@@ -710,10 +724,10 @@ public class HBaseAdmin implements Abort
       }
     }
     if (!enabled) {
-      throw new IOException("Unable to enable table " +
-        Bytes.toString(tableName));
+      long msec = EnvironmentEdgeManager.currentTimeMillis() - start;
+      throw new IOException("Table '" + Bytes.toString(tableName) +
+        "' not yet enabled, after " + msec + "ms.");
     }
-    LOG.info("Enabled table " + Bytes.toString(tableName));
   }
 
   public void enableTableAsync(final String tableName)
@@ -2409,9 +2423,7 @@ public class HBaseAdmin implements Abort
       throw new TableExistsException("Table '" + tableName + " already exists");
     }
     internalRestoreSnapshot(snapshotName, tableName);
-    for (int tries = 0; !isTableEnabled(tableName); ++tries) {
-      Thread.sleep(this.pause);
-    }
+    waitUntilTableIsEnabled(Bytes.toBytes(tableName));
   }
 
   /**



Mime
View raw message