Search in sources :

Example 66 with TableId

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);
}
Also used : TableId(co.cask.cdap.data2.util.TableId) InMemoryTable(co.cask.cdap.data2.dataset2.lib.table.inmemory.InMemoryTable) NoTxInMemoryTable(co.cask.cdap.data2.dataset2.lib.table.inmemory.NoTxInMemoryTable) InMemoryTableAdmin(co.cask.cdap.data2.dataset2.lib.table.inmemory.InMemoryTableAdmin) NamespaceId(co.cask.cdap.proto.id.NamespaceId) NoTxInMemoryTable(co.cask.cdap.data2.dataset2.lib.table.inmemory.NoTxInMemoryTable)

Example 67 with TableId

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);
}
Also used : TableId(co.cask.cdap.data2.util.TableId) LevelDBTableCore(co.cask.cdap.data2.dataset2.lib.table.leveldb.LevelDBTableCore) NamespaceId(co.cask.cdap.proto.id.NamespaceId)

Example 68 with TableId

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);
}
Also used : LevelDBTableAdmin(co.cask.cdap.data2.dataset2.lib.table.leveldb.LevelDBTableAdmin) LevelDBTableDefinition(co.cask.cdap.data2.dataset2.lib.table.leveldb.LevelDBTableDefinition) DatasetProperties(co.cask.cdap.api.dataset.DatasetProperties) DatasetSpecification(co.cask.cdap.api.dataset.DatasetSpecification)

Example 69 with TableId

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);
}
Also used : LevelDBTableCore(co.cask.cdap.data2.dataset2.lib.table.leveldb.LevelDBTableCore)

Example 70 with TableId

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);
        }
    }
}
Also used : HBaseDDLExecutor(co.cask.cdap.spi.hbase.HBaseDDLExecutor) TableId(co.cask.cdap.data2.util.TableId) HBaseAdmin(org.apache.hadoop.hbase.client.HBaseAdmin) NamespaceId(co.cask.cdap.proto.id.NamespaceId)

Aggregations

TableId (co.cask.cdap.data2.util.TableId)100 Test (org.junit.Test)49 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)40 HRegion (org.apache.hadoop.hbase.regionserver.HRegion)39 Put (org.apache.hadoop.hbase.client.Put)34 NamespaceId (co.cask.cdap.proto.id.NamespaceId)26 Cell (org.apache.hadoop.hbase.Cell)24 Scan (org.apache.hadoop.hbase.client.Scan)24 HTableDescriptorBuilder (co.cask.cdap.data2.util.hbase.HTableDescriptorBuilder)18 RegionScanner (org.apache.hadoop.hbase.regionserver.RegionScanner)17 HBaseTableUtil (co.cask.cdap.data2.util.hbase.HBaseTableUtil)15 HBaseTableUtilFactory (co.cask.cdap.data2.util.hbase.HBaseTableUtilFactory)15 IOException (java.io.IOException)13 HTable (org.apache.hadoop.hbase.client.HTable)11 Delete (org.apache.hadoop.hbase.client.Delete)9 HBaseAdmin (org.apache.hadoop.hbase.client.HBaseAdmin)9 HBaseDDLExecutor (co.cask.cdap.spi.hbase.HBaseDDLExecutor)8 Path (org.apache.hadoop.fs.Path)8 HColumnDescriptor (org.apache.hadoop.hbase.HColumnDescriptor)8 HRegionInfo (org.apache.hadoop.hbase.HRegionInfo)8