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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations