@Test public void testScheduleRunnable() throws Exception { assertThat(submitted.getCount()).isZero(); assertThat(running.getCount()).isZero(); assertThat(completed.getCount()).isZero(); assertThat(duration.getCount()).isZero(); assertThat(scheduledOnce.getCount()).isZero(); assertThat(scheduledRepetitively.getCount()).isZero(); assertThat(scheduledOverrun.getCount()).isZero(); assertThat(percentOfPeriod.getCount()).isZero(); ScheduledFuture<?> theFuture = instrumentedScheduledExecutor.schedule(new Runnable() { public void run() { assertThat(submitted.getCount()).isZero(); assertThat(running.getCount()).isEqualTo(1); assertThat(completed.getCount()).isZero(); assertThat(duration.getCount()).isZero(); assertThat(scheduledOnce.getCount()).isEqualTo(1); assertThat(scheduledRepetitively.getCount()).isZero(); assertThat(scheduledOverrun.getCount()).isZero(); assertThat(percentOfPeriod.getCount()).isZero(); } }, 10L, TimeUnit.MILLISECONDS); theFuture.get(); assertThat(submitted.getCount()).isZero(); assertThat(running.getCount()).isZero(); assertThat(completed.getCount()).isEqualTo(1); assertThat(duration.getCount()).isEqualTo(1); assertThat(duration.getSnapshot().size()).isEqualTo(1); assertThat(scheduledOnce.getCount()).isEqualTo(1); assertThat(scheduledRepetitively.getCount()).isZero(); assertThat(scheduledOverrun.getCount()).isZero(); assertThat(percentOfPeriod.getCount()).isZero(); }
@Override public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) { scheduledOnce.mark(); return delegate.schedule(new InstrumentedRunnable(command), delay, unit); }
InstrumentedScheduledExecutorService implements ScheduledExecutorService { @Override public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) { scheduledOnce.mark(); return delegate.schedule(new InstrumentedRunnable(command), delay, unit); } }
InstrumentedScheduledExecutorService implements ScheduledExecutorService { @Override public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) { scheduledOnce.mark(); return delegate.schedule(new InstrumentedRunnable(command), delay, unit); } InstrumentedScheduledExecutorService(ScheduledExecutorService delegate, MetricRegistry registry);  InstrumentedScheduledExecutorService(ScheduledExecutorService delegate, MetricRegistry registry, String name); }
InstrumentedScheduledExecutorService implements ScheduledExecutorService { @Override public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) { scheduledOnce.mark(); return delegate.schedule(new InstrumentedRunnable(command), delay, unit); } InstrumentedScheduledExecutorService(ScheduledExecutorService delegate, MetricRegistry registry);  InstrumentedScheduledExecutorService(ScheduledExecutorService delegate, MetricRegistry registry, String name); @Override ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit); @Override ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit); @Override ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit); @Override ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit); @Override void shutdown(); @Override List<Runnable> shutdownNow(); @Override boolean isShutdown(); @Override boolean isTerminated(); @Override boolean awaitTermination(long timeout, TimeUnit unit); @Override Future<T> submit(Callable<T> task); @Override Future<T> submit(Runnable task, T result); @Override Future<?> submit(Runnable task); @Override List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks); @Override List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit); @Override T invokeAny(Collection<? extends Callable<T>> tasks); @Override T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit); @Override void execute(Runnable command); }
InstrumentedScheduledExecutorService implements ScheduledExecutorService { @Override public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) { scheduledOnce.mark(); return delegate.schedule(new InstrumentedRunnable(command), delay, unit); } InstrumentedScheduledExecutorService(ScheduledExecutorService delegate, MetricRegistry registry);  InstrumentedScheduledExecutorService(ScheduledExecutorService delegate, MetricRegistry registry, String name); @Override ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit); @Override ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit); @Override ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit); @Override ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit); @Override void shutdown(); @Override List<Runnable> shutdownNow(); @Override boolean isShutdown(); @Override boolean isTerminated(); @Override boolean awaitTermination(long timeout, TimeUnit unit); @Override Future<T> submit(Callable<T> task); @Override Future<T> submit(Runnable task, T result); @Override Future<?> submit(Runnable task); @Override List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks); @Override List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit); @Override T invokeAny(Collection<? extends Callable<T>> tasks); @Override T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit); @Override void execute(Runnable command);  }