use of org.apache.hadoop.hbase.client.TableDescriptor in project hbase by apache.
the class TestFSTableDescriptorForceCreation method testShouldNotCreateTheSameTableDescriptorIfForcefulCreationIsFalse.
@Test
public void testShouldNotCreateTheSameTableDescriptorIfForcefulCreationIsFalse() throws IOException {
final String name = this.name.getMethodName();
FileSystem fs = FileSystem.get(UTIL.getConfiguration());
// Cleanup old tests if any detritus laying around.
Path rootdir = new Path(UTIL.getDataTestDir(), name);
FSTableDescriptors fstd = new FSTableDescriptors(fs, rootdir);
TableDescriptor htd = TableDescriptorBuilder.newBuilder(TableName.valueOf(name)).build();
fstd.update(htd);
assertFalse("Should not create new table descriptor", fstd.createTableDescriptor(htd, false));
}
use of org.apache.hadoop.hbase.client.TableDescriptor in project hbase by apache.
the class TestColumnFamilyDescriptorDefaultVersions method testCreateTableWithDefaultFromConf.
@Test
public void testCreateTableWithDefaultFromConf() throws Exception {
TEST_UTIL.shutdownMiniCluster();
TEST_UTIL.getConfiguration().setInt("hbase.column.max.version", 3);
TEST_UTIL.startMiniCluster(1);
Admin admin = TEST_UTIL.getAdmin();
// Create a table with one family
TableDescriptor tableDescriptor = TableDescriptorBuilder.newBuilder(TABLE_NAME).setColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(FAMILY).setMaxVersions(TEST_UTIL.getConfiguration().getInt("hbase.column.max.version", 1)).build()).build();
admin.createTable(tableDescriptor);
admin.disableTable(TABLE_NAME);
try {
// Verify the column descriptor
verifyHColumnDescriptor(3, TABLE_NAME, FAMILY);
} finally {
admin.deleteTable(TABLE_NAME);
}
}
use of org.apache.hadoop.hbase.client.TableDescriptor in project hbase by apache.
the class TestColumnFamilyDescriptorDefaultVersions method testCreateTableWithSetVersion.
@Test
public void testCreateTableWithSetVersion() throws Exception {
TEST_UTIL.shutdownMiniCluster();
TEST_UTIL.getConfiguration().setInt("hbase.column.max.version", 3);
TEST_UTIL.startMiniCluster(1);
Admin admin = TEST_UTIL.getAdmin();
// Create a table with one family
TableDescriptor tableDescriptor = TableDescriptorBuilder.newBuilder(TABLE_NAME).setColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(FAMILY).setMaxVersions(5).build()).build();
admin.createTable(tableDescriptor);
admin.disableTable(TABLE_NAME);
try {
// Verify the column descriptor
verifyHColumnDescriptor(5, TABLE_NAME, FAMILY);
} finally {
admin.deleteTable(TABLE_NAME);
}
}
use of org.apache.hadoop.hbase.client.TableDescriptor in project hbase by apache.
the class TestColumnFamilyDescriptorDefaultVersions method testCreateTableWithDefault.
@Test
public void testCreateTableWithDefault() throws IOException {
Admin admin = TEST_UTIL.getAdmin();
// Create a table with one family
TableDescriptor tableDescriptor = TableDescriptorBuilder.newBuilder(TABLE_NAME).setColumnFamily(ColumnFamilyDescriptorBuilder.of(FAMILY)).build();
admin.createTable(tableDescriptor);
admin.disableTable(TABLE_NAME);
try {
// Verify the column descriptor
verifyHColumnDescriptor(1, TABLE_NAME, FAMILY);
} finally {
admin.deleteTable(TABLE_NAME);
}
}
use of org.apache.hadoop.hbase.client.TableDescriptor in project hbase by apache.
the class TestColumnFamilyDescriptorDefaultVersions method verifyHColumnDescriptor.
private void verifyHColumnDescriptor(int expected, final TableName tableName, final byte[]... families) throws IOException {
Admin admin = TEST_UTIL.getAdmin();
// Verify descriptor from master
TableDescriptor htd = admin.getDescriptor(tableName);
ColumnFamilyDescriptor[] hcds = htd.getColumnFamilies();
verifyColumnFamilyDescriptor(expected, hcds, tableName, families);
// Verify descriptor from HDFS
MasterFileSystem mfs = TEST_UTIL.getMiniHBaseCluster().getMaster().getMasterFileSystem();
Path tableDir = CommonFSUtils.getTableDir(mfs.getRootDir(), tableName);
TableDescriptor td = FSTableDescriptors.getTableDescriptorFromFs(mfs.getFileSystem(), tableDir);
hcds = td.getColumnFamilies();
verifyColumnFamilyDescriptor(expected, hcds, tableName, families);
}
Aggregations