use of io.cdap.cdap.data2.util.TableId in project cdap by caskdata.
the class AbstractHBaseTableUtilTest method disable.
private void disable(String namespace, String tableName) throws IOException {
HBaseTableUtil tableUtil = getTableUtil();
TableId hTableId = tableUtil.createHTableId(new NamespaceId(namespace), tableName);
TableName name = HTableNameConverter.toTableName(getPrefix(), hTableId);
ddlExecutor.disableTableIfEnabled(name.getNamespaceAsString(), name.getQualifierAsString());
}
use of io.cdap.cdap.data2.util.TableId in project cdap by caskdata.
the class AbstractHBaseTableUtilTest method writeSome.
private void writeSome(String namespace, String tableName) throws IOException {
HBaseTableUtil tableUtil = getTableUtil();
TableId hTableId = tableUtil.createHTableId(new NamespaceId(namespace), tableName);
try (Table table = tableUtil.createTable(TEST_HBASE.getConfiguration(), hTableId)) {
// writing at least couple megs to reflect in "megabyte"-based metrics
for (int i = 0; i < 8; i++) {
Put put = new Put(Bytes.toBytes("row" + i));
put.add(Bytes.toBytes("d"), Bytes.toBytes("col" + i), new byte[1024 * 1024]);
table.put(put);
}
}
}
use of io.cdap.cdap.data2.util.TableId 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.TableId 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.TableId 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);
}
Aggregations