sunhelly commented on a change in pull request #3001:
URL: https://github.com/apache/hbase/pull/3001#discussion_r595118863



##########
File path: 
hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRegionSplit.java
##########
@@ -146,8 +152,70 @@ public void testSplitTableRegion() throws Exception {
     UTIL.getAdmin().enableTable(tableName);
     Thread.sleep(500);
 
-    assertEquals("Table region not correct.", 2,
-        UTIL.getHBaseCluster().getRegions(tableName).size());
+    List<HRegion> tableRegions = UTIL.getHBaseCluster().getRegions(tableName);
+    assertEquals("Table region not correct.", 2, tableRegions.size());
+    Map<RegionInfo, ServerName> regionInfoMap = 
UTIL.getHBaseCluster().getMaster().getAssignmentManager()
+      .getRegionStates().getRegionAssignments();
+    assertEquals(regionInfoMap.get(tableRegions.get(0).getRegionInfo()),
+      regionInfoMap.get(tableRegions.get(1).getRegionInfo()));
+  }
+
+  @Test
+  public void testSplitTableRegionAndSeparateChildRegions() throws Exception {
+    cleanupTest();
+    //restart master
+    
UTIL.getConfiguration().setBoolean(HConstants.HBASE_ENABLE_SEPARATE_CHILD_REGIONS,
 true);
+    setupCluster();
+
+    final TableName tableName = TableName.valueOf(name.getMethodName());
+    final ProcedureExecutor<MasterProcedureEnv> procExec = 
getMasterProcedureExecutor();
+
+    RegionInfo[] regions =
+      MasterProcedureTestingUtility.createTable(procExec, tableName, null, 
ColumnFamilyName);
+    insertData(tableName);
+    int splitRowNum = startRowNum + rowCount / 2;
+    byte[] splitKey = Bytes.toBytes("" + splitRowNum);
+
+    assertTrue("not able to find a splittable region", regions != null);
+    assertTrue("not able to find a splittable region", regions.length == 1);
+
+    // Split region of the table
+    long procId = procExec.submitProcedure(
+      new SplitTableRegionProcedure(procExec.getEnvironment(), regions[0], 
splitKey));
+    // Wait the completion
+    ProcedureTestingUtility.waitProcedure(procExec, procId);
+    ProcedureTestingUtility.assertProcNotFailed(procExec, procId);
+
+    assertTrue("not able to split table", 
UTIL.getHBaseCluster().getRegions(tableName).size() == 2);
+
+    //disable table
+    UTIL.getAdmin().disableTable(tableName);
+    Thread.sleep(500);
+
+    //stop master
+    UTIL.getHBaseCluster().stopMaster(0);
+    UTIL.getHBaseCluster().waitOnMaster(0);
+    Thread.sleep(500);
+
+    //restart master
+    JVMClusterUtil.MasterThread t = UTIL.getHBaseCluster().startMaster();
+    Thread.sleep(500);
+
+    UTIL.invalidateConnection();
+    // enable table
+    UTIL.getAdmin().enableTable(tableName);
+    Thread.sleep(500);
+
+    List<HRegion> tableRegions = UTIL.getHBaseCluster().getRegions(tableName);
+    assertEquals("Table region not correct.", 2, tableRegions.size());
+    Map<RegionInfo, ServerName> regionInfoMap = 
UTIL.getHBaseCluster().getMaster().getAssignmentManager()
+      .getRegionStates().getRegionAssignments();
+    assertNotEquals(regionInfoMap.get(tableRegions.get(0).getRegionInfo()),

Review comment:
       Because the test cluster has three region servers, and before the round 
robin assignment, one daughter will be kept on the parent server, which will be 
excluded from the round robin servers set. At last, the other daughter and its 
replicas will be assigned to the other two servers. More than one servers in 
the destination server set will make round robin work well.




----------------------------------------------------------------
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]


Reply via email to