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_r304208133
 
 

 ##########
 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:
   I removed checking of equality of source group and target group in the 
methods moveTables(), moveServers(), and moveServersAndTables() to make them 
idempotent. These three cases are testing the three methods. In each case, I 
call the method twice. The first time, the call fails because I make a region 
in SPLITTING state, and it will not be moved. And I check if all the regions 
except the changed region are on target group servers. The second time, I 
recover the region state to OPEN to check if all regions on target group 
servers after calling the movement method.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to