@Override public ListenableScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) { return delegate.scheduleAtFixedRate(command, initialDelay, period, unit); }
@Override public ListenableScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) { return delegate.scheduleAtFixedRate(command, initialDelay, period, unit); }
@Override public ListenableScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) { NeverSuccessfulListenableFutureTask task = new NeverSuccessfulListenableFutureTask(new MDCPropagatingRunnable(command)); ScheduledFuture<?> scheduled = executorService.scheduleAtFixedRate(task, initialDelay, period, unit); return new ListenableScheduledTask<>(task, scheduled); }
/** * Schedule a {@link TaskMetricsUpdater}. * * @param taskMetricsUpdater the {@link TaskMetricsUpdater} to schedule * @param task the {@link Task} that the {@link TaskMetricsUpdater} is associated to * @return a {@link java.util.concurrent.ScheduledFuture} corresponding to the scheduled {@link TaskMetricsUpdater} */ protected ScheduledFuture<?> scheduleTaskMetricsUpdater(Runnable taskMetricsUpdater, Task task) { return this.taskMetricsUpdaterExecutor.scheduleAtFixedRate(taskMetricsUpdater, task.getTaskContext().getStatusReportingInterval(), task.getTaskContext().getStatusReportingInterval(), TimeUnit.MILLISECONDS); }
public void testListeningDecorator_schedulePeriodic() throws Exception { ScheduledThreadPoolExecutor delegate = new ScheduledThreadPoolExecutor(1); ListeningScheduledExecutorService service = listeningDecorator(delegate); RuntimeException ex = new RuntimeException(); ListenableFuture<?> future; ThrowingRunnable runnable = new ThrowingRunnable(5, ex); future = service.scheduleAtFixedRate(runnable, 1, 1, TimeUnit.MILLISECONDS); assertExecutionException(future, ex); assertEquals(5, runnable.count); assertEquals(0, delegate.getQueue().size()); runnable = new ThrowingRunnable(5, ex); future = service.scheduleWithFixedDelay(runnable, 1, 1, TimeUnit.MILLISECONDS); assertExecutionException(future, ex); assertEquals(5, runnable.count); assertEquals(0, delegate.getQueue().size()); }
public void testListeningDecorator_cancelled() throws Exception { ScheduledThreadPoolExecutor delegate = new ScheduledThreadPoolExecutor(1); BlockingQueue<?> delegateQueue = delegate.getQueue(); ListeningScheduledExecutorService service = listeningDecorator(delegate); ListenableFuture<?> future; ScheduledFuture<?> delegateFuture; Runnable runnable = new Runnable() { @Override public void run() {} }; future = service.schedule(runnable, 5, TimeUnit.MINUTES); future.cancel(true); assertTrue(future.isCancelled()); delegateFuture = (ScheduledFuture<?>) delegateQueue.element(); assertTrue(delegateFuture.isCancelled()); delegateQueue.clear(); future = service.scheduleAtFixedRate(runnable, 5, 5, TimeUnit.MINUTES); future.cancel(true); assertTrue(future.isCancelled()); delegateFuture = (ScheduledFuture<?>) delegateQueue.element(); assertTrue(delegateFuture.isCancelled()); delegateQueue.clear(); future = service.scheduleWithFixedDelay(runnable, 5, 5, TimeUnit.MINUTES); future.cancel(true); assertTrue(future.isCancelled()); delegateFuture = (ScheduledFuture<?>) delegateQueue.element(); assertTrue(delegateFuture.isCancelled()); }
@Override public ListenableScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) { this.checkQueue(1); return this.thread.scheduleAtFixedRate(command, initialDelay, period, unit); }
@Override public ListenableScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit) { return delegate.scheduleAtFixedRate(timedRunnable(command), initialDelay, delay, unit); }
private void scheduleSizeMonitor() { scheduler.scheduleAtFixedRate(new Runnable() { @Override public void run() { fileStoreSize = fileStore.getStats().getApproximateSize(); } }, 1, 1, MINUTES); }
@Override public ListenableScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) { return delegate.scheduleAtFixedRate(timedRunnable(command), initialDelay, period, unit); }
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override public ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) { return new ScheduledFuture(delegate().scheduleAtFixedRate(command, initialDelay, period, unit)); }
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override public ListenableScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) { return new ListenableScheduledFuture(delegate().scheduleAtFixedRate(command, initialDelay, period, unit)); }
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override public ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) { return new ScheduledFuture(delegate().scheduleAtFixedRate(command, initialDelay, period, unit)); }
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override public ListenableScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) { return new ListenableScheduledFuture(delegate().scheduleAtFixedRate(command, initialDelay, period, unit)); }
/** * {@inheritDoc} */ @Override public ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) { return chooseThread().scheduleAtFixedRate(timedRunnable(command), initialDelay, period, unit); }
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override public ListenableScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) { return new ListenableScheduledFuture(delegate().scheduleAtFixedRate(command, initialDelay, period, unit)); }
/** * Schedule a {@link TaskMetricsUpdater}. * * @param taskMetricsUpdater the {@link TaskMetricsUpdater} to schedule * @param task the {@link Task} that the {@link TaskMetricsUpdater} is associated to * @return a {@link java.util.concurrent.ScheduledFuture} corresponding to the scheduled {@link TaskMetricsUpdater} */ protected ScheduledFuture<?> scheduleTaskMetricsUpdater(Runnable taskMetricsUpdater, Task task) { return this.taskMetricsUpdaterExecutor.scheduleAtFixedRate(taskMetricsUpdater, task.getTaskContext().getStatusReportingInterval(), task.getTaskContext().getStatusReportingInterval(), TimeUnit.MILLISECONDS); }
/** * Schedule a {@link TaskMetricsUpdater}. * * @param taskMetricsUpdater the {@link TaskMetricsUpdater} to schedule * @param task the {@link Task} that the {@link TaskMetricsUpdater} is associated to * @return a {@link java.util.concurrent.ScheduledFuture} corresponding to the scheduled {@link TaskMetricsUpdater} */ protected ScheduledFuture<?> scheduleTaskMetricsUpdater(Runnable taskMetricsUpdater, Task task) { return this.taskMetricsUpdaterExecutor.scheduleAtFixedRate(taskMetricsUpdater, task.getTaskContext().getStatusReportingInterval(), task.getTaskContext().getStatusReportingInterval(), TimeUnit.MILLISECONDS); }
@Override public ListenableScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) { NeverSuccessfulListenableFutureTask task = new NeverSuccessfulListenableFutureTask(new MDCPropagatingRunnable(command)); ScheduledFuture<?> scheduled = executorService.scheduleAtFixedRate(task, initialDelay, period, unit); return new ListenableScheduledTask<>(task, scheduled); }
@Override public ListenableScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) { NeverSuccessfulListenableFutureTask task = new NeverSuccessfulListenableFutureTask(new MDCPropagatingRunnable(command)); ScheduledFuture<?> scheduled = executorService.scheduleAtFixedRate(task, initialDelay, period, unit); return new ListenableScheduledTask<>(task, scheduled); }