Search in sources :

Example 31 with NamespaceDescriptor

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

the class TestCreateNamespaceProcedure method testCreateNamespaceWithInvalidTableCount.

@Test
public void testCreateNamespaceWithInvalidTableCount() throws Exception {
    final NamespaceDescriptor nsd = NamespaceDescriptor.create("testCreateNamespaceWithInvalidTableCount").build();
    final String nsKey = "hbase.namespace.quota.maxtables";
    final String nsValue = "-1";
    final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
    nsd.setConfiguration(nsKey, nsValue);
    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 ConstraintException);
}
Also used : NamespaceDescriptor(org.apache.hadoop.hbase.NamespaceDescriptor) ConstraintException(org.apache.hadoop.hbase.constraint.ConstraintException) Test(org.junit.Test)

Example 32 with NamespaceDescriptor

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

the class TestDeleteNamespaceProcedure method testRollbackAndDoubleExecution.

@Test
public void testRollbackAndDoubleExecution() throws Exception {
    final String namespaceName = "testRollbackAndDoubleExecution";
    final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
    createNamespaceForTesting(namespaceName);
    ProcedureTestingUtility.waitNoProcedureRunning(procExec);
    ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExec, true);
    // Start the DeleteNamespace procedure && kill the executor
    long procId = procExec.submitProcedure(new DeleteNamespaceProcedure(procExec.getEnvironment(), namespaceName));
    // failing before DELETE_NAMESPACE_DELETE_FROM_NS_TABLE
    int lastStep = 2;
    MasterProcedureTestingUtility.testRollbackAndDoubleExecution(procExec, procId, lastStep);
    // Validate the namespace still exists
    NamespaceDescriptor createdNsDescriptor = UTIL.getAdmin().getNamespaceDescriptor(namespaceName);
    assertNotNull(createdNsDescriptor);
}
Also used : NamespaceDescriptor(org.apache.hadoop.hbase.NamespaceDescriptor) Test(org.junit.Test)

Example 33 with NamespaceDescriptor

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

the class TestMasterObserverPostCalls method testPostCreateNamespace.

@Test
public void testPostCreateNamespace() throws IOException {
    final Admin admin = UTIL.getAdmin();
    final String ns = "postcreatens";
    HMaster master = UTIL.getMiniHBaseCluster().getMaster();
    MasterObserverForTest observer = master.getMasterCoprocessorHost().findCoprocessor(MasterObserverForTest.class);
    // Validate that the post hook is called
    int preCount = observer.postHookCalls.get();
    NamespaceDescriptor nsDesc = NamespaceDescriptor.create(ns).build();
    admin.createNamespace(nsDesc);
    int postCount = observer.postHookCalls.get();
    assertEquals("Expected 1 invocation of postModifyNamespace", preCount + 1, postCount);
    // Then, validate that it's not called when the call fails
    preCount = observer.postHookCalls.get();
    try {
        admin.createNamespace(nsDesc);
        fail("Creating an already present namespace should fail");
    } catch (IOException e) {
    // Pass
    }
    postCount = observer.postHookCalls.get();
    assertEquals("Expected no invocations of postModifyNamespace when the operation fails", preCount, postCount);
}
Also used : HMaster(org.apache.hadoop.hbase.master.HMaster) NamespaceDescriptor(org.apache.hadoop.hbase.NamespaceDescriptor) IOException(java.io.IOException) Admin(org.apache.hadoop.hbase.client.Admin) Test(org.junit.Test)

Example 34 with NamespaceDescriptor

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

the class TestMasterObserverPostCalls method testPostModifyNamespace.

@Test
public void testPostModifyNamespace() throws IOException {
    final Admin admin = UTIL.getAdmin();
    final String ns = "postmodifyns";
    NamespaceDescriptor nsDesc = NamespaceDescriptor.create(ns).build();
    admin.createNamespace(nsDesc);
    HMaster master = UTIL.getMiniHBaseCluster().getMaster();
    MasterObserverForTest observer = master.getMasterCoprocessorHost().findCoprocessor(MasterObserverForTest.class);
    int preCount = observer.postHookCalls.get();
    try {
        admin.modifyNamespace(NamespaceDescriptor.create("nonexistent").build());
        fail("Modifying a missing namespace should fail");
    } catch (IOException e) {
    // Pass
    }
    int postCount = observer.postHookCalls.get();
    assertEquals("Expected no invocations of postModifyNamespace when the operation fails", preCount, postCount);
    // Validate that the postDeletNS hook is invoked
    preCount = observer.postHookCalls.get();
    admin.modifyNamespace(NamespaceDescriptor.create(nsDesc).addConfiguration("foo", "bar").build());
    postCount = observer.postHookCalls.get();
    assertEquals("Expected 1 invocation of postModifyNamespace", preCount + 1, postCount);
}
Also used : HMaster(org.apache.hadoop.hbase.master.HMaster) NamespaceDescriptor(org.apache.hadoop.hbase.NamespaceDescriptor) IOException(java.io.IOException) Admin(org.apache.hadoop.hbase.client.Admin) Test(org.junit.Test)

Example 35 with NamespaceDescriptor

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

the class TestModifyNamespaceProcedure method testModifyNamespaceWithInvalidRegionCount.

@Test
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);
    Procedure<?> result = procExec.getResult(procId);
    assertTrue(result.isFailed());
    LOG.debug("Modify namespace failed with exception: " + result.getException());
    assertTrue(ProcedureTestingUtility.getExceptionCause(result) instanceof ConstraintException);
}
Also used : NamespaceDescriptor(org.apache.hadoop.hbase.NamespaceDescriptor) ConstraintException(org.apache.hadoop.hbase.constraint.ConstraintException) Test(org.junit.Test)

Aggregations

NamespaceDescriptor (org.apache.hadoop.hbase.NamespaceDescriptor)97 Test (org.junit.Test)51 TableName (org.apache.hadoop.hbase.TableName)26 IOException (java.io.IOException)17 Admin (org.apache.hadoop.hbase.client.Admin)15 TableDescriptor (org.apache.hadoop.hbase.client.TableDescriptor)13 ColumnFamilyDescriptor (org.apache.hadoop.hbase.client.ColumnFamilyDescriptor)11 TableDescriptorBuilder (org.apache.hadoop.hbase.client.TableDescriptorBuilder)11 QuotaExceededException (org.apache.hadoop.hbase.quotas.QuotaExceededException)9 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)8 Table (org.apache.hadoop.hbase.client.Table)8 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)7 NamespaceNotFoundException (org.apache.hadoop.hbase.NamespaceNotFoundException)7 Connection (org.apache.hadoop.hbase.client.Connection)7 ConstraintException (org.apache.hadoop.hbase.constraint.ConstraintException)7 RestoreSnapshotException (org.apache.hadoop.hbase.snapshot.RestoreSnapshotException)7 KeeperException (org.apache.zookeeper.KeeperException)7 ArrayList (java.util.ArrayList)6 ExecutionException (java.util.concurrent.ExecutionException)5 NamespaceExistException (org.apache.hadoop.hbase.NamespaceExistException)5