Search in sources :

Example 76 with NamespaceDescriptor

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));
}
Also used : NamespaceDescriptor(org.apache.hadoop.hbase.NamespaceDescriptor) Test(org.junit.Test)

Example 77 with NamespaceDescriptor

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);
}
Also used : NamespaceDescriptor(org.apache.hadoop.hbase.NamespaceDescriptor) ConstraintException(org.apache.hadoop.hbase.constraint.ConstraintException) Test(org.junit.Test)

Example 78 with NamespaceDescriptor

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));
}
Also used : NamespaceDescriptor(org.apache.hadoop.hbase.NamespaceDescriptor) Test(org.junit.Test)

Example 79 with NamespaceDescriptor

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);
    }
}
Also used : TableName(org.apache.hadoop.hbase.TableName) NormalizeTableFilterParams(org.apache.hadoop.hbase.client.NormalizeTableFilterParams) TableDescriptorBuilder(org.apache.hadoop.hbase.client.TableDescriptorBuilder) NamespaceDescriptor(org.apache.hadoop.hbase.NamespaceDescriptor) Test(org.junit.Test)

Example 80 with NamespaceDescriptor

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);
}
Also used : NamespaceDescriptor(org.apache.hadoop.hbase.NamespaceDescriptor) 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