Search in sources :

Example 1 with NamespaceExistException

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

the class TestCreateNamespaceProcedure method testCreateSystemNamespace.

@Test(timeout = 60000)
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);
    ProcedureInfo result = procExec.getResult(procId);
    assertTrue(result.isFailed());
    LOG.debug("Create namespace failed with exception: " + result.getExceptionFullMessage());
    assertTrue(ProcedureTestingUtility.getExceptionCause(result) instanceof NamespaceExistException);
}
Also used : ProcedureInfo(org.apache.hadoop.hbase.ProcedureInfo) NamespaceDescriptor(org.apache.hadoop.hbase.NamespaceDescriptor) NamespaceExistException(org.apache.hadoop.hbase.NamespaceExistException) Test(org.junit.Test)

Example 2 with NamespaceExistException

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

the class TestCreateNamespaceProcedure method testCreateSameNamespaceTwice.

@Test(timeout = 60000)
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
    ProcedureInfo result = procExec.getResult(procId2);
    assertTrue(result.isFailed());
    LOG.debug("Create namespace failed with exception: " + result.getExceptionFullMessage());
    assertTrue(ProcedureTestingUtility.getExceptionCause(result) instanceof NamespaceExistException);
}
Also used : ProcedureInfo(org.apache.hadoop.hbase.ProcedureInfo) NamespaceDescriptor(org.apache.hadoop.hbase.NamespaceDescriptor) NamespaceExistException(org.apache.hadoop.hbase.NamespaceExistException) Test(org.junit.Test)

Aggregations

NamespaceDescriptor (org.apache.hadoop.hbase.NamespaceDescriptor)2 NamespaceExistException (org.apache.hadoop.hbase.NamespaceExistException)2 ProcedureInfo (org.apache.hadoop.hbase.ProcedureInfo)2 Test (org.junit.Test)2