hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apurt...@apache.org
Subject svn commit: r1463070 - in /hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase: ./ client/ coprocessor/ master/ regionserver/wal/ util/
Date Mon, 01 Apr 2013 00:57:15 GMT
Author: apurtell
Date: Mon Apr  1 00:57:14 2013
New Revision: 1463070

URL: http://svn.apache.org/r1463070
Log:
HBASE-8226. HBaseTestingUtility#waitUntilAllRegionsAssigned won't return if it counts 'too
many' regions

Modified:
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHTableMultiplexer.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestCoprocessorEndpoint.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionServerCoprocessorExceptionWithAbort.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionServerCoprocessorExceptionWithRemove.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterTransitions.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestHLogFiltering.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestMiniClusterLoadSequential.java

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java?rev=1463070&r1=1463069&r2=1463070&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
(original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
Mon Apr  1 00:57:14 2013
@@ -2159,37 +2159,56 @@ public class HBaseTestingUtility extends
     }
   }
 
+  /**
+   * Wait until all regions for a table in .META. have a non-empty
+   * info:server, up to 60 seconds. This means all regions have been deployed,
+   * master has been informed and updated .META. with the regions deployed
+   * server.
+   * @param tableName the table name
+   * @throws IOException
+   */
+  public void waitUntilAllRegionsAssigned(final byte[] tableName) throws IOException {
+    waitUntilAllRegionsAssigned(tableName, 60000);
+  }
 
   /**
-   * Wait until <code>countOfRegion</code> in .META. have a non-empty
-   * info:server.  This means all regions have been deployed, master has been
-   * informed and updated .META. with the regions deployed server.
-   * @param countOfRegions How many regions in .META.
+   * Wait until all regions for a table in .META. have a non-empty
+   * info:server, or until timeout.  This means all regions have been deployed,
+   * master has been informed and updated .META. with the regions deployed
+   * server.
+   * @param tableName the table name
+   * @param timeout timeout, in milliseconds
    * @throws IOException
    */
