use of org.apache.hadoop.hbase.master.assignment.TransitRegionStateProcedure in project hbase by apache.
the class MasterProcedureTestingUtility method restartMasterProcedureExecutor.
public static void restartMasterProcedureExecutor(ProcedureExecutor<MasterProcedureEnv> procExec) throws Exception {
final MasterProcedureEnv env = procExec.getEnvironment();
final HMaster master = (HMaster) env.getMasterServices();
ProcedureTestingUtility.restart(procExec, true, true, // stop services
new Callable<Void>() {
@Override
public Void call() throws Exception {
AssignmentManager am = env.getAssignmentManager();
// try to simulate a master restart by removing the ServerManager states about seqIDs
for (RegionState regionState : am.getRegionStates().getRegionStates()) {
env.getMasterServices().getServerManager().removeRegion(regionState.getRegion());
}
am.stop();
master.setInitialized(false);
return null;
}
}, // setup RIT before starting workers
new Callable<Void>() {
@Override
public Void call() throws Exception {
AssignmentManager am = env.getAssignmentManager();
am.start();
// just follow the same way with HMaster.finishActiveMasterInitialization. See the
// comments there
am.setupRIT(procExec.getActiveProceduresNoCopy().stream().filter(p -> !p.isSuccess()).filter(p -> p instanceof TransitRegionStateProcedure).map(p -> (TransitRegionStateProcedure) p).collect(Collectors.toList()));
return null;
}
}, // restart services
new Callable<Void>() {
@Override
public Void call() throws Exception {
AssignmentManager am = env.getAssignmentManager();
try {
am.joinCluster();
am.wakeMetaLoadedEvent();
master.setInitialized(true);
} catch (Exception e) {
LOG.warn("Failed to load meta", e);
}
return null;
}
});
}
use of org.apache.hadoop.hbase.master.assignment.TransitRegionStateProcedure in project hbase by apache.
the class TestReopenTableRegionsProcedureBackoff method testRetryBackoff.
@Test
public void testRetryBackoff() throws IOException, InterruptedException {
AssignmentManager am = UTIL.getMiniHBaseCluster().getMaster().getAssignmentManager();
ProcedureExecutor<MasterProcedureEnv> procExec = UTIL.getMiniHBaseCluster().getMaster().getMasterProcedureExecutor();
RegionInfo regionInfo = UTIL.getAdmin().getRegions(TABLE_NAME).get(0);
RegionStateNode regionNode = am.getRegionStates().getRegionStateNode(regionInfo);
// just a dummy one
TransitRegionStateProcedure trsp = TransitRegionStateProcedure.unassign(procExec.getEnvironment(), regionInfo);
long openSeqNum;
regionNode.lock();
try {
openSeqNum = regionNode.getOpenSeqNum();
// make a fake state to let the procedure wait.
regionNode.setState(State.OPENING);
regionNode.setOpenSeqNum(-1L);
regionNode.setProcedure(trsp);
} finally {
regionNode.unlock();
}
ReopenTableRegionsProcedure proc = new ReopenTableRegionsProcedure(TABLE_NAME);
procExec.submitProcedure(proc);
UTIL.waitFor(10000, () -> proc.getState() == ProcedureState.WAITING_TIMEOUT);
long oldTimeout = 0;
int timeoutIncrements = 0;
for (; ; ) {
long timeout = proc.getTimeout();
if (timeout > oldTimeout) {
LOG.info("Timeout incremented, was {}, now is {}, increments={}", timeout, oldTimeout, timeoutIncrements);
oldTimeout = timeout;
timeoutIncrements++;
if (timeoutIncrements > 3) {
// If we incremented at least twice, break; the backoff is working.
break;
}
}
Thread.sleep(1000);
}
regionNode.lock();
try {
// reset to the correct state
regionNode.setState(State.OPEN);
regionNode.setOpenSeqNum(openSeqNum);
regionNode.unsetProcedure(trsp);
} finally {
regionNode.unlock();
}
ProcedureSyncWait.waitForProcedureToComplete(procExec, proc, 60000);
assertTrue(regionNode.getOpenSeqNum() > openSeqNum);
}
use of org.apache.hadoop.hbase.master.assignment.TransitRegionStateProcedure in project hbase by apache.
the class TestServerCrashProcedureCarryingMetaStuck method test.
@Test
public void test() throws Exception {
RegionServerThread rsThread = null;
for (RegionServerThread t : UTIL.getMiniHBaseCluster().getRegionServerThreads()) {
if (!t.getRegionServer().getRegions(TableName.META_TABLE_NAME).isEmpty()) {
rsThread = t;
break;
}
}
HRegionServer rs = rsThread.getRegionServer();
RegionInfo hri = rs.getRegions(TableName.META_TABLE_NAME).get(0).getRegionInfo();
HMaster master = UTIL.getMiniHBaseCluster().getMaster();
ProcedureExecutor<MasterProcedureEnv> executor = master.getMasterProcedureExecutor();
DummyRegionProcedure proc = new DummyRegionProcedure(executor.getEnvironment(), hri);
long procId = master.getMasterProcedureExecutor().submitProcedure(proc);
proc.waitUntilArrive();
try (AsyncConnection conn = ConnectionFactory.createAsyncConnection(UTIL.getConfiguration()).get()) {
AsyncAdmin admin = conn.getAdmin();
CompletableFuture<Void> future = admin.move(hri.getRegionName());
rs.abort("For testing!");
UTIL.waitFor(30000, () -> executor.getProcedures().stream().filter(p -> p instanceof TransitRegionStateProcedure).map(p -> (TransitRegionStateProcedure) p).anyMatch(p -> Bytes.equals(hri.getRegionName(), p.getRegion().getRegionName())));
proc.resume();
UTIL.waitFor(30000, () -> executor.isFinished(procId));
// see whether the move region procedure can finish properly
future.get(30, TimeUnit.SECONDS);
}
}
Aggregations