public NonceProcedureRunnable(final MasterServices master, final long nonceGroup, final long nonce) { this.master = master; this.nonceKey = getProcedureExecutor().createNonceKey(nonceGroup, nonce); }
public static <TEnv> long submitProcedure(ProcedureExecutor<TEnv> procExecutor, Procedure proc, final long nonceGroup, final long nonce) { final NonceKey nonceKey = procExecutor.createNonceKey(nonceGroup, nonce); long procId = procExecutor.registerNonce(nonceKey); assertFalse(procId >= 0); return procExecutor.submitProcedure(proc, nonceKey); }
private void testConcurrentNonceRegistration(final boolean submitProcedure, final long nonceGroup, final long nonce) throws IOException { final NonceKey nonceKey = procExecutor.createNonceKey(nonceGroup, nonce);
@Test public void testSetFailureResultForNonce() throws IOException { final long nonceGroup = 234; final long nonce = 55555; // check and register the request nonce final NonceKey nonceKey = procExecutor.createNonceKey(nonceGroup, nonce); assertFalse(procExecutor.registerNonce(nonceKey) >= 0); procExecutor.setFailureResultForNonce(nonceKey, "testProc", User.getCurrent(), new IOException("test failure")); final long procId = procExecutor.registerNonce(nonceKey); Procedure<?> result = procExecutor.getResult(procId); ProcedureTestingUtility.assertProcFailed(result); }
@Test public void testRunningProcWithSameNonce() throws Exception { final long nonceGroup = 456; final long nonce = 33333; // register the nonce final NonceKey nonceKey = procExecutor.createNonceKey(nonceGroup, nonce); assertFalse(procExecutor.registerNonce(nonceKey) >= 0); // Submit a proc and use a latch to prevent the step execution until we submitted proc2 CountDownLatch latch = new CountDownLatch(1); TestSingleStepProcedure proc = new TestSingleStepProcedure(); procEnv.setWaitLatch(latch); long procId = procExecutor.submitProcedure(proc, nonceKey); while (proc.step != 1) Threads.sleep(25); // try to register a procedure with the same nonce // we should get back the old procId assertEquals(procId, procExecutor.registerNonce(nonceKey)); // complete the procedure latch.countDown(); // Restart, the procedure is not completed yet ProcedureTestingUtility.restart(procExecutor); ProcedureTestingUtility.waitProcedure(procExecutor, procId); // try to register a procedure with the same nonce // we should get back the old procId assertEquals(procId, procExecutor.registerNonce(nonceKey)); Procedure<?> result = procExecutor.getResult(procId); ProcedureTestingUtility.assertProcNotFailed(result); }
@Test public void testCompletedProcWithSameNonce() throws Exception { final long nonceGroup = 123; final long nonce = 2222; // register the nonce final NonceKey nonceKey = procExecutor.createNonceKey(nonceGroup, nonce); assertFalse(procExecutor.registerNonce(nonceKey) >= 0); // Submit a proc and wait for its completion Procedure proc = new TestSingleStepProcedure(); long procId = procExecutor.submitProcedure(proc, nonceKey); ProcedureTestingUtility.waitProcedure(procExecutor, procId); // Restart ProcedureTestingUtility.restart(procExecutor); ProcedureTestingUtility.waitProcedure(procExecutor, procId); // try to register a procedure with the same nonce // we should get back the old procId assertEquals(procId, procExecutor.registerNonce(nonceKey)); Procedure<?> result = procExecutor.getResult(procId); ProcedureTestingUtility.assertProcNotFailed(result); }
public static <TEnv> long submitProcedure(ProcedureExecutor<TEnv> procExecutor, Procedure proc, final long nonceGroup, final long nonce) { final NonceKey nonceKey = procExecutor.createNonceKey(nonceGroup, nonce); long procId = procExecutor.registerNonce(nonceKey); assertFalse(procId >= 0); return procExecutor.submitProcedure(proc, nonceKey); }
public static <TEnv> long submitProcedure(ProcedureExecutor<TEnv> procExecutor, Procedure proc, final long nonceGroup, final long nonce) { final NonceKey nonceKey = procExecutor.createNonceKey(nonceGroup, nonce); long procId = procExecutor.registerNonce(nonceKey); assertFalse(procId >= 0); return procExecutor.submitProcedure(proc, nonceKey); }
private void testConcurrentNonceRegistration(final boolean submitProcedure, final long nonceGroup, final long nonce) throws IOException { final NonceKey nonceKey = procExecutor.createNonceKey(nonceGroup, nonce);
private void testConcurrentNonceRegistration(final boolean submitProcedure, final long nonceGroup, final long nonce) throws IOException { final NonceKey nonceKey = procExecutor.createNonceKey(nonceGroup, nonce);
@Test public void testSetFailureResultForNonce() throws IOException { final long nonceGroup = 234; final long nonce = 55555; // check and register the request nonce final NonceKey nonceKey = procExecutor.createNonceKey(nonceGroup, nonce); assertFalse(procExecutor.registerNonce(nonceKey) >= 0); procExecutor.setFailureResultForNonce(nonceKey, "testProc", User.getCurrent(), new IOException("test failure")); final long procId = procExecutor.registerNonce(nonceKey); Procedure<?> result = procExecutor.getResult(procId); ProcedureTestingUtility.assertProcFailed(result); }
@Test public void testSetFailureResultForNonce() throws IOException { final long nonceGroup = 234; final long nonce = 55555; // check and register the request nonce final NonceKey nonceKey = procExecutor.createNonceKey(nonceGroup, nonce); assertFalse(procExecutor.registerNonce(nonceKey) >= 0); procExecutor.setFailureResultForNonce(nonceKey, "testProc", User.getCurrent(), new IOException("test failure")); final long procId = procExecutor.registerNonce(nonceKey); Procedure<?> result = procExecutor.getResult(procId); ProcedureTestingUtility.assertProcFailed(result); }
@Test public void testRunningProcWithSameNonce() throws Exception { final long nonceGroup = 456; final long nonce = 33333; // register the nonce final NonceKey nonceKey = procExecutor.createNonceKey(nonceGroup, nonce); assertFalse(procExecutor.registerNonce(nonceKey) >= 0); // Submit a proc and use a latch to prevent the step execution until we submitted proc2 CountDownLatch latch = new CountDownLatch(1); TestSingleStepProcedure proc = new TestSingleStepProcedure(); procEnv.setWaitLatch(latch); long procId = procExecutor.submitProcedure(proc, nonceKey); while (proc.step != 1) Threads.sleep(25); // try to register a procedure with the same nonce // we should get back the old procId assertEquals(procId, procExecutor.registerNonce(nonceKey)); // complete the procedure latch.countDown(); // Restart, the procedure is not completed yet ProcedureTestingUtility.restart(procExecutor); ProcedureTestingUtility.waitProcedure(procExecutor, procId); // try to register a procedure with the same nonce // we should get back the old procId assertEquals(procId, procExecutor.registerNonce(nonceKey)); Procedure<?> result = procExecutor.getResult(procId); ProcedureTestingUtility.assertProcNotFailed(result); }
@Test public void testRunningProcWithSameNonce() throws Exception { final long nonceGroup = 456; final long nonce = 33333; // register the nonce final NonceKey nonceKey = procExecutor.createNonceKey(nonceGroup, nonce); assertFalse(procExecutor.registerNonce(nonceKey) >= 0); // Submit a proc and use a latch to prevent the step execution until we submitted proc2 CountDownLatch latch = new CountDownLatch(1); TestSingleStepProcedure proc = new TestSingleStepProcedure(); procEnv.setWaitLatch(latch); long procId = procExecutor.submitProcedure(proc, nonceKey); while (proc.step != 1) Threads.sleep(25); // try to register a procedure with the same nonce // we should get back the old procId assertEquals(procId, procExecutor.registerNonce(nonceKey)); // complete the procedure latch.countDown(); // Restart, the procedure is not completed yet ProcedureTestingUtility.restart(procExecutor); ProcedureTestingUtility.waitProcedure(procExecutor, procId); // try to register a procedure with the same nonce // we should get back the old procId assertEquals(procId, procExecutor.registerNonce(nonceKey)); Procedure<?> result = procExecutor.getResult(procId); ProcedureTestingUtility.assertProcNotFailed(result); }
@Test public void testCompletedProcWithSameNonce() throws Exception { final long nonceGroup = 123; final long nonce = 2222; // register the nonce final NonceKey nonceKey = procExecutor.createNonceKey(nonceGroup, nonce); assertFalse(procExecutor.registerNonce(nonceKey) >= 0); // Submit a proc and wait for its completion Procedure proc = new TestSingleStepProcedure(); long procId = procExecutor.submitProcedure(proc, nonceKey); ProcedureTestingUtility.waitProcedure(procExecutor, procId); // Restart ProcedureTestingUtility.restart(procExecutor); ProcedureTestingUtility.waitProcedure(procExecutor, procId); // try to register a procedure with the same nonce // we should get back the old procId assertEquals(procId, procExecutor.registerNonce(nonceKey)); Procedure<?> result = procExecutor.getResult(procId); ProcedureTestingUtility.assertProcNotFailed(result); }
@Test public void testCompletedProcWithSameNonce() throws Exception { final long nonceGroup = 123; final long nonce = 2222; // register the nonce final NonceKey nonceKey = procExecutor.createNonceKey(nonceGroup, nonce); assertFalse(procExecutor.registerNonce(nonceKey) >= 0); // Submit a proc and wait for its completion Procedure proc = new TestSingleStepProcedure(); long procId = procExecutor.submitProcedure(proc, nonceKey); ProcedureTestingUtility.waitProcedure(procExecutor, procId); // Restart ProcedureTestingUtility.restart(procExecutor); ProcedureTestingUtility.waitProcedure(procExecutor, procId); // try to register a procedure with the same nonce // we should get back the old procId assertEquals(procId, procExecutor.registerNonce(nonceKey)); Procedure<?> result = procExecutor.getResult(procId); ProcedureTestingUtility.assertProcNotFailed(result); }