You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by GitBox <gi...@apache.org> on 2019/08/26 07:08:28 UTC

[GitHub] [hbase] sunhelly commented on a change in pull request #387: HBASE-22642 Make move operations of RSGroup idempotent

sunhelly commented on a change in pull request #387: HBASE-22642 Make move operations of RSGroup idempotent
URL: https://github.com/apache/hbase/pull/387#discussion_r317475974
 
 

 ##########
 File path: hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsAdmin2.java
 ##########
 @@ -652,24 +614,156 @@ public boolean evaluate() throws Exception {
       RSGroupInfo newGroup) throws IOException{
     // get target server to move, which should has more than one regions
     // randomly set a region state to SPLITTING to make move fail
-    Map<ServerName, List<String>> assignMap = getTableServerRegionMap().get(tableName);
-    String rregion = null;
-    ServerName toMoveServer = null;
+    return randomlySetRegionState(newGroup, RegionState.State.SPLITTING,tableName);
+  }
+
+  private Pair<ServerName, RegionStateNode> randomlySetRegionState(RSGroupInfo groupInfo,
+      RegionState.State state, TableName... tableNames) throws IOException {
+    Preconditions.checkArgument(tableNames.length == 1 || tableNames.length == 2,
+        "only support one or two tables");
+    Map<ServerName, List<String>> assignMap = getTableServerRegionMap().get(tableNames[0]);
+    if(tableNames.length == 2) {
+      Map<ServerName, List<String>> assignMap2 = getTableServerRegionMap().get(tableNames[1]);
+      assignMap2.forEach((k ,v) -> {
+        if(!assignMap.containsKey(k)) {
+          assignMap.remove(k);
+        }
+      });
+    }
+    String toCorrectRegionName = null;
+    ServerName srcServer = null;
     for (ServerName server : assignMap.keySet()) {
-      rregion = assignMap.get(server).size() > 1 &&
-          !newGroup.containsServer(server.getAddress()) ? assignMap.get(server).get(0) : null;
-      if (rregion != null) {
-        toMoveServer = server;
+      toCorrectRegionName = assignMap.get(server).size() >= 1 &&
+          !groupInfo.containsServer(server.getAddress()) ? assignMap.get(server).get(0) : null;
+      if (toCorrectRegionName != null) {
+        srcServer = server;
         break;
       }
     }
-    assert toMoveServer != null;
-    RegionInfo ri = TEST_UTIL.getMiniHBaseCluster().getMaster().getAssignmentManager().
-        getRegionInfo(Bytes.toBytesBinary(rregion));
+    assert srcServer != null;
+    RegionInfo toCorrectRegionInfo = TEST_UTIL.getMiniHBaseCluster().getMaster()
+        .getAssignmentManager().getRegionInfo(Bytes.toBytesBinary(toCorrectRegionName));
     RegionStateNode rsn =
         TEST_UTIL.getMiniHBaseCluster().getMaster().getAssignmentManager().getRegionStates()
-            .getRegionStateNode(ri);
-    rsn.setState(RegionState.State.SPLITTING);
-    return new Pair<>(toMoveServer, rsn);
+            .getRegionStateNode(toCorrectRegionInfo);
+    rsn.setState(state);
+    return new Pair<>(srcServer, rsn);
+  }
+
+  @Test
+  public void testFailedMoveTablesAndRepair() throws Exception{
 
 Review comment:
   Yes, I have added some description for these UTs.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services