hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject svn commit: r1145906 - /hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
Date Wed, 13 Jul 2011 08:47:41 GMT
Author: tedyu
Date: Wed Jul 13 08:47:41 2011
New Revision: 1145906

URL: http://svn.apache.org/viewvc?rev=1145906&view=rev
Log:
HBASE-3904 Revert patch v6 from TRUNK

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=1145906&r1=1145905&r2=1145906&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 Wed Jul 13 08:47:41
2011
@@ -21,7 +21,6 @@ package org.apache.hadoop.hbase.client;
 
 import java.io.Closeable;
 import java.io.IOException;
-import java.io.InterruptedIOException;
 import java.net.SocketTimeoutException;
 import java.util.Arrays;
 import java.util.LinkedList;
@@ -334,52 +333,49 @@ public class HBaseAdmin implements Abort
     } catch (SocketTimeoutException ste) {
       LOG.warn("Creating " + desc.getNameAsString() + " took too long", ste);
     }
-    int numRegs = splitKeys == null ? 1 : splitKeys.length + 1;
-    int prevRegCount = 0;
-    for (int tries = 0; tries < numRetries; ++tries) {
-      // Wait for new table to come on-line
-      final AtomicInteger actualRegCount = new AtomicInteger(0);
-      MetaScannerVisitor visitor = new MetaScannerVisitor() {
-        @Override
-        public boolean processRow(Result rowResult) throws IOException {
-          HRegionInfo info = Writables.getHRegionInfo(
-              rowResult.getValue(HConstants.CATALOG_FAMILY,
-                  HConstants.REGIONINFO_QUALIFIER));
-          if (!(Bytes.equals(info.getTableName(), desc.getName()))) {
-            return false;
-          }
-          String hostAndPort = null;
-          byte [] value = rowResult.getValue(HConstants.CATALOG_FAMILY,
-              HConstants.SERVER_QUALIFIER);
-          // Make sure that regions are assigned to server
-          if (value != null && value.length > 0) {
-            hostAndPort = Bytes.toString(value);
-          }
-          if (!(info.isOffline() || info.isSplit()) && hostAndPort != null) {
-            actualRegCount.incrementAndGet();
+    int numRegs = splitKeys == null ? 1 : splitKeys.length+1;
+    for (int tries = 0; tries < numRetries; tries++) {
+      try {
+        // Wait for new table to come on-line
+        final AtomicInteger actualRegCount = new AtomicInteger(0);
+
+        MetaScannerVisitor visitor = new MetaScannerVisitor() {
+          public boolean processRow(Result rowResult) throws IOException {
+            HRegionInfo info = Writables.getHRegionInfo(
+                rowResult.getValue(HConstants.CATALOG_FAMILY,
+                    HConstants.REGIONINFO_QUALIFIER));
+
+            if (!(Bytes.equals(info.getTableName(), desc.getName()))) {
+              return false;
+            }
+
+            String hostAndPort = null;
+            byte [] value = rowResult.getValue(HConstants.CATALOG_FAMILY,
+                HConstants.SERVER_QUALIFIER);
+            if (value != null && value.length > 0) {
+              hostAndPort = Bytes.toString(value);
+            }
+
+            if (!(info.isOffline() || info.isSplit()) && hostAndPort != null) {
+              actualRegCount.incrementAndGet();
+            }
+            return true;
           }
-          return true;
-        }
-      };
-      MetaScanner.metaScan(conf, visitor, desc.getName());
-      if (actualRegCount.get() != numRegs) {
+
+        };
+        MetaScanner.metaScan(conf, visitor, desc.getName());
+        if (actualRegCount.get() == numRegs)
+          break;
+      } catch (RegionException e) {
         if (tries == numRetries - 1) {
-          throw new RegionOfflineException("Only " + actualRegCount.get() + 
-              " of " + numRegs + " regions are online; retries exhausted.");
-        }
-        try { // Sleep
-          Thread.sleep(getPauseTime(tries));
-        } catch (InterruptedException e) {
-          throw new InterruptedIOException("Interrupted when opening" +
-              " regions; " + actualRegCount.get() + " of " + numRegs + 
-              " regions processed so far");
-        }
-        if (actualRegCount.get() > prevRegCount) { // Making progress
-          prevRegCount = actualRegCount.get();
-          tries = -1;
+          // Ran out of tries
+          throw e;
         }
-      } else {
-        return;
+      }
+      try {
+        Thread.sleep(getPauseTime(tries));
+      } catch (InterruptedException e) {
+        // Just continue; ignore the interruption.
       }
     }
   }



Mime
View raw message