Search in sources :

Example 1 with LevelDBTableCore

use of co.cask.cdap.data2.dataset2.lib.table.leveldb.LevelDBTableCore in project cdap by caskdata.

the class LevelDBQueueClientFactory method createConsumer.

@Override
public QueueConsumer createConsumer(QueueName queueName, ConsumerConfig consumerConfig, int numGroups) throws IOException {
    LevelDBQueueAdmin admin = ensureTableExists(queueName);
    LevelDBTableCore core = new LevelDBTableCore(admin.getActualTableName(queueName), service);
    // only the first consumer of each group runs eviction; and only if the number of consumers is known (> 0).
    QueueEvictor evictor = (numGroups <= 0 || consumerConfig.getInstanceId() != 0) ? QueueEvictor.NOOP : createEvictor(queueName, numGroups, core);
    return new LevelDBQueueConsumer(cConf, core, getQueueLock(queueName.toString()), consumerConfig, queueName, evictor);
}
Also used : LevelDBTableCore(co.cask.cdap.data2.dataset2.lib.table.leveldb.LevelDBTableCore) QueueEvictor(co.cask.cdap.data2.transaction.queue.QueueEvictor)

Example 2 with LevelDBTableCore

use of co.cask.cdap.data2.dataset2.lib.table.leveldb.LevelDBTableCore 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 3 with LevelDBTableCore

use of co.cask.cdap.data2.dataset2.lib.table.leveldb.LevelDBTableCore 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 4 with LevelDBTableCore

use of co.cask.cdap.data2.dataset2.lib.table.leveldb.LevelDBTableCore in project cdap by caskdata.

the class LevelDBQueueClientFactory method createEvictor.

@VisibleForTesting
QueueEvictor createEvictor(QueueName queueName, int numGroups) throws IOException {
    LevelDBQueueAdmin admin = ensureTableExists(queueName);
    LevelDBTableCore core = new LevelDBTableCore(admin.getActualTableName(queueName), service);
    return createEvictor(queueName, numGroups, core);
}
Also used : LevelDBTableCore(co.cask.cdap.data2.dataset2.lib.table.leveldb.LevelDBTableCore) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

LevelDBTableCore (co.cask.cdap.data2.dataset2.lib.table.leveldb.LevelDBTableCore)4 QueueEvictor (co.cask.cdap.data2.transaction.queue.QueueEvictor)1 TableId (co.cask.cdap.data2.util.TableId)1 NamespaceId (co.cask.cdap.proto.id.NamespaceId)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1