use of co.cask.cdap.data2.queue.QueueClientFactory 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.commit(tx);
Uninterruptibles.getUninterruptibly(evictor.evict(tx));
}
use of co.cask.cdap.data2.queue.QueueClientFactory in project cdap by caskdata.
the class ProgramLifecycleHttpHandlerTest method enqueue.
// TODO: Duplicate from AppFabricHttpHandlerTest, remove the AppFabricHttpHandlerTest method after deprecating v2 APIs
private void enqueue(QueueName queueName, final QueueEntry queueEntry) throws Exception {
QueueClientFactory queueClientFactory = AppFabricTestBase.getInjector().getInstance(QueueClientFactory.class);
final QueueProducer producer = queueClientFactory.createProducer(queueName);
// doing inside tx
TransactionExecutorFactory txExecutorFactory = AppFabricTestBase.getInjector().getInstance(TransactionExecutorFactory.class);
txExecutorFactory.createExecutor(ImmutableList.of((TransactionAware) producer)).execute(new TransactionExecutor.Subroutine() {
@Override
public void apply() throws Exception {
// write more than one so that we can dequeue multiple times for multiple checks
// we only dequeue twice, but ensure that the drop queues call drops the rest of the entries as well
int numEntries = 0;
while (numEntries++ < 5) {
producer.enqueue(queueEntry);
}
}
});
}
use of co.cask.cdap.data2.queue.QueueClientFactory in project cdap by caskdata.
the class ProgramLifecycleHttpHandlerTest method dequeueOne.
private boolean dequeueOne(QueueName queueName) throws Exception {
QueueClientFactory queueClientFactory = AppFabricTestBase.getInjector().getInstance(QueueClientFactory.class);
final QueueConsumer consumer = queueClientFactory.createConsumer(queueName, new ConsumerConfig(1L, 0, 1, DequeueStrategy.ROUND_ROBIN, null), 1);
// doing inside tx
TransactionExecutorFactory txExecutorFactory = AppFabricTestBase.getInjector().getInstance(TransactionExecutorFactory.class);
return txExecutorFactory.createExecutor(ImmutableList.of((TransactionAware) consumer)).execute(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return !consumer.dequeue(1).isEmpty();
}
});
}
use of co.cask.cdap.data2.queue.QueueClientFactory in project cdap by caskdata.
the class LevelDBStreamConsumerTest method init.
@BeforeClass
public static void init() throws Exception {
cConf.set(Constants.CFG_LOCAL_DATA_DIR, tmpFolder.newFolder().getAbsolutePath());
Injector injector = Guice.createInjector(new ConfigModule(cConf), new NonCustomLocationUnitTestModule().getModule(), new SystemDatasetRuntimeModule().getInMemoryModules(), new DataSetsModules().getInMemoryModules(), new DataFabricLevelDBModule(), new TransactionMetricsModule(), new DiscoveryRuntimeModule().getInMemoryModules(), new ExploreClientModule(), new ViewAdminModules().getInMemoryModules(), new NamespaceClientRuntimeModule().getInMemoryModules(), new AuthorizationTestModule(), new AuthorizationEnforcementModule().getInMemoryModules(), new AuthenticationContextModules().getNoOpModule(), Modules.override(new StreamAdminModules().getStandaloneModules()).with(new AbstractModule() {
@Override
protected void configure() {
bind(StreamMetaStore.class).to(InMemoryStreamMetaStore.class);
bind(NotificationFeedManager.class).to(NoOpNotificationFeedManager.class);
bind(UGIProvider.class).to(UnsupportedUGIProvider.class);
bind(OwnerAdmin.class).to(DefaultOwnerAdmin.class);
}
}));
consumerFactory = injector.getInstance(StreamConsumerFactory.class);
streamAdmin = injector.getInstance(StreamAdmin.class);
txClient = injector.getInstance(TransactionSystemClient.class);
txManager = injector.getInstance(TransactionManager.class);
queueClientFactory = injector.getInstance(QueueClientFactory.class);
fileWriterFactory = injector.getInstance(StreamFileWriterFactory.class);
streamCoordinatorClient = injector.getInstance(StreamCoordinatorClient.class);
streamCoordinatorClient.startAndWait();
txManager.startAndWait();
setupNamespaces(injector.getInstance(NamespacedLocationFactory.class));
}
Aggregations