public void remoteProcedureFailed(long procId, RemoteProcedureException error) { LOG.debug("Remote procedure failed, pid={}", procId, error); RemoteProcedure<MasterProcedureEnv, ?> procedure = getRemoteProcedure(procId); if (procedure != null) { procedure.remoteOperationFailed(procedureExecutor.getEnvironment(), error); } }
/** * Release the lock. * No-op if the lock was never acquired. */ public void release() { if (proc != null) { proc.unlock(master.getMasterProcedureExecutor().getEnvironment()); } proc = null; }
@Override public long createNamespace(NamespaceDescriptor namespaceDescriptor, final NonceKey nonceKey, final ProcedurePrepareLatch latch) throws IOException { return submitProcedure(new CreateNamespaceProcedure( this.masterServices.getMasterProcedureExecutor().getEnvironment(), namespaceDescriptor, latch), nonceKey); }
@Override public long deleteNamespace(String name, final NonceKey nonceKey, final ProcedurePrepareLatch latch) throws IOException { return submitProcedure(new DeleteNamespaceProcedure( this.masterServices.getMasterProcedureExecutor().getEnvironment(), name, latch), nonceKey); }
@Override public long modifyNamespace(NamespaceDescriptor namespaceDescriptor, final NonceKey nonceKey, final ProcedurePrepareLatch latch) throws IOException { return submitProcedure(new ModifyNamespaceProcedure( this.masterServices.getMasterProcedureExecutor().getEnvironment(), namespaceDescriptor, latch), nonceKey); }
@Test public void testChildOnLastStepWithRollback() { procExecutor.getEnvironment().triggerChildRollback = true; long procId = procExecutor.submitProcedure(new TestSMProcedure()); ProcedureTestingUtility.waitProcedure(procExecutor, procId); assertEquals(3, procExecutor.getEnvironment().execCount.get()); assertEquals(3, procExecutor.getEnvironment().rollbackCount.get()); Throwable cause = ProcedureTestingUtility.assertProcFailed(procExecutor, procId); assertEquals(TEST_FAILURE_EXCEPTION, cause); }
@Test public void testChildOnLastStepWithRollbackDoubleExecution() throws Exception { procExecutor.getEnvironment().triggerChildRollback = true; ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExecutor, true); long procId = procExecutor.submitProcedure(new TestSMProcedure()); ProcedureTestingUtility.testRecoveryAndDoubleExecution(procExecutor, procId, true); assertEquals(6, procExecutor.getEnvironment().execCount.get()); assertEquals(6, procExecutor.getEnvironment().rollbackCount.get()); Throwable cause = ProcedureTestingUtility.assertProcFailed(procExecutor, procId); assertEquals(TEST_FAILURE_EXCEPTION, cause); }
@Test public void testChildOnLastStep() { long procId = procExecutor.submitProcedure(new TestSMProcedure()); ProcedureTestingUtility.waitProcedure(procExecutor, procId); assertEquals(3, procExecutor.getEnvironment().execCount.get()); assertEquals(0, procExecutor.getEnvironment().rollbackCount.get()); ProcedureTestingUtility.assertProcNotFailed(procExecutor, procId); }
@Override public boolean start() { if (!super.start()) { return false; } master.getServerManager().registerListener(this); procedureEnv = master.getMasterProcedureExecutor().getEnvironment(); for (ServerName serverName: master.getServerManager().getOnlineServersList()) { addNode(serverName); } return true; }
@Test public void testChildNormalRollbackStateCount() { procExecutor.getEnvironment().triggerChildRollback = true; TestSMProcedureBadRollback testNormalRollback = new TestSMProcedureBadRollback(); long procId = procExecutor.submitProcedure(testNormalRollback); ProcedureTestingUtility.waitProcedure(procExecutor, procId); assertEquals(0, testNormalRollback.stateCount); }
private void createNamespaceForTesting(NamespaceDescriptor nsDescriptor) throws Exception { final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor(); long procId = procExec.submitProcedure( new CreateNamespaceProcedure(procExec.getEnvironment(), nsDescriptor)); // Wait the completion ProcedureTestingUtility.waitProcedure(procExec, procId); ProcedureTestingUtility.assertProcNotFailed(procExec, procId); } }
@Test(expected=TableNotFoundException.class) public void testDeleteNotExistentTable() throws Exception { final TableName tableName = TableName.valueOf(name.getMethodName()); final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor(); ProcedurePrepareLatch latch = new ProcedurePrepareLatch.CompatibilityLatch(); long procId = ProcedureTestingUtility.submitAndWait(procExec, new DeleteTableProcedure(procExec.getEnvironment(), tableName, latch)); latch.await(); }
@After public void tearDown() throws Exception { for (Procedure<?> proc : getMasterProcedureExecutor().getProcedures()) { if (proc instanceof LockProcedure) { ((LockProcedure) proc).unlock(getMasterProcedureExecutor().getEnvironment()); ProcedureTestingUtility.waitProcedure(getMasterProcedureExecutor(), proc); } } assertEquals(0, getMasterProcedureExecutor().getEnvironment().getProcedureScheduler().size()); }
public void start(final int numServes, final RSProcedureDispatcher remoteDispatcher) throws IOException, KeeperException { startProcedureExecutor(remoteDispatcher); this.assignmentManager.start(); for (int i = 0; i < numServes; ++i) { ServerName sn = ServerName.valueOf("localhost", 100 + i, 1); serverManager.regionServerReport(sn, ServerMetricsBuilder.of(sn)); } this.procedureExecutor.getEnvironment().setEventReady(initialized, true); }
public static RegionInfo[] createTable(final ProcedureExecutor<MasterProcedureEnv> procExec, final TableName tableName, final byte[][] splitKeys, String... family) throws IOException { TableDescriptor htd = createHTD(tableName, family); RegionInfo[] regions = ModifyRegionUtils.createRegionInfos(htd, splitKeys); long procId = ProcedureTestingUtility.submitAndWait(procExec, new CreateTableProcedure(procExec.getEnvironment(), htd, regions)); ProcedureTestingUtility.assertProcNotFailed(procExec.getResult(procId)); return regions; }
@Test public void testRestoreSnapshot() throws Exception { final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor(); long procId = ProcedureTestingUtility.submitAndWait( procExec, new RestoreSnapshotProcedure(procExec.getEnvironment(), snapshotHTD, snapshot)); ProcedureTestingUtility.assertProcNotFailed(procExec.getResult(procId)); validateSnapshotRestore(); }
@Test public void testDeleteNamespace() throws Exception { final String namespaceName = "testDeleteNamespace"; final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor(); createNamespaceForTesting(namespaceName); long procId = procExec.submitProcedure( new DeleteNamespaceProcedure(procExec.getEnvironment(), namespaceName)); // Wait the completion ProcedureTestingUtility.waitProcedure(procExec, procId); ProcedureTestingUtility.assertProcNotFailed(procExec, procId); validateNamespaceNotExist(namespaceName); }
@Test public void testRecoveryAndDoubleExecution() throws Exception { final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor(); ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExec, true); // Start the Restore snapshot procedure && kill the executor long procId = procExec.submitProcedure( new RestoreSnapshotProcedure(procExec.getEnvironment(), snapshotHTD, snapshot)); // Restart the executor and execute the step twice MasterProcedureTestingUtility.testRecoveryAndDoubleExecution(procExec, procId); resetProcExecutorTestingKillFlag(); validateSnapshotRestore(); }
@After public void tearDown() throws Exception { ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExec, false); // Kill all running procedures. for (Procedure<?> proc : procExec.getProcedures()) { procExec.abort(proc.getProcId()); ProcedureTestingUtility.waitProcedure(procExec, proc); } assertEquals(0, procExec.getEnvironment().getProcedureScheduler().size()); }
@Test public void testCrashProcedureReplay() { HMaster master = TEST_UTIL.getHBaseCluster().getMaster(); final ProcedureExecutor<MasterProcedureEnv> pExecutor = master.getMasterProcedureExecutor(); ServerCrashProcedure proc = new ServerCrashProcedure( pExecutor.getEnvironment(), hostname123, false, false); ProcedureTestingUtility.submitAndWait(pExecutor, proc); assertFalse(master.getServerManager().getDeadServers().areDeadServersInProgress()); }