use of org.apache.hadoop.hbase.HTableDescriptor in project hbase by apache.
the class TestAsyncTableAdminApi method testAddColumnFamily.
@Test
public void testAddColumnFamily() throws IOException {
final TableName tableName = TableName.valueOf(name.getMethodName());
// Create a table with two families
HTableDescriptor baseHtd = new HTableDescriptor(tableName);
baseHtd.addFamily(new HColumnDescriptor(FAMILY_0));
admin.createTable(baseHtd).join();
admin.disableTable(tableName).join();
try {
// Verify the table descriptor
verifyTableDescriptor(tableName, FAMILY_0);
// Modify the table removing one family and verify the descriptor
admin.addColumnFamily(tableName, new HColumnDescriptor(FAMILY_1)).join();
verifyTableDescriptor(tableName, FAMILY_0, FAMILY_1);
} finally {
admin.deleteTable(tableName);
}
}
use of org.apache.hadoop.hbase.HTableDescriptor in project hbase by apache.
the class TestAsyncTableAdminApi method testDisableCatalogTable.
@Test(timeout = 300000)
public void testDisableCatalogTable() throws Exception {
try {
this.admin.disableTable(TableName.META_TABLE_NAME).join();
fail("Expected to throw ConstraintException");
} catch (Exception e) {
}
// Before the fix for HBASE-6146, the below table creation was failing as the hbase:meta table
// actually getting disabled by the disableTable() call.
HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(name.getMethodName().getBytes()));
HColumnDescriptor hcd = new HColumnDescriptor("cf1".getBytes());
htd.addFamily(hcd);
admin.createTable(htd).join();
}
use of org.apache.hadoop.hbase.HTableDescriptor in project hbase by apache.
the class TestAsyncTableAdminApi method testCreateTableWithEmptyRowInTheSplitKeys.
@Test(timeout = 300000)
public void testCreateTableWithEmptyRowInTheSplitKeys() throws IOException {
byte[] tableName = Bytes.toBytes(name.getMethodName());
byte[][] splitKeys = new byte[3][];
splitKeys[0] = "region1".getBytes();
splitKeys[1] = HConstants.EMPTY_BYTE_ARRAY;
splitKeys[2] = "region2".getBytes();
HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(tableName));
desc.addFamily(new HColumnDescriptor("col"));
try {
admin.createTable(desc, splitKeys).join();
fail("Test case should fail as empty split key is passed.");
} catch (CompletionException e) {
assertTrue(e.getCause() instanceof IllegalArgumentException);
}
}
use of org.apache.hadoop.hbase.HTableDescriptor in project hbase by apache.
the class TestAsyncTableAdminApi method testDeleteSameColumnFamilyTwice.
@Test
public void testDeleteSameColumnFamilyTwice() throws IOException {
final TableName tableName = TableName.valueOf(name.getMethodName());
// Create a table with two families
HTableDescriptor baseHtd = new HTableDescriptor(tableName);
baseHtd.addFamily(new HColumnDescriptor(FAMILY_0));
baseHtd.addFamily(new HColumnDescriptor(FAMILY_1));
admin.createTable(baseHtd).join();
admin.disableTable(tableName).join();
try {
// Verify the table descriptor
verifyTableDescriptor(tableName, FAMILY_0, FAMILY_1);
// Modify the table removing one family and verify the descriptor
admin.deleteColumnFamily(tableName, FAMILY_1).join();
verifyTableDescriptor(tableName, FAMILY_0);
try {
// Delete again - expect failure
admin.deleteColumnFamily(tableName, FAMILY_1).join();
Assert.fail("Delete a non-exist column family should fail");
} catch (Exception e) {
// Expected.
}
} finally {
admin.deleteTable(tableName).join();
}
}
use of org.apache.hadoop.hbase.HTableDescriptor in project hbase by apache.
the class TestAsyncTableAdminApi method testAddSameColumnFamilyTwice.
@Test
public void testAddSameColumnFamilyTwice() throws Exception {
final TableName tableName = TableName.valueOf(name.getMethodName());
// Create a table with one families
HTableDescriptor baseHtd = new HTableDescriptor(tableName);
baseHtd.addFamily(new HColumnDescriptor(FAMILY_0));
admin.createTable(baseHtd).join();
admin.disableTable(tableName).join();
try {
// Verify the table descriptor
verifyTableDescriptor(tableName, FAMILY_0);
// Modify the table removing one family and verify the descriptor
this.admin.addColumnFamily(tableName, new HColumnDescriptor(FAMILY_1)).join();
verifyTableDescriptor(tableName, FAMILY_0, FAMILY_1);
try {
// Add same column family again - expect failure
this.admin.addColumnFamily(tableName, new HColumnDescriptor(FAMILY_1)).join();
Assert.fail("Delete a non-exist column family should fail");
} catch (Exception e) {
// Expected.
}
} finally {
admin.deleteTable(tableName).join();
}
}
Aggregations