Search in sources :

Example 1 with QueueEvictor

use of co.cask.cdap.data2.transaction.queue.QueueEvictor 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 QueueEvictor

use of co.cask.cdap.data2.transaction.queue.QueueEvictor 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)

Example 3 with QueueEvictor

use of co.cask.cdap.data2.transaction.queue.QueueEvictor in project cdap by caskdata.

the class LevelDBQueueTest method forceEviction.

@Override
protected void forceEviction(QueueName queueName, int numGroups) throws Exception {
    QueueEvictor evictor = ((LevelDBQueueClientFactory) queueClientFactory).createEvictor(queueName, numGroups);
    Transaction tx = txSystemClient.startShort();
    // There is no change, just to get the latest transaction for eviction
    txSystemClient.commitOrThrow(tx);
    Uninterruptibles.getUninterruptibly(evictor.evict(tx));
}
Also used : Transaction(org.apache.tephra.Transaction) QueueEvictor(co.cask.cdap.data2.transaction.queue.QueueEvictor)

Aggregations

LevelDBTableCore (co.cask.cdap.data2.dataset2.lib.table.leveldb.LevelDBTableCore)2 QueueEvictor (co.cask.cdap.data2.transaction.queue.QueueEvictor)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Transaction (org.apache.tephra.Transaction)1