@Test public void ensureThatTaskEventuallyRuns() { doThrow(NotWritableException.class).when(freezeService).checkWritable(anyString()); Future<String> result = statusDelayedExecutor.submit(() -> "Done"); await() .pollDelay(SLEEP_INTERVAL_MS / 2, MILLISECONDS) .atMost(2 * MAX_RETRIES * SLEEP_INTERVAL_MS, MILLISECONDS) .until(() -> result.isDone()); verify(freezeService, times(MAX_RETRIES)).checkWritable(anyString()); }
@Override @Guarded(by = STARTED) public <T> Future<T> submit(final Callable<T> task) { return executor.submit(wrap(task)); }
DatabaseStatusDelayedExecutor extends StateGuardLifecycleSupport implements ExecutorService { @Override @Guarded(by = STARTED) public <T> Future<T> submit(final Callable<T> task) { return executor.submit(wrap(task)); } }
DatabaseStatusDelayedExecutor extends StateGuardLifecycleSupport implements ExecutorService { @Override @Guarded(by = STARTED) public <T> Future<T> submit(final Callable<T> task) { return executor.submit(wrap(task)); } @Inject  DatabaseStatusDelayedExecutor(final FreezeService freezeService,
                                       @Named("${nexus.delayedExecutor.threadPoolSize:-1}")
                                       final int delayedExecutorThreadPoolSize,
                                       @Named("${nexus.delayedExecutor.sleepIntervalMs:-5000}") final int sleepInterval,
                                       @Named("${nexus.delayedExecutor.maxRetries:-8640}") final int maxRetries); }
DatabaseStatusDelayedExecutor extends StateGuardLifecycleSupport implements ExecutorService { @Override @Guarded(by = STARTED) public <T> Future<T> submit(final Callable<T> task) { return executor.submit(wrap(task)); } @Inject  DatabaseStatusDelayedExecutor(final FreezeService freezeService,
                                       @Named("${nexus.delayedExecutor.threadPoolSize:-1}")
                                       final int delayedExecutorThreadPoolSize,
                                       @Named("${nexus.delayedExecutor.sleepIntervalMs:-5000}") final int sleepInterval,
                                       @Named("${nexus.delayedExecutor.maxRetries:-8640}") final int maxRetries); @Override @Guarded(by = STARTED) void shutdown(); @Override @Guarded(by = STARTED) List<Runnable> shutdownNow(); @Override @Guarded(by = STARTED) boolean isShutdown(); @Override @Guarded(by = STARTED) boolean isTerminated(); @Override @Guarded(by = STARTED) boolean awaitTermination(final long timeout, final TimeUnit unit); @Override @Guarded(by = STARTED) Future<T> submit(final Callable<T> task); @Override @Guarded(by = STARTED) Future<T> submit(final Runnable task, final T result); @Override @Guarded(by = STARTED) Future<?> submit(final Runnable task); @Override @Guarded(by = STARTED) List<Future<T>> invokeAll(final Collection<? extends Callable<T>> tasks); @Override @Guarded(by = STARTED) List<Future<T>> invokeAll(final Collection<? extends Callable<T>> tasks,
                                       final long timeout,
                                       final TimeUnit unit); @Override @Guarded(by = STARTED) T invokeAny(final Collection<? extends Callable<T>> tasks); @Override @Guarded(by = STARTED) T invokeAny(final Collection<? extends Callable<T>> tasks, final long timeout, final TimeUnit unit); @Override @Guarded(by = STARTED) void execute(final Runnable command); }
DatabaseStatusDelayedExecutor extends StateGuardLifecycleSupport implements ExecutorService { @Override @Guarded(by = STARTED) public <T> Future<T> submit(final Callable<T> task) { return executor.submit(wrap(task)); } @Inject  DatabaseStatusDelayedExecutor(final FreezeService freezeService,
                                       @Named("${nexus.delayedExecutor.threadPoolSize:-1}")
                                       final int delayedExecutorThreadPoolSize,
                                       @Named("${nexus.delayedExecutor.sleepIntervalMs:-5000}") final int sleepInterval,
                                       @Named("${nexus.delayedExecutor.maxRetries:-8640}") final int maxRetries); @Override @Guarded(by = STARTED) void shutdown(); @Override @Guarded(by = STARTED) List<Runnable> shutdownNow(); @Override @Guarded(by = STARTED) boolean isShutdown(); @Override @Guarded(by = STARTED) boolean isTerminated(); @Override @Guarded(by = STARTED) boolean awaitTermination(final long timeout, final TimeUnit unit); @Override @Guarded(by = STARTED) Future<T> submit(final Callable<T> task); @Override @Guarded(by = STARTED) Future<T> submit(final Runnable task, final T result); @Override @Guarded(by = STARTED) Future<?> submit(final Runnable task); @Override @Guarded(by = STARTED) List<Future<T>> invokeAll(final Collection<? extends Callable<T>> tasks); @Override @Guarded(by = STARTED) List<Future<T>> invokeAll(final Collection<? extends Callable<T>> tasks,
                                       final long timeout,
                                       final TimeUnit unit); @Override @Guarded(by = STARTED) T invokeAny(final Collection<? extends Callable<T>> tasks); @Override @Guarded(by = STARTED) T invokeAny(final Collection<? extends Callable<T>> tasks, final long timeout, final TimeUnit unit); @Override @Guarded(by = STARTED) void execute(final Runnable command);  }