Search in sources :

Example 26 with ProcedureInfo

use of org.apache.hadoop.hbase.ProcedureInfo in project hbase by apache.

the class TestProcedureRecovery method testSingleStepProcRecovery.

@Test(timeout = 30000)
public void testSingleStepProcRecovery() throws Exception {
    Procedure proc = new TestSingleStepProcedure();
    procExecutor.testing.killBeforeStoreUpdate = true;
    long procId = ProcedureTestingUtility.submitAndWait(procExecutor, proc);
    assertFalse(procExecutor.isRunning());
    procExecutor.testing.killBeforeStoreUpdate = false;
    // Restart and verify that the procedures restart
    long restartTs = EnvironmentEdgeManager.currentTime();
    restart();
    waitProcedure(procId);
    ProcedureInfo result = procExecutor.getResult(procId);
    assertTrue(result.getLastUpdate() > restartTs);
    ProcedureTestingUtility.assertProcNotFailed(result);
    assertEquals(1, Bytes.toInt(result.getResult()));
    long resultTs = result.getLastUpdate();
    // Verify that after another restart the result is still there
    restart();
    result = procExecutor.getResult(procId);
    ProcedureTestingUtility.assertProcNotFailed(result);
    assertEquals(resultTs, result.getLastUpdate());
    assertEquals(1, Bytes.toInt(result.getResult()));
}
Also used : ProcedureInfo(org.apache.hadoop.hbase.ProcedureInfo) Test(org.junit.Test)

Example 27 with ProcedureInfo

use of org.apache.hadoop.hbase.ProcedureInfo in project hbase by apache.

the class ProcedureTestingUtility method assertProcNotFailed.

public static <TEnv> void assertProcNotFailed(ProcedureExecutor<TEnv> procExecutor, long procId) {
    ProcedureInfo result = procExecutor.getResult(procId);
    assertTrue("expected procedure result", result != null);
    assertProcNotFailed(result);
}
Also used : ProcedureInfo(org.apache.hadoop.hbase.ProcedureInfo)

Example 28 with ProcedureInfo

use of org.apache.hadoop.hbase.ProcedureInfo in project hbase by apache.

the class TestProcedureExecution method testAbortTimeoutWithChildren.

@Test(timeout = 30000)
public void testAbortTimeoutWithChildren() {
    List<String> state = new ArrayList<>();
    Procedure proc = new TestWaitingProcedure("wproc", state, true);
    proc.setTimeout(2500);
    long rootId = ProcedureTestingUtility.submitAndWait(procExecutor, proc);
    LOG.info(state);
    ProcedureInfo result = procExecutor.getResult(rootId);
    assertTrue(state.toString(), result.isFailed());
    ProcedureTestingUtility.assertIsTimeoutException(result);
    assertEquals(state.toString(), 4, state.size());
    assertEquals("wproc-execute", state.get(0));
    assertEquals("wproc-child-execute", state.get(1));
    assertEquals("wproc-child-rollback", state.get(2));
    assertEquals("wproc-rollback", state.get(3));
}
Also used : ProcedureInfo(org.apache.hadoop.hbase.ProcedureInfo) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 29 with ProcedureInfo

use of org.apache.hadoop.hbase.ProcedureInfo in project hbase by apache.

the class TestProcedureExecution method testRollbackRetriableFailure.

@Test(timeout = 30000)
public void testRollbackRetriableFailure() {
    long procId = ProcedureTestingUtility.submitAndWait(procExecutor, new TestFaultyRollback());
    ProcedureInfo result = procExecutor.getResult(procId);
    assertTrue("expected a failure", result.isFailed());
    LOG.info(result.getException().getMessage());
    Throwable cause = ProcedureTestingUtility.getExceptionCause(result);
    assertTrue("expected TestProcedureException, got " + cause, cause instanceof TestProcedureException);
}
Also used : ProcedureInfo(org.apache.hadoop.hbase.ProcedureInfo) Test(org.junit.Test)

Example 30 with ProcedureInfo

use of org.apache.hadoop.hbase.ProcedureInfo in project hbase by apache.

the class TestProcedureExecution method testAbortTimeout.

@Test(timeout = 30000)
public void testAbortTimeout() {
    final int PROC_TIMEOUT_MSEC = 2500;
    List<String> state = new ArrayList<>();
    Procedure proc = new TestWaitingProcedure("wproc", state, false);
    proc.setTimeout(PROC_TIMEOUT_MSEC);
    long startTime = EnvironmentEdgeManager.currentTime();
    long rootId = ProcedureTestingUtility.submitAndWait(procExecutor, proc);
    long execTime = EnvironmentEdgeManager.currentTime() - startTime;
    LOG.info(state);
    assertTrue("we didn't wait enough execTime=" + execTime, execTime >= PROC_TIMEOUT_MSEC);
    ProcedureInfo result = procExecutor.getResult(rootId);
    assertTrue(state.toString(), result.isFailed());
    ProcedureTestingUtility.assertIsTimeoutException(result);
    assertEquals(state.toString(), 2, state.size());
    assertEquals("wproc-execute", state.get(0));
    assertEquals("wproc-rollback", state.get(1));
}
Also used : ProcedureInfo(org.apache.hadoop.hbase.ProcedureInfo) ArrayList(java.util.ArrayList) 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