hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jxi...@apache.org
Subject svn commit: r1421455 - /hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/TestDrainingServer.java
Date Thu, 13 Dec 2012 19:54:29 GMT
Author: jxiang
Date: Thu Dec 13 19:54:28 2012
New Revision: 1421455

URL: http://svn.apache.org/viewvc?rev=1421455&view=rev
Log:
HBASE-7343 Fix flaky condition for TestDrainingServer (Himanshu)

Modified:
    hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/TestDrainingServer.java

Modified: hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/TestDrainingServer.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/TestDrainingServer.java?rev=1421455&r1=1421454&r2=1421455&view=diff
==============================================================================
--- hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/TestDrainingServer.java (original)
+++ hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/TestDrainingServer.java Thu
Dec 13 19:54:28 2012
@@ -54,13 +54,14 @@ public class TestDrainingServer {
   private static final byte [] TABLENAME = Bytes.toBytes("t");
   private static final byte [] FAMILY = Bytes.toBytes("f");
   private static final int COUNT_OF_REGIONS = HBaseTestingUtility.KEYS.length;
+  private static final int NB_SLAVES = 5;
 
   /**
    * Spin up a cluster with a bunch of regions on it.
    */
   @BeforeClass
   public static void setUpBeforeClass() throws Exception {
-    TEST_UTIL.startMiniCluster(5);
+    TEST_UTIL.startMiniCluster(NB_SLAVES);
     TEST_UTIL.getConfiguration().setBoolean("hbase.master.enabletable.roundrobin", true);
     ZooKeeperWatcher zkw = HBaseTestingUtility.getZooKeeperWatcher(TEST_UTIL);
     HTableDescriptor htd = new HTableDescriptor(TABLENAME);
@@ -73,14 +74,25 @@ public class TestDrainingServer {
       createTableDescriptor(fs, FSUtils.getRootDir(TEST_UTIL.getConfiguration()), htd);
     // Assign out the regions we just created.
     HBaseAdmin admin = new HBaseAdmin(TEST_UTIL.getConfiguration());
+    MiniHBaseCluster cluster = TEST_UTIL.getMiniHBaseCluster();
     admin.disableTable(TABLENAME);
     admin.enableTable(TABLENAME);
-    ZKAssign.blockUntilNoRIT(zkw);
-    // Assert that every regionserver has some regions on it.
-    MiniHBaseCluster cluster = TEST_UTIL.getMiniHBaseCluster();
-    for (int i = 0; i < cluster.getRegionServerThreads().size(); i++) {
-      HRegionServer hrs = cluster.getRegionServer(i);
-      Assert.assertFalse(hrs.getOnlineRegions().isEmpty());
+    boolean ready = false;
+    while (!ready) {
+      ZKAssign.blockUntilNoRIT(zkw);
+      // Assert that every regionserver has some regions on it, else invoke the balancer.
+      ready = true;
+      for (int i = 0; i < NB_SLAVES; i++) {
+        HRegionServer hrs = cluster.getRegionServer(i);
+        if (hrs.getOnlineRegions().isEmpty()) {
+          ready = false;
+          break;
+        }
+      }
+      if (!ready) {
+        admin.balancer();
+        Thread.sleep(100);
+      }
     }
   }
 



Mime
View raw message