use of org.apache.hadoop.hbase.ProcedureInfo in project hbase by apache.
the class TestModifyNamespaceProcedure method testModifyNamespaceWithInvalidRegionCount.
@Test(timeout = 60000)
public void testModifyNamespaceWithInvalidRegionCount() throws Exception {
final NamespaceDescriptor nsd = NamespaceDescriptor.create("testModifyNamespaceWithInvalidRegionCount").build();
final String nsKey = "hbase.namespace.quota.maxregions";
final String nsValue = "-1";
final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
createNamespaceForTesting(nsd);
// Modify
nsd.setConfiguration(nsKey, nsValue);
long procId = procExec.submitProcedure(new ModifyNamespaceProcedure(procExec.getEnvironment(), nsd));
// Wait the completion
ProcedureTestingUtility.waitProcedure(procExec, procId);
ProcedureInfo result = procExec.getResult(procId);
assertTrue(result.isFailed());
LOG.debug("Modify namespace failed with exception: " + result.getExceptionFullMessage());
assertTrue(ProcedureTestingUtility.getExceptionCause(result) instanceof ConstraintException);
}
use of org.apache.hadoop.hbase.ProcedureInfo in project hbase by apache.
the class TestModifyNamespaceProcedure method testModifyNonExistNamespace.
@Test(timeout = 60000)
public void testModifyNonExistNamespace() throws Exception {
final String namespaceName = "testModifyNonExistNamespace";
final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
try {
NamespaceDescriptor nsDescriptor = UTIL.getAdmin().getNamespaceDescriptor(namespaceName);
assertNull(nsDescriptor);
} catch (NamespaceNotFoundException nsnfe) {
// Expected
LOG.debug("The namespace " + namespaceName + " does not exist. This is expected.");
}
final NamespaceDescriptor nsd = NamespaceDescriptor.create(namespaceName).build();
long procId = procExec.submitProcedure(new ModifyNamespaceProcedure(procExec.getEnvironment(), nsd));
// Wait the completion
ProcedureTestingUtility.waitProcedure(procExec, procId);
// Expect fail with NamespaceNotFoundException
ProcedureInfo result = procExec.getResult(procId);
assertTrue(result.isFailed());
LOG.debug("modify namespace failed with exception: " + result.getExceptionFullMessage());
assertTrue(ProcedureTestingUtility.getExceptionCause(result) instanceof NamespaceNotFoundException);
}
use of org.apache.hadoop.hbase.ProcedureInfo in project hbase by apache.
the class TestModifyTableProcedure method testModifyTableDeleteCF.
@Test(timeout = 60000)
public void testModifyTableDeleteCF() throws Exception {
final TableName tableName = TableName.valueOf(name.getMethodName());
final String cf1 = "cf1";
final String cf2 = "cf2";
final String cf3 = "cf3";
final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
MasterProcedureTestingUtility.createTable(procExec, tableName, null, cf1, cf2, cf3);
HTableDescriptor currentHtd = UTIL.getAdmin().getTableDescriptor(tableName);
assertEquals(3, currentHtd.getFamiliesKeys().size());
// Test 1: Modify the table descriptor
HTableDescriptor htd = new HTableDescriptor(UTIL.getAdmin().getTableDescriptor(tableName));
htd.removeFamily(cf2.getBytes());
long procId = ProcedureTestingUtility.submitAndWait(procExec, new ModifyTableProcedure(procExec.getEnvironment(), htd));
ProcedureTestingUtility.assertProcNotFailed(procExec.getResult(procId));
currentHtd = UTIL.getAdmin().getTableDescriptor(tableName);
assertEquals(2, currentHtd.getFamiliesKeys().size());
assertFalse(currentHtd.hasFamily(cf2.getBytes()));
// Test 2: Modify the table descriptor offline
UTIL.getAdmin().disableTable(tableName);
ProcedureTestingUtility.waitNoProcedureRunning(procExec);
HTableDescriptor htd2 = new HTableDescriptor(UTIL.getAdmin().getTableDescriptor(tableName));
htd2.removeFamily(cf3.getBytes());
// Disable Sanity check
htd2.setConfiguration("hbase.table.sanity.checks", Boolean.FALSE.toString());
long procId2 = ProcedureTestingUtility.submitAndWait(procExec, new ModifyTableProcedure(procExec.getEnvironment(), htd2));
ProcedureTestingUtility.assertProcNotFailed(procExec.getResult(procId2));
currentHtd = UTIL.getAdmin().getTableDescriptor(tableName);
assertEquals(1, currentHtd.getFamiliesKeys().size());
assertFalse(currentHtd.hasFamily(cf3.getBytes()));
//Removing the last family will fail
HTableDescriptor htd3 = new HTableDescriptor(UTIL.getAdmin().getTableDescriptor(tableName));
htd3.removeFamily(cf1.getBytes());
long procId3 = ProcedureTestingUtility.submitAndWait(procExec, new ModifyTableProcedure(procExec.getEnvironment(), htd3));
final ProcedureInfo result = procExec.getResult(procId3);
assertEquals(true, result.isFailed());
Throwable cause = ProcedureTestingUtility.getExceptionCause(result);
assertTrue("expected DoNotRetryIOException, got " + cause, cause instanceof DoNotRetryIOException);
assertEquals(1, currentHtd.getFamiliesKeys().size());
assertTrue(currentHtd.hasFamily(cf1.getBytes()));
}
use of org.apache.hadoop.hbase.ProcedureInfo in project hbase by apache.
the class TestProcedureAdmin method testListProcedure.
@Test(timeout = 60000)
public void testListProcedure() throws Exception {
final TableName tableName = TableName.valueOf(name.getMethodName());
final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
MasterProcedureTestingUtility.createTable(procExec, tableName, null, "f");
ProcedureTestingUtility.waitNoProcedureRunning(procExec);
ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExec, true);
long procId = procExec.submitProcedure(new DisableTableProcedure(procExec.getEnvironment(), tableName, false));
// Wait for one step to complete
ProcedureTestingUtility.waitProcedure(procExec, procId);
List<ProcedureInfo> listProcedures = procExec.listProcedures();
assertTrue(listProcedures.size() >= 1);
boolean found = false;
for (ProcedureInfo procInfo : listProcedures) {
if (procInfo.getProcId() == procId) {
assertTrue(procInfo.getProcState() == ProcedureState.RUNNABLE);
found = true;
} else {
assertTrue(procInfo.getProcState() == ProcedureState.FINISHED);
}
}
assertTrue(found);
ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExec, false);
ProcedureTestingUtility.restart(procExec);
ProcedureTestingUtility.waitNoProcedureRunning(procExec);
ProcedureTestingUtility.assertProcNotFailed(procExec, procId);
listProcedures = procExec.listProcedures();
for (ProcedureInfo procInfo : listProcedures) {
assertTrue(procInfo.getProcState() == ProcedureState.FINISHED);
}
}
use of org.apache.hadoop.hbase.ProcedureInfo in project hbase by apache.
the class TestDisableTableProcedure method testDisableTableMultipleTimes.
@Test(timeout = 60000)
public void testDisableTableMultipleTimes() throws Exception {
final TableName tableName = TableName.valueOf(name.getMethodName());
final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
MasterProcedureTestingUtility.createTable(procExec, tableName, null, "f1", "f2");
// Disable the table
long procId1 = procExec.submitProcedure(new DisableTableProcedure(procExec.getEnvironment(), tableName, false));
// Wait the completion
ProcedureTestingUtility.waitProcedure(procExec, procId1);
ProcedureTestingUtility.assertProcNotFailed(procExec, procId1);
MasterProcedureTestingUtility.validateTableIsDisabled(UTIL.getHBaseCluster().getMaster(), tableName);
// Disable the table again - expect failure
long procId2 = procExec.submitProcedure(new DisableTableProcedure(procExec.getEnvironment(), tableName, false));
// Wait the completion
ProcedureTestingUtility.waitProcedure(procExec, procId2);
ProcedureInfo result = procExec.getResult(procId2);
assertTrue(result.isFailed());
LOG.debug("Disable failed with exception: " + result.getExceptionFullMessage());
assertTrue(ProcedureTestingUtility.getExceptionCause(result) instanceof TableNotEnabledException);
// Disable the table - expect failure from ProcedurePrepareLatch
try {
final ProcedurePrepareLatch prepareLatch = new ProcedurePrepareLatch.CompatibilityLatch();
long procId3 = procExec.submitProcedure(new DisableTableProcedure(procExec.getEnvironment(), tableName, false, prepareLatch));
prepareLatch.await();
Assert.fail("Disable should throw exception through latch.");
} catch (TableNotEnabledException tnee) {
// Expected
LOG.debug("Disable failed with expected exception.");
}
// Disable the table again with skipping table state check flag (simulate recovery scenario)
long procId4 = procExec.submitProcedure(new DisableTableProcedure(procExec.getEnvironment(), tableName, true));
// Wait the completion
ProcedureTestingUtility.waitProcedure(procExec, procId4);
ProcedureTestingUtility.assertProcNotFailed(procExec, procId4);
MasterProcedureTestingUtility.validateTableIsDisabled(UTIL.getHBaseCluster().getMaster(), tableName);
}
Aggregations