use of org.apache.hadoop.hbase.NamespaceDescriptor in project hbase by apache.
the class TestModifyNamespaceProcedure method testModifyNamespace.
@Test
public void testModifyNamespace() throws Exception {
final NamespaceDescriptor nsd = NamespaceDescriptor.create("testModifyNamespace").build();
final String nsKey1 = "hbase.namespace.quota.maxregions";
final String nsValue1before = "1111";
final String nsValue1after = "9999";
final String nsKey2 = "hbase.namespace.quota.maxtables";
final String nsValue2 = "10";
final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
nsd.setConfiguration(nsKey1, nsValue1before);
createNamespaceForTesting(nsd);
// Before modify
NamespaceDescriptor currentNsDescriptor = UTIL.getAdmin().getNamespaceDescriptor(nsd.getName());
assertEquals(nsValue1before, currentNsDescriptor.getConfigurationValue(nsKey1));
assertNull(currentNsDescriptor.getConfigurationValue(nsKey2));
// Update
nsd.setConfiguration(nsKey1, nsValue1after);
nsd.setConfiguration(nsKey2, nsValue2);
long procId1 = procExec.submitProcedure(new ModifyNamespaceProcedure(procExec.getEnvironment(), nsd));
// Wait the completion
ProcedureTestingUtility.waitProcedure(procExec, procId1);
ProcedureTestingUtility.assertProcNotFailed(procExec, procId1);
// Verify the namespace is updated.
currentNsDescriptor = UTIL.getAdmin().getNamespaceDescriptor(nsd.getName());
assertEquals(nsValue1after, nsd.getConfigurationValue(nsKey1));
assertEquals(nsValue2, currentNsDescriptor.getConfigurationValue(nsKey2));
}
use of org.apache.hadoop.hbase.NamespaceDescriptor in project hbase by apache.
the class TestModifyNamespaceProcedure method testModifyNamespaceWithInvalidTableCount.
@Test
public void testModifyNamespaceWithInvalidTableCount() throws Exception {
final NamespaceDescriptor nsd = NamespaceDescriptor.create("testModifyNamespaceWithInvalidTableCount").build();
final String nsKey = "hbase.namespace.quota.maxtables";
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);
}
use of org.apache.hadoop.hbase.NamespaceDescriptor in project hbase by apache.
the class TestModifyNamespaceProcedure method testRecoveryAndDoubleExecution.
@Test
public void testRecoveryAndDoubleExecution() throws Exception {
final NamespaceDescriptor nsd = NamespaceDescriptor.create("testRecoveryAndDoubleExecution").build();
final String nsKey = "foo";
final String nsValue = "bar";
final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
createNamespaceForTesting(nsd);
ProcedureTestingUtility.waitNoProcedureRunning(procExec);
ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExec, true);
// Modify
nsd.setConfiguration(nsKey, nsValue);
// Start the Modify procedure && kill the executor
long procId = procExec.submitProcedure(new ModifyNamespaceProcedure(procExec.getEnvironment(), nsd));
// Restart the executor and execute the step twice
MasterProcedureTestingUtility.testRecoveryAndDoubleExecution(procExec, procId);
ProcedureTestingUtility.assertProcNotFailed(procExec, procId);
// Validate
NamespaceDescriptor currentNsDescriptor = UTIL.getAdmin().getNamespaceDescriptor(nsd.getName());
assertEquals(nsValue, currentNsDescriptor.getConfigurationValue(nsKey));
}
use of org.apache.hadoop.hbase.NamespaceDescriptor in project hbase by apache.
the class TestSimpleRegionNormalizerOnCluster method testHonorsNamespaceFilter.
@Test
public void testHonorsNamespaceFilter() throws Exception {
final NamespaceDescriptor namespaceDescriptor = NamespaceDescriptor.create("ns").build();
final TableName tn1 = TableName.valueOf("ns", name.getMethodName());
final TableName tn2 = TableName.valueOf(name.getMethodName());
try {
admin.createNamespace(namespaceDescriptor).get();
final int tn1RegionCount = createTableBegsSplit(tn1, true, false);
final int tn2RegionCount = createTableBegsSplit(tn2, true, false);
final NormalizeTableFilterParams ntfp = new NormalizeTableFilterParams.Builder().namespace("ns").build();
assertFalse(admin.normalizerSwitch(true).get());
assertTrue(admin.normalize(ntfp).get());
waitForTableRegionCount(tn1, greaterThanOrEqualTo(tn1RegionCount + 1));
// confirm that tn1 has (tn1RegionCount + 1) number of regions.
// tn2 has tn2RegionCount number of regions because it's not a member of the target namespace.
assertEquals(tn1 + " should have split.", tn1RegionCount + 1, getRegionCount(tn1));
waitForTableRegionCount(tn2, comparesEqualTo(tn2RegionCount));
} finally {
dropIfExists(tn1);
dropIfExists(tn2);
}
}
use of org.apache.hadoop.hbase.NamespaceDescriptor in project hbase by apache.
the class TestCreateNamespaceProcedure method testCreateNamespace.
@Test
public void testCreateNamespace() throws Exception {
final NamespaceDescriptor nsd = NamespaceDescriptor.create("testCreateNamespace").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);
validateNamespaceCreated(nsd);
}
Aggregations