use of io.cdap.cdap.data2.util.TableId in project cdap by caskdata.
the class HBaseStreamConsumerStateStoreFactory method dropAllInNamespace.
@Override
public synchronized void dropAllInNamespace(NamespaceId namespace) throws IOException {
try (HBaseDDLExecutor executor = ddlExecutorFactory.get();
HBaseAdmin admin = new HBaseAdmin(hConf)) {
TableId tableId = StreamUtils.getStateStoreTableId(namespace);
TableId hbaseTableId = tableUtil.createHTableId(new NamespaceId(tableId.getNamespace()), tableId.getTableName());
if (tableUtil.tableExists(admin, hbaseTableId)) {
tableUtil.dropTable(executor, hbaseTableId);
}
}
}
use of io.cdap.cdap.data2.util.TableId in project cdap by caskdata.
the class HBaseQueueAdmin method create.
@Override
public void create(QueueName queueName, Properties properties) throws IOException {
// Queue Config needs to be on separate table, otherwise disabling the queue table would makes queue config
// not accessible by the queue region coprocessor for doing eviction.
// Create the config table first so that in case the queue table coprocessor runs, it can access the config table.
createStateStoreDataset(queueName.getFirstComponent());
TableId tableId = getDataTableId(queueName);
try (QueueDatasetAdmin dsAdmin = new QueueDatasetAdmin(tableId, hConf, cConf, tableUtil, properties)) {
dsAdmin.create();
}
}
use of io.cdap.cdap.data2.util.TableId in project cdap by caskdata.
the class HBaseQueueAdmin method dropAllInNamespace.
@Override
public void dropAllInNamespace(NamespaceId namespaceId) throws Exception {
Set<QueueConstants.QueueType> queueTypes = EnumSet.of(QueueConstants.QueueType.QUEUE, QueueConstants.QueueType.SHARDED_QUEUE);
try (HBaseDDLExecutor ddlExecutor = ddlExecutorFactory.get()) {
for (QueueConstants.QueueType queueType : queueTypes) {
// Note: The trailing "." is crucial, since otherwise nsId could match nsId1, nsIdx etc
// It's important to keep config table enabled while disabling and dropping queue tables.
final String queueTableNamePrefix = String.format("%s.%s.", NamespaceId.SYSTEM.getNamespace(), queueType);
final String hbaseNamespace = tableUtil.getHBaseNamespace(namespaceId);
final TableId configTableId = TableId.from(hbaseNamespace, getConfigTableName());
tableUtil.deleteAllInNamespace(ddlExecutor, hbaseNamespace, hConf, new Predicate<TableId>() {
@Override
public boolean apply(TableId tableId) {
// It's a bit hacky here since we know how the Dataset System names tables
return (tableId.getTableName().startsWith(queueTableNamePrefix)) && !tableId.equals(configTableId);
}
});
}
}
// Delete the state store in the namespace
DatasetId id = getStateStoreId(namespaceId.getEntityName());
if (datasetFramework.hasInstance(id)) {
datasetFramework.deleteInstance(id);
}
}
use of io.cdap.cdap.data2.util.TableId in project cdap by caskdata.
the class InMemoryStreamConsumerStateStoreFactory method create.
@Override
public synchronized StreamConsumerStateStore create(StreamConfig streamConfig) throws IOException {
NamespaceId namespace = streamConfig.getStreamId().getParent();
TableId tableId = StreamUtils.getStateStoreTableId(namespace);
InMemoryTableAdmin admin = new InMemoryTableAdmin(DatasetContext.from(tableId.getNamespace()), tableId.getTableName(), cConf);
if (!admin.exists()) {
admin.create();
}
InMemoryTable table = new NoTxInMemoryTable(DatasetContext.from(tableId.getNamespace()), tableId.getTableName(), cConf);
return new InMemoryStreamConsumerStateStore(streamConfig, table);
}
use of io.cdap.cdap.data2.util.TableId in project cdap by caskdata.
the class InMemoryStreamConsumerStateStoreFactory method dropAllInNamespace.
@Override
public synchronized void dropAllInNamespace(NamespaceId namespace) throws IOException {
TableId tableId = StreamUtils.getStateStoreTableId(namespace);
InMemoryTableAdmin admin = new InMemoryTableAdmin(DatasetContext.from(tableId.getNamespace()), tableId.getTableName(), cConf);
admin.drop();
}
Aggregations