com.google.common.util.concurrent.ListenableScheduledFuture

Here are the examples of the java api class com.google.common.util.concurrent.ListenableScheduledFuture taken from open source projects.

1. CeProcessingSchedulerImplTest#when_workerCount_is_more_than_1_as_many_CeWorkerCallable_are_scheduled()

View license
@Test
public void when_workerCount_is_more_than_1_as_many_CeWorkerCallable_are_scheduled() throws InterruptedException {
    int workerCount = Math.abs(new Random().nextInt(10)) + 1;
    ceConfiguration.setWorkerCount(workerCount);
    ListenableScheduledFuture listenableScheduledFuture = mock(ListenableScheduledFuture.class);
    CeProcessingSchedulerExecutorService processingExecutorService = mock(CeProcessingSchedulerExecutorService.class);
    CeProcessingSchedulerImpl underTest = new CeProcessingSchedulerImpl(ceConfiguration, processingExecutorService, ceWorkerRunnable);
    when(processingExecutorService.schedule(ceWorkerRunnable, ceConfiguration.getQueuePollingDelay(), MILLISECONDS)).thenReturn(listenableScheduledFuture);
    underTest.startScheduling();
    verify(processingExecutorService, times(workerCount)).schedule(ceWorkerRunnable, ceConfiguration.getQueuePollingDelay(), MILLISECONDS);
    verify(listenableScheduledFuture, times(workerCount)).addListener(any(Runnable.class), eq(processingExecutorService));
}

2. LookupCoordinatorManager#backgroundManagerIsRunning()

Project: druid
Source File: LookupCoordinatorManager.java
View license
@VisibleForTesting
boolean backgroundManagerIsRunning() {
    ListenableScheduledFuture backgroundManagerFuture = this.backgroundManagerFuture;
    return backgroundManagerFuture != null && !backgroundManagerFuture.isDone();
}