-  public void waitUntilAllRegionsAssigned(final int countOfRegions)
-  throws IOException {
-    HTable meta = new HTable(getConfiguration(), HConstants.META_TABLE_NAME);
-    while (true) {
-      int rows = 0;
-      Scan scan = new Scan();
-      scan.addColumn(HConstants.CATALOG_FAMILY, HConstants.SERVER_QUALIFIER);
-      ResultScanner s = meta.getScanner(scan);
-      for (Result r = null; (r = s.next()) != null;) {
-        byte [] b =
-          r.getValue(HConstants.CATALOG_FAMILY, HConstants.SERVER_QUALIFIER);
-        if (b == null || b.length <= 0) {
-          break;
+  public void waitUntilAllRegionsAssigned(final byte[] tableName, final long timeout)
+      throws IOException {
+    final HTable meta = new HTable(getConfiguration(), HConstants.META_TABLE_NAME);
+    try {
+      waitFor(timeout, 200, true, new Predicate<IOException>() {
+        @Override
+        public boolean evaluate() throws IOException {
+          boolean allRegionsAssigned = true;
+          Scan scan = new Scan();
+          scan.addFamily(HConstants.CATALOG_FAMILY);
+          ResultScanner s = meta.getScanner(scan);
+          try {
+            Result r;
+            while ((r = s.next()) != null) {
+              byte [] b = r.getValue(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER);
+              HRegionInfo info = HRegionInfo.parseFromOrNull(b);
+              if (info != null && Bytes.equals(info.getTableName(), tableName)) {
+                b = r.getValue(HConstants.CATALOG_FAMILY, HConstants.SERVER_QUALIFIER);
+                allRegionsAssigned &= (b != null);
+              }
+            }
+          } finally {
+            s.close();
+          }
+          return allRegionsAssigned;
         }
-        rows++;
-      }
-      s.close();
-      // If I get to here and all rows have a Server, then all have been assigned.
-      if (rows == countOfRegions) {
-        break;
-      }
-      LOG.info("Found=" + rows);
-      Threads.sleep(200);
+      });
+    } finally {
+      meta.close();
     }
   }
 

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHTableMultiplexer.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHTableMultiplexer.java?rev=1463070&r1=1463069&r2=1463070&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHTableMultiplexer.java
(original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHTableMultiplexer.java
Mon Apr  1 00:57:14 2013
@@ -77,7 +77,7 @@ public class TestHTableMultiplexer {
 
     HTable ht = TEST_UTIL.createTable(TABLE, new byte[][] { FAMILY }, VERSION,
         Bytes.toBytes("aaaaa"), Bytes.toBytes("zzzzz"), NUM_REGIONS);
-    TEST_UTIL.waitUntilAllRegionsAssigned(NUM_REGIONS);
+    TEST_UTIL.waitUntilAllRegionsAssigned(TABLE);
 
     byte[][] startRows = ht.getStartKeys();
     byte[][] endRows = ht.getEndKeys();

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestCoprocessorEndpoint.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestCoprocessorEndpoint.java?rev=1463070&r1=1463069&r2=1463070&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestCoprocessorEndpoint.java
(original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestCoprocessorEndpoint.java
Mon Apr  1 00:57:14 2013
@@ -91,7 +91,7 @@ public class TestCoprocessorEndpoint {
     HTableDescriptor desc = new HTableDescriptor(TEST_TABLE);
     desc.addFamily(new HColumnDescriptor(TEST_FAMILY));
     admin.createTable(desc, new byte[][]{ROWS[rowSeperator1], ROWS[rowSeperator2]});
-    util.waitUntilAllRegionsAssigned(3);
+    util.waitUntilAllRegionsAssigned(TEST_TABLE);
     admin.close();
 
     HTable table = new HTable(conf, TEST_TABLE);

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java?rev=1463070&r1=1463069&r2=1463070&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java
(original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java
Mon Apr  1 00:57:14 2013
@@ -1109,8 +1109,8 @@ public class TestMasterObserver {
     HTable table = UTIL.createTable(TEST_TABLE, TEST_FAMILY);
 
     try {
-      int countOfRegions = UTIL.createMultiRegions(table, TEST_FAMILY);
-      UTIL.waitUntilAllRegionsAssigned(countOfRegions);
+      UTIL.createMultiRegions(table, TEST_FAMILY);
+      UTIL.waitUntilAllRegionsAssigned(TEST_TABLE);
   
       NavigableMap<HRegionInfo, ServerName> regions = table.getRegionLocations();
       Map.Entry<HRegionInfo, ServerName> firstGoodPair = null;

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionServerCoprocessorExceptionWithAbort.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionServerCoprocessorExceptionWithAbort.java?rev=1463070&r1=1463069&r2=1463070&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionServerCoprocessorExceptionWithAbort.java
(original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionServerCoprocessorExceptionWithAbort.java
Mon Apr  1 00:57:14 2013
@@ -75,7 +75,8 @@ public class TestRegionServerCoprocessor
     byte[] TEST_FAMILY = Bytes.toBytes("aaa");
 
     HTable table = TEST_UTIL.createTable(TEST_TABLE, TEST_FAMILY);
-    TEST_UTIL.waitUntilAllRegionsAssigned(TEST_UTIL.createMultiRegions(table, TEST_FAMILY));
+    TEST_UTIL.createMultiRegions(table, TEST_FAMILY);
+    TEST_UTIL.waitUntilAllRegionsAssigned(TEST_TABLE);
 
     // Note which regionServer will abort (after put is attempted).
     final HRegionServer regionServer = TEST_UTIL.getRSForFirstRegionInTable(TEST_TABLE);

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionServerCoprocessorExceptionWithRemove.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionServerCoprocessorExceptionWithRemove.java?rev=1463070&r1=1463069&r2=1463070&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionServerCoprocessorExceptionWithRemove.java
(original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionServerCoprocessorExceptionWithRemove.java
Mon Apr  1 00:57:14 2013
@@ -91,8 +91,8 @@ public class TestRegionServerCoprocessor
     byte[] TEST_FAMILY = Bytes.toBytes("aaa");
 
     HTable table = TEST_UTIL.createTable(TEST_TABLE, TEST_FAMILY);
-    TEST_UTIL.waitUntilAllRegionsAssigned(
-        TEST_UTIL.createMultiRegions(table, TEST_FAMILY));
+    TEST_UTIL.createMultiRegions(table, TEST_FAMILY);
+    TEST_UTIL.waitUntilAllRegionsAssigned(TEST_TABLE);
     // Note which regionServer that should survive the buggy coprocessor's
     // prePut().
     HRegionServer regionServer =

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterTransitions.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterTransitions.java?rev=1463070&r1=1463069&r2=1463070&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterTransitions.java
(original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterTransitions.java
Mon Apr  1 00:57:14 2013
@@ -60,10 +60,11 @@ public class TestMasterTransitions {
     TEST_UTIL.getConfiguration().setBoolean("dfs.support.append", true);
     TEST_UTIL.startMiniCluster(2);
     // Create a table of three families.  This will assign a region.
-    TEST_UTIL.createTable(Bytes.toBytes(TABLENAME), FAMILIES);
+    byte[] tableName = Bytes.toBytes(TABLENAME);
+    TEST_UTIL.createTable(tableName, FAMILIES);
     HTable t = new HTable(TEST_UTIL.getConfiguration(), TABLENAME);
     int countOfRegions = TEST_UTIL.createMultiRegions(t, getTestFamily());
-    TEST_UTIL.waitUntilAllRegionsAssigned(countOfRegions);
+    TEST_UTIL.waitUntilAllRegionsAssigned(tableName);
     addToEachStartKey(countOfRegions);
     t.close();
   }

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestHLogFiltering.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestHLogFiltering.java?rev=1463070&r1=1463069&r2=1463070&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestHLogFiltering.java
(original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestHLogFiltering.java
Mon Apr  1 00:57:14 2013
@@ -102,7 +102,7 @@ public class TestHLogFiltering {
         table.flushCommits();
       }
     }
-    TEST_UTIL.waitUntilAllRegionsAssigned(NUM_RS);
+    TEST_UTIL.waitUntilAllRegionsAssigned(TABLE_NAME);
   }
 
   @Test

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestMiniClusterLoadSequential.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestMiniClusterLoadSequential.java?rev=1463070&r1=1463069&r2=1463070&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestMiniClusterLoadSequential.java
(original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestMiniClusterLoadSequential.java
Mon Apr  1 00:57:14 2013
@@ -140,8 +140,8 @@ public class TestMiniClusterLoadSequenti
 
   protected void createPreSplitLoadTestTable(HTableDescriptor htd, HColumnDescriptor hcd)
       throws IOException {
-    int numRegions = HBaseTestingUtility.createPreSplitLoadTestTable(conf, htd, hcd);
-    TEST_UTIL.waitUntilAllRegionsAssigned(numRegions);
+    HBaseTestingUtility.createPreSplitLoadTestTable(conf, htd, hcd);
+    TEST_UTIL.waitUntilAllRegionsAssigned(htd.getName());
   }
 
   protected void prepareForLoadTest() throws IOException {



Mime
View raw message