hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zhang...@apache.org
Subject hbase git commit: HBASE-20160 TestRestartCluster.testRetainAssignmentOnRestart uses the wrong condition to decide whether the assignment is finished
Date Fri, 09 Mar 2018 03:28:33 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-2.0 28ebac556 -> 58d840199


HBASE-20160 TestRestartCluster.testRetainAssignmentOnRestart uses the wrong condition to decide
whether the assignment is finished


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/58d84019
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/58d84019
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/58d84019

Branch: refs/heads/branch-2.0
Commit: 58d8401995df2b81bc1557cef270546cf174da7b
Parents: 28ebac5
Author: zhangduo <zhangduo@apache.org>
Authored: Thu Mar 8 18:03:04 2018 +0800
Committer: zhangduo <zhangduo@apache.org>
Committed: Fri Mar 9 11:09:01 2018 +0800

----------------------------------------------------------------------
 .../hadoop/hbase/master/TestRestartCluster.java | 32 +++++++++-----------
 1 file changed, 14 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/58d84019/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRestartCluster.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRestartCluster.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRestartCluster.java
index 56976b3..088dff5 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRestartCluster.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRestartCluster.java
@@ -32,7 +32,6 @@ import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.TableExistsException;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.client.RegionInfo;
-import org.apache.hadoop.hbase.master.assignment.RegionStates;
 import org.apache.hadoop.hbase.testclassification.LargeTests;
 import org.apache.hadoop.hbase.testclassification.MasterTests;
 import org.apache.hadoop.hbase.util.Bytes;
@@ -45,7 +44,7 @@ import org.junit.experimental.categories.Category;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-@Category({MasterTests.class, LargeTests.class})
+@Category({ MasterTests.class, LargeTests.class })
 public class TestRestartCluster {
 
   @ClassRule
@@ -60,7 +59,7 @@ public class TestRestartCluster {
       TableName.valueOf("restartTableTwo"),
       TableName.valueOf("restartTableThree")
   };
-  private static final byte [] FAMILY = Bytes.toBytes("family");
+  private static final byte[] FAMILY = Bytes.toBytes("family");
 
   @After public void tearDown() throws Exception {
     UTIL.shutdownMiniCluster();
@@ -115,17 +114,13 @@ public class TestRestartCluster {
   @Test
   public void testRetainAssignmentOnRestart() throws Exception {
     UTIL.startMiniCluster(2);
-    while (!UTIL.getMiniHBaseCluster().getMaster().isInitialized()) {
-      Threads.sleep(1);
-    }
     // Turn off balancer
-    UTIL.getMiniHBaseCluster().getMaster().
-      getMasterRpcServices().synchronousBalanceSwitch(false);
+    UTIL.getMiniHBaseCluster().getMaster().getMasterRpcServices().synchronousBalanceSwitch(false);
     LOG.info("\n\nCreating tables");
-    for(TableName TABLE : TABLES) {
+    for (TableName TABLE : TABLES) {
       UTIL.createTable(TABLE, FAMILY);
     }
-    for(TableName TABLE : TABLES) {
+    for (TableName TABLE : TABLES) {
       UTIL.waitTableEnabled(TABLE);
     }
 
@@ -157,6 +152,7 @@ public class TestRestartCluster {
     }
 
     LOG.info("\n\nShutting down HBase cluster");
+    cluster.stopMaster(0);
     cluster.shutdown();
     cluster.waitUntilShutDown();
 
@@ -194,11 +190,8 @@ public class TestRestartCluster {
     }
 
     // Wait till master is initialized and all regions are assigned
-    RegionStates regionStates = master.getAssignmentManager().getRegionStates();
-    int expectedRegions = regionToRegionServerMap.size() + 1;
-    while (!master.isInitialized()
-        || regionStates.getRegionAssignments().size() != expectedRegions) {
-      Threads.sleep(100);
+    for (TableName TABLE : TABLES) {
+      UTIL.waitTableAvailable(TABLE);
     }
 
     snapshot = new SnapshotOfRegionAssignmentFromMeta(master.getConnection());
@@ -206,11 +199,14 @@ public class TestRestartCluster {
     Map<RegionInfo, ServerName> newRegionToRegionServerMap =
       snapshot.getRegionToRegionServerMap();
     assertEquals(regionToRegionServerMap.size(), newRegionToRegionServerMap.size());
-    for (Map.Entry<RegionInfo, ServerName> entry: newRegionToRegionServerMap.entrySet())
{
-      if (TableName.NAMESPACE_TABLE_NAME.equals(entry.getKey().getTable())) continue;
+    for (Map.Entry<RegionInfo, ServerName> entry : newRegionToRegionServerMap.entrySet())
{
+      if (TableName.NAMESPACE_TABLE_NAME.equals(entry.getKey().getTable())) {
+        continue;
+      }
       ServerName oldServer = regionToRegionServerMap.get(entry.getKey());
       ServerName currentServer = entry.getValue();
-      LOG.info("Key=" + entry.getKey() + " oldServer=" + oldServer + ", currentServer=" +
currentServer);
+      LOG.info(
+        "Key=" + entry.getKey() + " oldServer=" + oldServer + ", currentServer=" + currentServer);
       assertEquals(entry.getKey().toString(), oldServer.getAddress(), currentServer.getAddress());
       assertNotEquals(oldServer.getStartcode(), currentServer.getStartcode());
     }


Mime
View raw message