use of co.cask.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 co.cask.cdap.data2.util.TableId in project cdap by caskdata.
the class LevelDBStreamConsumerStateStoreFactory method create.
@Override
public synchronized StreamConsumerStateStore create(StreamConfig streamConfig) throws IOException {
NamespaceId namespace = streamConfig.getStreamId().getParent();
TableId tableId = StreamUtils.getStateStoreTableId(namespace);
getLevelDBTableAdmin(tableId).create();
String levelDBTableName = PrefixedNamespaces.namespace(cConf, tableId.getNamespace(), tableId.getTableName());
LevelDBTableCore coreTable = new LevelDBTableCore(levelDBTableName, tableService);
return new LevelDBStreamConsumerStateStore(streamConfig, coreTable);
}
use of co.cask.cdap.data2.util.TableId in project cdap by caskdata.
the class LevelDBStreamConsumerStateStoreFactory method getLevelDBTableAdmin.
private LevelDBTableAdmin getLevelDBTableAdmin(TableId tableId) throws IOException {
DatasetProperties props = TableProperties.builder().setColumnFamily("t").build();
LevelDBTableDefinition tableDefinition = new LevelDBTableDefinition("tableDefinition");
DatasetSpecification spec = tableDefinition.configure(tableId.getTableName(), props);
return new LevelDBTableAdmin(DatasetContext.from(tableId.getNamespace()), spec, tableService, cConf);
}
use of co.cask.cdap.data2.util.TableId in project cdap by caskdata.
the class LevelDBStreamFileConsumerFactory method create.
@Override
protected StreamConsumer create(TableId tableId, StreamConfig streamConfig, ConsumerConfig consumerConfig, StreamConsumerStateStore stateStore, StreamConsumerState beginConsumerState, FileReader<StreamEventOffset, Iterable<StreamFileOffset>> reader, @Nullable ReadFilter extraFilter) throws IOException {
String tableName = fromTableId(tableId);
tableService.ensureTableExists(tableName);
LevelDBTableCore tableCore = new LevelDBTableCore(tableName, tableService);
Object dbLock = getDBLock(tableName);
return new LevelDBStreamFileConsumer(cConf, streamConfig, consumerConfig, reader, stateStore, beginConsumerState, extraFilter, tableCore, dbLock);
}
use of co.cask.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);
}
}
}
Aggregations