hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject svn commit: r1143524 - in /hbase/branches/0.90: CHANGES.txt src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
Date Wed, 06 Jul 2011 18:37:50 GMT
Author: tedyu
Date: Wed Jul  6 18:37:50 2011
New Revision: 1143524

URL: http://svn.apache.org/viewvc?rev=1143524&view=rev
Log:
HBASE-3904  HBA.createTable(final HTableDescriptor desc, byte [][] splitKeys)
               should be synchronous


Modified:
    hbase/branches/0.90/CHANGES.txt
    hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java

Modified: hbase/branches/0.90/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/CHANGES.txt?rev=1143524&r1=1143523&r2=1143524&view=diff
==============================================================================
--- hbase/branches/0.90/CHANGES.txt (original)
+++ hbase/branches/0.90/CHANGES.txt Wed Jul  6 18:37:50 2011
@@ -54,6 +54,8 @@ Release 0.90.4 - Unreleased
    HBASE-4045  [replication] NPE in ReplicationSource when ZK is gone
    HBASE-4059  If a region is split during RS shutdown process, the daughter
                regions are NOT made online by master
+   HBASE-3904  HBA.createTable(final HTableDescriptor desc, byte [][] splitKeys)
+               should be synchronous
 
   IMPROVEMENT
    HBASE-3882  hbase-config.sh needs to be updated so it can auto-detects the

Modified: hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java?rev=1143524&r1=1143523&r2=1143524&view=diff
==============================================================================
--- hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java (original)
+++ hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java Wed Jul
 6 18:37:50 2011
@@ -20,8 +20,10 @@
 package org.apache.hadoop.hbase.client;
 
 import java.io.IOException;
+import java.net.SocketTimeoutException;
 import java.util.Arrays;
 import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -44,10 +46,12 @@ import org.apache.hadoop.hbase.UnknownRe
 import org.apache.hadoop.hbase.ZooKeeperConnectionException;
 import org.apache.hadoop.hbase.catalog.CatalogTracker;
 import org.apache.hadoop.hbase.catalog.MetaReader;
+import org.apache.hadoop.hbase.client.MetaScanner.MetaScannerVisitor;
 import org.apache.hadoop.hbase.ipc.HMasterInterface;
 import org.apache.hadoop.hbase.ipc.HRegionInterface;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.Pair;
+import org.apache.hadoop.hbase.util.Writables;
 import org.apache.hadoop.ipc.RemoteException;
 import org.apache.hadoop.util.StringUtils;
 
@@ -282,16 +286,47 @@ public class HBaseAdmin implements Abort
    * and attempt-at-creation).
    * @throws IOException
    */
-  public void createTable(HTableDescriptor desc, byte [][] splitKeys)
+  public void createTable(final HTableDescriptor desc, byte [][] splitKeys)
   throws IOException {
     HTableDescriptor.isLegalTableName(desc.getName());
-    createTableAsync(desc, splitKeys);
+    try {
+      createTableAsync(desc, splitKeys);
+    } catch (SocketTimeoutException ste) {
+      LOG.warn("Creating " + desc.getNameAsString() + " took too long", ste);
+    }
+    int numRegs = splitKeys == null ? 1 : splitKeys.length+1;
     for (int tries = 0; tries < numRetries; tries++) {
       try {
         // Wait for new table to come on-line
-        connection.locateRegion(desc.getName(), HConstants.EMPTY_START_ROW);
-        break;
+        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;
+          }
+
+        };
+        MetaScanner.metaScan(conf, visitor, desc.getName());
+        if (actualRegCount.get() == numRegs)
+          break;
       } catch (RegionException e) {
         if (tries == numRetries - 1) {
           // Ran out of tries



Mime
View raw message