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