Search in sources :

Example 36 with ProcedureInfo

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

the class ProcedureExecutor method getResultOrProcedure.

public Pair<ProcedureInfo, Procedure> getResultOrProcedure(final long procId) {
    ProcedureInfo result = completed.get(procId);
    Procedure proc = null;
    if (result == null) {
        proc = procedures.get(procId);
        if (proc == null) {
            result = completed.get(procId);
        }
    }
    return new Pair(result, proc);
}
Also used : ProcedureInfo(org.apache.hadoop.hbase.ProcedureInfo) Pair(org.apache.hadoop.hbase.util.Pair)

Example 37 with ProcedureInfo

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

the class TestProcedureRecovery method testMultiStepRollbackRecovery.

@Test(timeout = 30000)
public void testMultiStepRollbackRecovery() 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 - rollback - kill
    procSleepInterval = 2500;
    restart();
    assertTrue(procExecutor.abort(procId));
    waitProcedure(procId);
    assertFalse(procExecutor.isRunning());
    // rollback - kill
    restart();
    waitProcedure(procId);
    ProcedureTestingUtility.assertProcNotYetCompleted(procExecutor, procId);
    assertFalse(procExecutor.isRunning());
    // rollback - complete
    restart();
    waitProcedure(procId);
    ProcedureTestingUtility.assertProcNotYetCompleted(procExecutor, procId);
    assertFalse(procExecutor.isRunning());
    // Restart the executor and get the result
    restart();
    waitProcedure(procId);
    // The procedure is completed
    ProcedureInfo result = procExecutor.getResult(procId);
    ProcedureTestingUtility.assertIsAbortException(result);
}
Also used : ProcedureInfo(org.apache.hadoop.hbase.ProcedureInfo) Test(org.junit.Test)

Example 38 with ProcedureInfo

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

the class TestProcedureNonce method testSetFailureResultForNonce.

@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);
    ProcedureInfo result = procExecutor.getResult(procId);
    ProcedureTestingUtility.assertProcFailed(result);
}
Also used : NonceKey(org.apache.hadoop.hbase.util.NonceKey) ProcedureInfo(org.apache.hadoop.hbase.ProcedureInfo) IOException(java.io.IOException) Test(org.junit.Test)

Example 39 with ProcedureInfo

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

the class TestModifyColumnFamilyProcedure method testModifyNonExistingColumnFamily.

@Test(timeout = 60000)
public void testModifyNonExistingColumnFamily() throws Exception {
    final TableName tableName = TableName.valueOf(name.getMethodName());
    final String cf2 = "cf2";
    final HColumnDescriptor columnDescriptor = new HColumnDescriptor(cf2);
    int oldBlockSize = columnDescriptor.getBlocksize();
    int newBlockSize = 2 * oldBlockSize;
    final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
    MasterProcedureTestingUtility.createTable(procExec, tableName, null, "f1");
    // Modify the column family that does not exist
    columnDescriptor.setBlocksize(newBlockSize);
    long procId1 = procExec.submitProcedure(new ModifyColumnFamilyProcedure(procExec.getEnvironment(), tableName, columnDescriptor));
    // Wait the completion
    ProcedureTestingUtility.waitProcedure(procExec, procId1);
    ProcedureInfo result = procExec.getResult(procId1);
    assertTrue(result.isFailed());
    LOG.debug("Modify failed with exception: " + result.getExceptionFullMessage());
    assertTrue(ProcedureTestingUtility.getExceptionCause(result) instanceof InvalidFamilyOperationException);
}
Also used : TableName(org.apache.hadoop.hbase.TableName) HColumnDescriptor(org.apache.hadoop.hbase.HColumnDescriptor) ProcedureInfo(org.apache.hadoop.hbase.ProcedureInfo) InvalidFamilyOperationException(org.apache.hadoop.hbase.InvalidFamilyOperationException) Test(org.junit.Test)

Example 40 with ProcedureInfo

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

the class TestRestoreSnapshotProcedure method testRestoreSnapshotToDifferentTable.

@Test(timeout = 60000)
public void testRestoreSnapshotToDifferentTable() throws Exception {
    final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
    final TableName restoredTableName = TableName.valueOf(name.getMethodName());
    final HTableDescriptor newHTD = createHTableDescriptor(restoredTableName, CF1, CF2);
    long procId = ProcedureTestingUtility.submitAndWait(procExec, new RestoreSnapshotProcedure(procExec.getEnvironment(), newHTD, snapshot));
    ProcedureInfo result = procExec.getResult(procId);
    assertTrue(result.isFailed());
    LOG.debug("Restore snapshot failed with exception: " + result.getExceptionFullMessage());
    assertTrue(ProcedureTestingUtility.getExceptionCause(result) instanceof TableNotFoundException);
}
Also used : TableName(org.apache.hadoop.hbase.TableName) TableNotFoundException(org.apache.hadoop.hbase.TableNotFoundException) ProcedureInfo(org.apache.hadoop.hbase.ProcedureInfo) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor) 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