use of org.apache.hadoop.hbase.ProcedureInfo in project hbase by apache.
the class TestProcedureRecovery method testMultiStepProcRecovery.
@Test(timeout = 30000)
public void testMultiStepProcRecovery() throws Exception {
// Step 0 - kill
Procedure proc = new TestMultiStepProcedure();
long procId = ProcedureTestingUtility.submitAndWait(procExecutor, proc);
assertFalse(procExecutor.isRunning());
// Step 0 exec && Step 1 - kill
restart();
waitProcedure(procId);
ProcedureTestingUtility.assertProcNotYetCompleted(procExecutor, procId);
assertFalse(procExecutor.isRunning());
// Step 1 exec && step 2 - kill
restart();
waitProcedure(procId);
ProcedureTestingUtility.assertProcNotYetCompleted(procExecutor, procId);
assertFalse(procExecutor.isRunning());
// Step 2 exec
restart();
waitProcedure(procId);
assertTrue(procExecutor.isRunning());
// The procedure is completed
ProcedureInfo result = procExecutor.getResult(procId);
ProcedureTestingUtility.assertProcNotFailed(result);
}
use of org.apache.hadoop.hbase.ProcedureInfo in project hbase by apache.
the class TestProcedureUtil method testConvert.
@Test
public void testConvert() throws Exception {
// check Procedure to protobuf conversion
final TestProcedure proc1 = new TestProcedure(10);
final ProcedureProtos.Procedure proto1 = ProcedureUtil.convertToProtoProcedure(proc1);
final TestProcedure proc2 = (TestProcedure) ProcedureUtil.convertToProcedure(proto1);
final ProcedureProtos.Procedure proto2 = ProcedureUtil.convertToProtoProcedure(proc2);
assertEquals(false, proto2.hasResult());
assertEquals("Procedure protobuf does not match", proto1, proto2);
// remove the state-data from the procedure protobuf to compare it to the gen ProcedureInfo
final ProcedureProtos.Procedure pbproc = proto2.toBuilder().clearStateData().build();
// check ProcedureInfo to protobuf conversion
final ProcedureInfo protoInfo1 = ProcedureUtil.convertToProcedureInfo(proc1);
final ProcedureProtos.Procedure proto3 = ProcedureUtil.convertToProtoProcedure(protoInfo1);
final ProcedureInfo protoInfo2 = ProcedureUtil.convertToProcedureInfo(proto3);
final ProcedureProtos.Procedure proto4 = ProcedureUtil.convertToProtoProcedure(protoInfo2);
assertEquals("ProcedureInfo protobuf does not match", proto3, proto4);
assertEquals("ProcedureInfo/Procedure protobuf does not match", pbproc, proto3);
assertEquals("ProcedureInfo/Procedure protobuf does not match", pbproc, proto4);
}
use of org.apache.hadoop.hbase.ProcedureInfo in project hbase by apache.
the class TestProcedureExecution method testSingleSequentialProc.
@Test(timeout = 30000)
public void testSingleSequentialProc() {
List<String> state = new ArrayList<>();
Procedure subProc2 = new TestSequentialProcedure("subProc2", state);
Procedure subProc1 = new TestSequentialProcedure("subProc1", state, subProc2);
Procedure rootProc = new TestSequentialProcedure("rootProc", state, subProc1);
long rootId = ProcedureTestingUtility.submitAndWait(procExecutor, rootProc);
// successful state, with 3 execute
LOG.info(state);
ProcedureInfo result = procExecutor.getResult(rootId);
ProcedureTestingUtility.assertProcNotFailed(result);
assertEquals(state.toString(), 3, state.size());
}
use of org.apache.hadoop.hbase.ProcedureInfo in project hbase by apache.
the class TestProcedureNonce method testCompletedProcWithSameNonce.
@Test(timeout = 30000)
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));
ProcedureInfo result = procExecutor.getResult(procId);
ProcedureTestingUtility.assertProcNotFailed(result);
}
use of org.apache.hadoop.hbase.ProcedureInfo in project hbase by apache.
the class TestProcedureNonce method testRunningProcWithSameNonce.
@Test(timeout = 30000)
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));
ProcedureInfo result = procExecutor.getResult(procId);
ProcedureTestingUtility.assertProcNotFailed(result);
}
Aggregations