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);
}
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);
}
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));
}
Aggregations