use of org.apache.hadoop.hbase.master.RegionPlan in project hbase by apache.
the class TestReportRegionStateTransitionFromDeadServer method test.
@Test
public void test() throws HBaseIOException, InterruptedException, ExecutionException {
RegionInfo region = UTIL.getMiniHBaseCluster().getRegions(NAME).get(0).getRegionInfo();
AssignmentManager am = UTIL.getMiniHBaseCluster().getMaster().getAssignmentManager();
RegionStateNode rsn = am.getRegionStates().getRegionStateNode(region);
// move from rs0 to rs1, and then kill rs0. Later add rs1 to exclude servers, and at last verify
// that the region should not be on rs1 and rs2 both.
HRegionServer rs0 = UTIL.getMiniHBaseCluster().getRegionServer(rsn.getRegionLocation());
HRegionServer rs1 = UTIL.getOtherRegionServer(rs0);
HRegionServer rs2 = UTIL.getMiniHBaseCluster().getRegionServerThreads().stream().map(t -> t.getRegionServer()).filter(rs -> rs != rs0 && rs != rs1).findAny().get();
RESUME_REPORT = new CountDownLatch(1);
ARRIVE_REPORT = new CountDownLatch(1);
Future<?> future = am.moveAsync(new RegionPlan(region, rs0.getServerName(), rs1.getServerName()));
ARRIVE_REPORT.await();
RESUME_GET_REGIONS = new CountDownLatch(1);
ARRIVE_GET_REGIONS = new CountDownLatch(1);
rs0.abort("For testing!");
ARRIVE_GET_REGIONS.await();
RESUME_REPORT.countDown();
try {
future.get(15, TimeUnit.SECONDS);
} catch (TimeoutException e) {
// after the fix in HBASE-21508 we will get this exception as the TRSP can not be finished any
// more before SCP interrupts it. It's OK.
}
EXCLUDE_SERVERS.add(rs1.getServerName());
RESUME_GET_REGIONS.countDown();
// wait until there are no running procedures, no SCP and no TRSP
UTIL.waitFor(30000, () -> UTIL.getMiniHBaseCluster().getMaster().getMasterProcedureExecutor().getActiveProcIds().isEmpty());
boolean onRS1 = !rs1.getRegions(NAME).isEmpty();
boolean onRS2 = !rs2.getRegions(NAME).isEmpty();
assertNotEquals("should either be on rs1 or rs2, but onRS1 is " + onRS1 + " and on RS2 is " + onRS2, onRS1, onRS2);
}
use of org.apache.hadoop.hbase.master.RegionPlan in project hbase by apache.
the class TestWakeUpUnexpectedProcedure method test.
@Test
public void test() throws Exception {
RegionInfo region = UTIL.getMiniHBaseCluster().getRegions(NAME).get(0).getRegionInfo();
AssignmentManager am = UTIL.getMiniHBaseCluster().getMaster().getAssignmentManager();
RegionStateNode rsn = am.getRegionStates().getRegionStateNode(region);
ServerName sn = rsn.getRegionLocation();
RESUME_EXEC_PROC = new CountDownLatch(1);
ARRIVE_EXEC_PROC = new CountDownLatch(1);
RESUME_IS_SERVER_ONLINE = new CountDownLatch(1);
// reopen the region, and halt the executeProcedures method at RS side
am.moveAsync(new RegionPlan(region, sn, sn));
ARRIVE_EXEC_PROC.await();
RESUME_REPORT = new CountDownLatch(1);
ARRIVE_REPORT = new CountDownLatch(1);
// kill the region server
ServerName serverToKill = SERVER_TO_KILL;
UTIL.getMiniHBaseCluster().stopRegionServer(serverToKill);
RESUME_EXEC_PROC.countDown();
// wait until we are going to open the region on a new rs
ARRIVE_REPORT.await();
// resume the isServerOnline check, to let the rs procedure
RESUME_IS_SERVER_ONLINE.countDown();
// assigned to two regionservers.
for (int i = 0; i < 15; i++) {
if (rsn.getState() == RegionState.State.OPEN) {
break;
}
Thread.sleep(1000);
}
// resume the old report
RESUME_REPORT.countDown();
// wait a bit to let the region to be online, it is not easy to write a condition for this so
// just sleep a while.
Thread.sleep(10000);
// confirm that the region is only on one rs
int count = 0;
for (RegionServerThread t : UTIL.getMiniHBaseCluster().getRegionServerThreads()) {
if (!t.getRegionServer().getRegions(NAME).isEmpty()) {
LOG.info("{} is on {}", region, t.getRegionServer().getServerName());
count++;
}
}
assertEquals(1, count);
}
use of org.apache.hadoop.hbase.master.RegionPlan in project hbase by apache.
the class RSGroupableBalancerTestBase method reconcile.
protected ArrayListMultimap<String, ServerAndLoad> reconcile(ArrayListMultimap<String, ServerAndLoad> previousLoad, List<RegionPlan> plans) {
ArrayListMultimap<String, ServerAndLoad> result = ArrayListMultimap.create();
result.putAll(previousLoad);
if (plans != null) {
for (RegionPlan plan : plans) {
ServerName source = plan.getSource();
updateLoad(result, source, -1);
ServerName destination = plan.getDestination();
updateLoad(result, destination, +1);
}
}
return result;
}
Aggregations