public static <TEnv> long submitAndWait(ProcedureExecutor<TEnv> procExecutor, Procedure proc, final long nonceGroup, final long nonce) { long procId = submitProcedure(procExecutor, proc, nonceGroup, nonce); waitProcedure(procExecutor, procId); return procId; }
@Test public void testAcquireAndReleaseSplitWALWorker() throws Exception { ProcedureExecutor<MasterProcedureEnv> masterPE = master.getMasterProcedureExecutor(); List<FakeServerProcedure> testProcedures = new ArrayList<>(); for (int i = 0; i < 3; i++) { FakeServerProcedure procedure = new FakeServerProcedure(TEST_UTIL.getHBaseCluster().getRegionServer(i).getServerName()); testProcedures.add(procedure); ProcedureTestingUtility.submitProcedure(masterPE, procedure, HConstants.NO_NONCE, HConstants.NO_NONCE); } TEST_UTIL.waitFor(10000, () -> testProcedures.get(2).isWorkerAcquired()); FakeServerProcedure failedProcedure = new FakeServerProcedure(TEST_UTIL.getHBaseCluster().getServerHoldingMeta()); ProcedureTestingUtility.submitProcedure(masterPE, failedProcedure, HConstants.NO_NONCE, HConstants.NO_NONCE); TEST_UTIL.waitFor(20000, () -> failedProcedure.isTriedToAcquire()); Assert.assertFalse(failedProcedure.isWorkerAcquired()); // let one procedure finish and release worker testProcedures.get(0).countDown(); TEST_UTIL.waitFor(10000, () -> failedProcedure.isWorkerAcquired()); Assert.assertTrue(testProcedures.get(0).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 testWorkerReloadWhenMasterRestart() throws Exception { List<FakeServerProcedure> testProcedures = new ArrayList<>(); for (int i = 0; i < 3; i++) { FakeServerProcedure procedure = new FakeServerProcedure(TEST_UTIL.getHBaseCluster().getRegionServer(i).getServerName()); testProcedures.add(procedure); ProcedureTestingUtility.submitProcedure(master.getMasterProcedureExecutor(), procedure, HConstants.NO_NONCE, HConstants.NO_NONCE); } TEST_UTIL.waitFor(10000, () -> testProcedures.get(2).isWorkerAcquired()); // 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(); FakeServerProcedure failedProcedure = new FakeServerProcedure(TEST_UTIL.getHBaseCluster().getServerHoldingMeta()); ProcedureTestingUtility.submitProcedure(master.getMasterProcedureExecutor(), failedProcedure, HConstants.NO_NONCE, HConstants.NO_NONCE); TEST_UTIL.waitFor(20000, () -> failedProcedure.isTriedToAcquire()); Assert.assertFalse(failedProcedure.isWorkerAcquired()); for (int i = 0; i < 3; i++) { testProcedures.get(i).countDown(); } failedProcedure.countDown(); }
public static <TEnv> long submitAndWait(ProcedureExecutor<TEnv> procExecutor, Procedure proc, final long nonceGroup, final long nonce) { long procId = submitProcedure(procExecutor, proc, nonceGroup, nonce); waitProcedure(procExecutor, procId); return procId; }
public static <TEnv> long submitAndWait(ProcedureExecutor<TEnv> procExecutor, Procedure proc, final long nonceGroup, final long nonce) { long procId = submitProcedure(procExecutor, proc, nonceGroup, nonce); waitProcedure(procExecutor, procId); return procId; }