use of org.apache.hadoop.hbase.NamespaceDescriptor in project hbase by apache.
the class TestCreateNamespaceProcedure method testCreateSameNamespaceTwice.
@Test
public void testCreateSameNamespaceTwice() throws Exception {
final NamespaceDescriptor nsd = NamespaceDescriptor.create("testCreateSameNamespaceTwice").build();
final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
long procId1 = procExec.submitProcedure(new CreateNamespaceProcedure(procExec.getEnvironment(), nsd));
// Wait the completion
ProcedureTestingUtility.waitProcedure(procExec, procId1);
ProcedureTestingUtility.assertProcNotFailed(procExec, procId1);
// Create the namespace that exists
long procId2 = procExec.submitProcedure(new CreateNamespaceProcedure(procExec.getEnvironment(), nsd));
// Wait the completion
ProcedureTestingUtility.waitProcedure(procExec, procId2);
// Second create should fail with NamespaceExistException
Procedure<?> result = procExec.getResult(procId2);
assertTrue(result.isFailed());
LOG.debug("Create namespace failed with exception: " + result.getException());
assertTrue(ProcedureTestingUtility.getExceptionCause(result) instanceof NamespaceExistException);
}
use of org.apache.hadoop.hbase.NamespaceDescriptor in project hbase by apache.
the class TestCreateNamespaceProcedure method testRecoveryAndDoubleExecution.
@Test
public void testRecoveryAndDoubleExecution() throws Exception {
final NamespaceDescriptor nsd = NamespaceDescriptor.create("testRecoveryAndDoubleExecution").build();
final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
ProcedureTestingUtility.waitNoProcedureRunning(procExec);
ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExec, true);
// Start the CreateNamespace procedure && kill the executor
long procId = procExec.submitProcedure(new CreateNamespaceProcedure(procExec.getEnvironment(), nsd));
// Restart the executor and execute the step twice
MasterProcedureTestingUtility.testRecoveryAndDoubleExecution(procExec, procId);
// Validate the creation of namespace
ProcedureTestingUtility.assertProcNotFailed(procExec, procId);
validateNamespaceCreated(nsd);
}
use of org.apache.hadoop.hbase.NamespaceDescriptor in project hbase by apache.
the class TestCreateNamespaceProcedure method testCreateSystemNamespace.
@Test
public void testCreateSystemNamespace() throws Exception {
final NamespaceDescriptor nsd = UTIL.getAdmin().getNamespaceDescriptor(NamespaceDescriptor.SYSTEM_NAMESPACE.getName());
final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
long procId = procExec.submitProcedure(new CreateNamespaceProcedure(procExec.getEnvironment(), nsd));
// Wait the completion
ProcedureTestingUtility.waitProcedure(procExec, procId);
Procedure<?> result = procExec.getResult(procId);
assertTrue(result.isFailed());
LOG.debug("Create namespace failed with exception: " + result.getException());
assertTrue(ProcedureTestingUtility.getExceptionCause(result) instanceof NamespaceExistException);
}
use of org.apache.hadoop.hbase.NamespaceDescriptor in project hbase by apache.
the class TestCreateNamespaceProcedure method testRollbackAndDoubleExecution.
@Test
public void testRollbackAndDoubleExecution() throws Exception {
final NamespaceDescriptor nsd = NamespaceDescriptor.create("testRollbackAndDoubleExecution").build();
final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
ProcedureTestingUtility.waitNoProcedureRunning(procExec);
ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExec, true);
// Start the CreateNamespace procedure && kill the executor
long procId = procExec.submitProcedure(new CreateNamespaceProcedure(procExec.getEnvironment(), nsd));
// failing before CREATE_NAMESPACE_CREATE_DIRECTORY
int lastStep = 2;
MasterProcedureTestingUtility.testRollbackAndDoubleExecution(procExec, procId, lastStep);
// Validate the non-existence of namespace
try {
NamespaceDescriptor nsDescriptor = UTIL.getAdmin().getNamespaceDescriptor(nsd.getName());
assertNull(nsDescriptor);
} catch (NamespaceNotFoundException nsnfe) {
// Expected
LOG.info("The namespace " + nsd.getName() + " is not created.");
}
}
use of org.apache.hadoop.hbase.NamespaceDescriptor in project hbase by apache.
the class TestDeleteNamespaceProcedure method createNamespaceForTesting.
private void createNamespaceForTesting(final String namespaceName) throws Exception {
final NamespaceDescriptor nsd = NamespaceDescriptor.create(namespaceName).build();
final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
long procId = procExec.submitProcedure(new CreateNamespaceProcedure(procExec.getEnvironment(), nsd));
// Wait the completion
ProcedureTestingUtility.waitProcedure(procExec, procId);
ProcedureTestingUtility.assertProcNotFailed(procExec, procId);
}
Aggregations