use of org.apache.hadoop.hbase.procedure2.ProcedureExecutor in project hbase by apache.
the class TestCatalogJanitorInMemoryStates method testInMemoryParentCleanup.
/**
* Test clearing a split parent from memory.
*/
@Test
public void testInMemoryParentCleanup() throws IOException, InterruptedException, ExecutionException {
HMaster master = TEST_UTIL.getHBaseCluster().getMaster();
final AssignmentManager am = master.getAssignmentManager();
final ServerManager sm = master.getServerManager();
Admin admin = TEST_UTIL.getAdmin();
admin.catalogJanitorSwitch(false);
final TableName tableName = name.getTableName();
Table t = TEST_UTIL.createTable(tableName, FAMILY);
TEST_UTIL.loadTable(t, FAMILY, false);
RegionLocator locator = TEST_UTIL.getConnection().getRegionLocator(tableName);
List<HRegionLocation> allRegionLocations = locator.getAllRegionLocations();
// We need to create a valid split with daughter regions
HRegionLocation parent = allRegionLocations.get(0);
List<HRegionLocation> daughters = splitRegion(parent.getRegion());
LOG.info("Parent region: " + parent);
LOG.info("Daughter regions: " + daughters);
assertNotNull("Should have found daughter regions for " + parent, daughters);
assertTrue("Parent region should exist in RegionStates", am.getRegionStates().isRegionInRegionStates(parent.getRegion()));
assertTrue("Parent region should exist in ServerManager", sm.isRegionInServerManagerStates(parent.getRegion()));
// clean the parent
Result r = MetaMockingUtil.getMetaTableRowResult(parent.getRegion(), null, daughters.get(0).getRegion(), daughters.get(1).getRegion());
CatalogJanitor.cleanParent(master, parent.getRegion(), r);
// wait for procedures to complete
Waiter.waitFor(TEST_UTIL.getConfiguration(), 10 * 1000, new Waiter.Predicate<Exception>() {
@Override
public boolean evaluate() throws Exception {
ProcedureExecutor<MasterProcedureEnv> pe = master.getMasterProcedureExecutor();
for (Procedure<MasterProcedureEnv> proc : pe.getProcedures()) {
if (proc.getClass().isAssignableFrom(GCRegionProcedure.class) && proc.isFinished()) {
return true;
}
}
return false;
}
});
assertFalse("Parent region should have been removed from RegionStates", am.getRegionStates().isRegionInRegionStates(parent.getRegion()));
assertFalse("Parent region should have been removed from ServerManager", sm.isRegionInServerManagerStates(parent.getRegion()));
}
Aggregations