Search in sources :

Example 6 with ProcedureInfo

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);
}
Also used : ProcedureInfo(org.apache.hadoop.hbase.ProcedureInfo) Test(org.junit.Test)

Example 7 with ProcedureInfo

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);
}
Also used : TestProcedure(org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility.TestProcedure) ProcedureInfo(org.apache.hadoop.hbase.ProcedureInfo) ProcedureProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.ProcedureProtos) Test(org.junit.Test)

Example 8 with ProcedureInfo

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());
}
Also used : ProcedureInfo(org.apache.hadoop.hbase.ProcedureInfo) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 9 with ProcedureInfo

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);
}
Also used : NonceKey(org.apache.hadoop.hbase.util.NonceKey) ProcedureInfo(org.apache.hadoop.hbase.ProcedureInfo) Test(org.junit.Test)

Example 10 with ProcedureInfo

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);
}
Also used : NonceKey(org.apache.hadoop.hbase.util.NonceKey) ProcedureInfo(org.apache.hadoop.hbase.ProcedureInfo) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Aggregations

ProcedureInfo (org.apache.hadoop.hbase.ProcedureInfo)57 Test (org.junit.Test)42 TableName (org.apache.hadoop.hbase.TableName)16 ArrayList (java.util.ArrayList)7 NamespaceDescriptor (org.apache.hadoop.hbase.NamespaceDescriptor)7 ConstraintException (org.apache.hadoop.hbase.constraint.ConstraintException)6 NonceKey (org.apache.hadoop.hbase.util.NonceKey)5 IOException (java.io.IOException)4 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)4 InvalidFamilyOperationException (org.apache.hadoop.hbase.InvalidFamilyOperationException)4 Procedure (org.apache.hadoop.hbase.procedure2.Procedure)4 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)3 TableNotDisabledException (org.apache.hadoop.hbase.TableNotDisabledException)3 TableNotFoundException (org.apache.hadoop.hbase.TableNotFoundException)3 LockProcedure (org.apache.hadoop.hbase.master.locking.LockProcedure)3 AtomicLong (java.util.concurrent.atomic.AtomicLong)2 HColumnDescriptor (org.apache.hadoop.hbase.HColumnDescriptor)2 HRegionInfo (org.apache.hadoop.hbase.HRegionInfo)2 NamespaceExistException (org.apache.hadoop.hbase.NamespaceExistException)2 NamespaceNotFoundException (org.apache.hadoop.hbase.NamespaceNotFoundException)2