sreenivasulureddy commented on a change in pull request #307: HBase 22537
URL: https://github.com/apache/hbase/pull/307#discussion_r295154396
##########
File path:
hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncNonMetaRegionLocator.java
##########
@@ -390,6 +404,98 @@ public RegionLocations getRegionLocations(TableName
tableName, int replicaId, bo
});
}
+ @Test
+ public void testRegionReplicaRitRecovery() throws Exception {
+ int startRowNum = 11;
+ int rowCount = 60;
+
+ final TableName tableName = TableName.valueOf(name.getMethodName());
+ final ProcedureExecutor<MasterProcedureEnv> procExec =
getMasterProcedureExecutor();
+ TEST_UTIL.getAdmin().createTable(
+ TableDescriptorBuilder.newBuilder(tableName)
+
.setColumnFamily(ColumnFamilyDescriptorBuilder.of(FAMILY)).setRegionReplication(2)
+ .build());
+ TEST_UTIL.waitUntilAllRegionsAssigned(tableName);
+ RegionLocations locs = new Locator() {
+
+ @Override
+ public void updateCachedLocationOnError(HRegionLocation loc, Throwable
error)
+ throws Exception {
+ LOCATOR.updateCachedLocationOnError(loc, error);
+ }
+
+ @Override
+ public RegionLocations getRegionLocations(TableName tableName, int
replicaId, boolean reload)
+ throws Exception {
+ return LOCATOR.getRegionLocations(tableName, EMPTY_START_ROW,
replicaId,
+ RegionLocateType.CURRENT, reload).get();
+ }
+ }.getRegionLocations(tableName, 0, false);
+ ServerName serverName =
+ RegionReplicaTestHelper.getRSCarryingReplica(TEST_UTIL, tableName,
1).get();
+ List<RegionInfo> regions = TEST_UTIL.getAdmin().getRegions(tableName);
+ insertData(tableName);
+ int splitRowNum = startRowNum + rowCount / 2;
+ byte[] splitKey = Bytes.toBytes("" + splitRowNum);
+
+ // Split region of the table
+ long procId =
+ procExec.submitProcedure(new
SplitTableRegionProcedure(procExec.getEnvironment(), regions
+ .get(0), splitKey));
+ // Wait the completion
+ ProcedureTestingUtility.waitProcedure(procExec, procId);
+
+ // Disable the table
+ long procId1 =
+ procExec.submitProcedure(new
DisableTableProcedure(procExec.getEnvironment(), tableName,
+ false));
+ // Wait the completion
+ ProcedureTestingUtility.waitProcedure(procExec, procId1);
+
+ long procId2 =
+ procExec.submitProcedure(new
DeleteTableProcedure(procExec.getEnvironment(), tableName));
+ // Wait the completion
+ ProcedureTestingUtility.waitProcedure(procExec, procId2);
+
+ AssignmentTestingUtil.killRs(TEST_UTIL, serverName);
+ long procId3 = getSCPProcId(procExec);
+ Threads.sleepWithoutInterrupt(5000);
+
+ boolean hasRegionsInTransition =
+
TEST_UTIL.getMiniHBaseCluster().getMaster().getAssignmentManager().getRegionStates()
+ .hasRegionsInTransition();
+
+ assertEquals(false, hasRegionsInTransition);
+
+ }
+
+ private ProcedureExecutor<MasterProcedureEnv> getMasterProcedureExecutor() {
+ return
TEST_UTIL.getHBaseCluster().getMaster().getMasterProcedureExecutor();
+ }
+
+ private long getSCPProcId(ProcedureExecutor<?> procExec) {
+ TEST_UTIL.waitFor(35000, () -> !procExec.getProcedures().isEmpty());
+ return
procExec.getActiveProcIds().stream().mapToLong(Long::longValue).min().getAsLong();
+ }
+
+ private void insertData(final TableName tableName) throws IOException,
InterruptedException {
Review comment:
I just reused the logic done in TestSplitTableRegionProcedure.
please provide if you have any suggestions for this.
----------------------------------------------------------------
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