/** * @return true if the procedure is finished. The Procedure may be completed successfully or * rolledback. */ public synchronized boolean isFinished() { return isSuccess() || state == ProcedureState.ROLLEDBACK; }
@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; } },
private void cleanupAfterRollbackOneStep(Procedure<TEnvironment> proc) { if (proc.removeStackIndex()) { if (!proc.isSuccess()) { proc.setState(ProcedureState.ROLLEDBACK); } // update metrics on finishing the procedure (fail) proc.updateMetricsOnFinish(getEnvironment(), proc.elapsedTime(), false); if (proc.hasParent()) { store.delete(proc.getProcId()); procedures.remove(proc.getProcId()); } else { final long[] childProcIds = rollbackStack.get(proc.getProcId()).getSubprocedureIds(); if (childProcIds != null) { store.delete(proc, childProcIds); } else { store.update(proc); } } } else { store.update(proc); } }
if (proc.isSuccess()) {
if (proc.isSuccess()) {
@Test public void testMasterRestart() throws Exception { Table table = TEST_UTIL.createTable(TABLE_NAME, FAMILY, TEST_UTIL.KEYS_FOR_HBA_CREATE_TABLE); for (int i = 0; i < 10; i++) { TEST_UTIL.loadTable(table, FAMILY); } HRegionServer testServer = TEST_UTIL.getHBaseCluster().getRegionServer(0); List<FileStatus> wals = splitWALManager.getWALsToSplit(testServer.getServerName(), false); Assert.assertEquals(1, wals.size()); SplitWALProcedure splitWALProcedure = new SplitWALProcedure(wals.get(0).getPath().toString(), testServer.getServerName()); long pid = ProcedureTestingUtility.submitProcedure(master.getMasterProcedureExecutor(), splitWALProcedure, HConstants.NO_NONCE, HConstants.NO_NONCE); TEST_UTIL.waitFor(5000, () -> splitWALProcedure.getWorker() != null); // Kill master TEST_UTIL.getHBaseCluster().killMaster(master.getServerName()); TEST_UTIL.getHBaseCluster().waitForMasterToStop(master.getServerName(), 20000); // restart master TEST_UTIL.getHBaseCluster().startMaster(); TEST_UTIL.getHBaseCluster().waitForActiveAndReadyMaster(); this.master = TEST_UTIL.getHBaseCluster().getMaster(); ProcedureTestingUtility.waitProcedure(master.getMasterProcedureExecutor(), pid); Optional<Procedure<?>> procedure = master.getProcedures().stream().filter(p -> p.getProcId() == pid).findAny(); // make sure procedure is successful and wal is deleted Assert.assertTrue(procedure.isPresent()); Assert.assertTrue(procedure.get().isSuccess()); Assert.assertFalse(TEST_UTIL.getTestFileSystem().exists(wals.get(0).getPath())); }
@Test public void testHandleDeadWorker() throws Exception { Table table = TEST_UTIL.createTable(TABLE_NAME, FAMILY, TEST_UTIL.KEYS_FOR_HBA_CREATE_TABLE); for (int i = 0; i < 10; i++) { TEST_UTIL.loadTable(table, FAMILY); } HRegionServer testServer = TEST_UTIL.getHBaseCluster().getRegionServer(0); ProcedureExecutor<MasterProcedureEnv> masterPE = master.getMasterProcedureExecutor(); List<FileStatus> wals = splitWALManager.getWALsToSplit(testServer.getServerName(), false); Assert.assertEquals(1, wals.size()); TEST_UTIL.getHBaseCluster().killRegionServer(testServer.getServerName()); TEST_UTIL.waitFor(30000, () -> master.getProcedures().stream() .anyMatch(procedure -> procedure instanceof SplitWALProcedure)); Procedure splitWALProcedure = master.getProcedures().stream() .filter(procedure -> procedure instanceof SplitWALProcedure).findAny().get(); Assert.assertNotNull(splitWALProcedure); TEST_UTIL.waitFor(5000, () -> ((SplitWALProcedure) splitWALProcedure).getWorker() != null); TEST_UTIL.getHBaseCluster() .killRegionServer(((SplitWALProcedure) splitWALProcedure).getWorker()); ProcedureTestingUtility.waitProcedure(masterPE, splitWALProcedure.getProcId()); Assert.assertTrue(splitWALProcedure.isSuccess()); ProcedureTestingUtility.waitAllProcedures(masterPE); }
@Test public void test() throws Exception { TestProcedure proc = new TestProcedure(); long procId = procExecutor.submitProcedure(proc); htu.waitFor(30000, () -> proc.isWaiting()); ProcedureTestingUtility.restart(procExecutor); htu.waitFor(30000, () -> { Procedure<?> p = procExecutor.getProcedure(procId); return p.isWaiting() || p.isFinished(); }); assertFalse(procExecutor.isFinished(procId)); ProcedureTestingUtility.restart(procExecutor); htu.waitFor(30000, () -> procExecutor.isFinished(procId)); Procedure<ProcEnv> p = procExecutor.getResult(procId); assertTrue(p.isSuccess()); } }
/** * @return true if the procedure is finished. The Procedure may be completed successfully or * rolledback. */ public synchronized boolean isFinished() { return isSuccess() || state == ProcedureState.ROLLEDBACK; }
/** * @return true if the procedure is finished. The Procedure may be completed successfully or * rolledback. */ public synchronized boolean isFinished() { return isSuccess() || state == ProcedureState.ROLLEDBACK; }
private void cleanupAfterRollbackOneStep(Procedure<TEnvironment> proc) { if (proc.removeStackIndex()) { if (!proc.isSuccess()) { proc.setState(ProcedureState.ROLLEDBACK); } // update metrics on finishing the procedure (fail) proc.updateMetricsOnFinish(getEnvironment(), proc.elapsedTime(), false); if (proc.hasParent()) { store.delete(proc.getProcId()); procedures.remove(proc.getProcId()); } else { final long[] childProcIds = rollbackStack.get(proc.getProcId()).getSubprocedureIds(); if (childProcIds != null) { store.delete(proc, childProcIds); } else { store.update(proc); } } } else { store.update(proc); } }
if (proc.isSuccess()) {
if (proc.isSuccess()) {
if (proc.isSuccess()) {
if (proc.isSuccess()) { if (LOG.isDebugEnabled()) { LOG.debug("Procedure completed in " +
@Test public void test() throws Exception { TestProcedure proc = new TestProcedure(); long procId = procExecutor.submitProcedure(proc); htu.waitFor(30000, () -> proc.isWaiting()); ProcedureTestingUtility.restart(procExecutor); htu.waitFor(30000, () -> { Procedure<?> p = procExecutor.getProcedure(procId); return p.isWaiting() || p.isFinished(); }); assertFalse(procExecutor.isFinished(procId)); ProcedureTestingUtility.restart(procExecutor); htu.waitFor(30000, () -> procExecutor.isFinished(procId)); Procedure<ProcEnv> p = procExecutor.getResult(procId); assertTrue(p.isSuccess()); } }