Search in sources :

Example 21 with TableExistsException

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

the class TestSCVFWithMiniCluster method create.

private static void create(Admin admin, TableName tableName, byte[]... families) throws IOException {
    TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(tableName);
    for (byte[] family : families) {
        ColumnFamilyDescriptor familyDescriptor = ColumnFamilyDescriptorBuilder.newBuilder(family).setMaxVersions(1).setCompressionType(Algorithm.GZ).build();
        builder.setColumnFamily(familyDescriptor);
    }
    try {
        admin.createTable(builder.build());
    } catch (TableExistsException tee) {
    /* Ignore */
    }
}
Also used : TableExistsException(org.apache.hadoop.hbase.TableExistsException) TableDescriptorBuilder(org.apache.hadoop.hbase.client.TableDescriptorBuilder) ColumnFamilyDescriptor(org.apache.hadoop.hbase.client.ColumnFamilyDescriptor)

Example 22 with TableExistsException

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

the class TestRSGroupsAdmin1 method testNotMoveTableToNullRSGroupWhenCreatingExistingTable.

@Test
public void testNotMoveTableToNullRSGroupWhenCreatingExistingTable() throws Exception {
    // Trigger
    TableName tn1 = TableName.valueOf("t1");
    TEST_UTIL.createTable(tn1, "cf1");
    try {
        // Create an existing table to trigger HBASE-21866
        TEST_UTIL.createTable(tn1, "cf1");
    } catch (TableExistsException teex) {
    // Ignore
    }
    // Wait then verify
    // Could not verify until the rollback of CreateTableProcedure is done
    // (that is, the coprocessor finishes its work),
    // or the table is still in the "default" rsgroup even though HBASE-21866
    // is not fixed.
    TEST_UTIL.waitFor(5000, new Waiter.Predicate<Exception>() {

        @Override
        public boolean evaluate() throws Exception {
            return MASTER.getMasterProcedureExecutor().getActiveExecutorCount() == 0;
        }
    });
    Set<TableName> tables = Sets.newHashSet(ADMIN.listTablesInRSGroup(RSGroupInfo.DEFAULT_GROUP));
    assertTrue("Table 't1' must be in 'default' rsgroup", tables.contains(tn1));
    // Cleanup
    TEST_UTIL.deleteTable(tn1);
}
Also used : TableName(org.apache.hadoop.hbase.TableName) TableExistsException(org.apache.hadoop.hbase.TableExistsException) Waiter(org.apache.hadoop.hbase.Waiter) TableNotFoundException(org.apache.hadoop.hbase.TableNotFoundException) TableExistsException(org.apache.hadoop.hbase.TableExistsException) IOException(java.io.IOException) ConstraintException(org.apache.hadoop.hbase.constraint.ConstraintException) Test(org.junit.Test)

Aggregations

TableExistsException (org.apache.hadoop.hbase.TableExistsException)22 TableName (org.apache.hadoop.hbase.TableName)9 IOException (java.io.IOException)7 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)7 Test (org.junit.Test)7 HColumnDescriptor (org.apache.hadoop.hbase.HColumnDescriptor)5 TableNotFoundException (org.apache.hadoop.hbase.TableNotFoundException)4 TableDescriptorBuilder (org.apache.hadoop.hbase.client.TableDescriptorBuilder)3 Map (java.util.Map)2 Admin (org.apache.hadoop.hbase.client.Admin)2 ColumnFamilyDescriptor (org.apache.hadoop.hbase.client.ColumnFamilyDescriptor)2 HBaseAdmin (org.apache.hadoop.hbase.client.HBaseAdmin)2 TableDescriptor (org.apache.hadoop.hbase.client.TableDescriptor)2 Stopwatch (com.google.common.base.Stopwatch)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 SQLException (java.sql.SQLException)1 HashMap (java.util.HashMap)1 TreeMap (java.util.TreeMap)1