use of io.cdap.cdap.data2.util.hbase.HBaseTableUtil in project cdap by caskdata.
the class AbstractHBaseTableUtilTest method testBackwardCompatibility.
@Test
public void testBackwardCompatibility() throws IOException, InterruptedException {
HBaseTableUtil tableUtil = getTableUtil();
String tablePrefix = cConf.get(Constants.Dataset.TABLE_PREFIX);
TableId tableId = TableId.from("default", "my.dataset");
TableId hTableId = tableUtil.createHTableId(new NamespaceId(tableId.getNamespace()), tableId.getTableName());
create(tableId);
TableId resultTableId = getTableId("default", "my.dataset");
Assert.assertNotNull(resultTableId);
Assert.assertEquals("default", resultTableId.getNamespace());
Assert.assertEquals("cdap.user.my.dataset", HTableNameConverter.toHBaseTableName(tablePrefix, resultTableId));
Assert.assertEquals(getTableNameAsString(tableId), Bytes.toString(tableUtil.createTable(TEST_HBASE.getConfiguration(), hTableId).getTableDescriptor().getTableName().getName()));
drop(tableId);
tableId = TableId.from("default", "system.queue.config");
hTableId = tableUtil.createHTableId(new NamespaceId(tableId.getNamespace()), tableId.getTableName());
create(tableId);
resultTableId = getTableId("default", "system.queue.config");
Assert.assertEquals("default", resultTableId.getNamespace());
Assert.assertEquals("cdap.system.queue.config", HTableNameConverter.toHBaseTableName(tablePrefix, resultTableId));
Assert.assertEquals(getTableNameAsString(tableId), Bytes.toString(tableUtil.createTable(TEST_HBASE.getConfiguration(), hTableId).getTableDescriptor().getTableName().getName()));
drop(tableId);
tableId = TableId.from("myspace", "could.be.any.table.name");
hTableId = tableUtil.createHTableId(new NamespaceId(tableId.getNamespace()), tableId.getTableName());
createNamespace("myspace");
create(tableId);
resultTableId = getTableId("myspace", "could.be.any.table.name");
Assert.assertEquals("cdap_myspace", resultTableId.getNamespace());
Assert.assertEquals("could.be.any.table.name", HTableNameConverter.toHBaseTableName(tablePrefix, resultTableId));
Assert.assertEquals(getTableNameAsString(hTableId), Bytes.toString(tableUtil.createTable(TEST_HBASE.getConfiguration(), hTableId).getTableDescriptor().getTableName().getName()));
drop(tableId);
deleteNamespace("myspace");
}
use of io.cdap.cdap.data2.util.hbase.HBaseTableUtil in project cdap by caskdata.
the class AbstractHBaseTableUtilTest method getTableStats.
private HBaseTableUtil.TableStats getTableStats(String namespace, String tableName) throws IOException {
HBaseTableUtil tableUtil = getTableUtil();
// todo : should support custom table-prefix
TableId tableId = tableUtil.createHTableId(new NamespaceId(namespace), tableName);
Map<TableId, HBaseTableUtil.TableStats> statsMap = tableUtil.getTableStats(hAdmin);
return statsMap.get(tableId);
}
use of io.cdap.cdap.data2.util.hbase.HBaseTableUtil in project cdap by caskdata.
the class AbstractHBaseTableUtilTest method create.
private void create(TableId tableId) throws IOException {
HBaseTableUtil tableUtil = getTableUtil();
TableId htableId = tableUtil.createHTableId(new NamespaceId(tableId.getNamespace()), tableId.getTableName());
ColumnFamilyDescriptorBuilder cfdBuilder = HBaseTableUtil.getColumnFamilyDescriptorBuilder("d", hAdmin.getConfiguration());
TableDescriptorBuilder tdBuilder = HBaseTableUtil.getTableDescriptorBuilder(htableId, cConf);
tdBuilder.addColumnFamily(cfdBuilder.build());
ddlExecutor.createTableIfNotExists(tdBuilder.build(), null);
}
use of io.cdap.cdap.data2.util.hbase.HBaseTableUtil in project cdap by caskdata.
the class AbstractHBaseTableUtilTest method testHTableDescriptor.
@Test
public void testHTableDescriptor() throws IOException {
HBaseTableUtil tableUtil = getTableUtil();
TableId tableId = TableId.from("default", "test.dataset");
create(tableId);
HTableDescriptor tableDescriptor = tableUtil.getHTableDescriptor(hAdmin, tableId);
Assert.assertEquals(ProjectInfo.getVersion().toString(), tableDescriptor.getValue(HBaseTableUtil.CDAP_VERSION));
Assert.assertEquals(getPrefix(), tableDescriptor.getValue(Constants.Dataset.TABLE_PREFIX));
TableName tableName = HTableNameConverter.toTableName(getPrefix(), tableId);
ddlExecutor.disableTableIfEnabled(tableName.getNamespaceAsString(), tableName.getQualifierAsString());
tableUtil.deleteTable(ddlExecutor, tableId);
}
use of io.cdap.cdap.data2.util.hbase.HBaseTableUtil in project cdap by caskdata.
the class AbstractHBaseTableUtilTest method drop.
private void drop(TableId tableId) throws IOException {
HBaseTableUtil tableUtil = getTableUtil();
TableId hTableId = tableUtil.createHTableId(new NamespaceId(tableId.getNamespace()), tableId.getTableName());
tableUtil.dropTable(ddlExecutor, hTableId);
}
Aggregations