public class RetryingExecutorService
extends java.lang.Object
ScheduledExecutorService to execute Callables with
retries.| Constructor and Description |
|---|
RetryingExecutorService(java.util.concurrent.ScheduledExecutorService scheduledExecutorService) |
| Modifier and Type | Method and Description |
|---|---|
void |
setRetryDelay(long delay,
java.util.concurrent.TimeUnit unit) |
void |
shutdown(long timeout,
java.util.concurrent.TimeUnit unit)
Stops accepting new
Callables and waits for all submitted
Callables to finish within the specified timeout. |
void |
submit(java.util.concurrent.Callable<java.lang.Boolean> callable)
Submit a new
Callable to be executed. |
public RetryingExecutorService(java.util.concurrent.ScheduledExecutorService scheduledExecutorService)
scheduledExecutorService - the ExecutorService to wrappublic void submit(java.util.concurrent.Callable<java.lang.Boolean> callable)
Callable to be executed. The submitted
Callable should return true to be retried, false
otherwise.callable - the Callable to executejava.util.concurrent.RejectedExecutionException - if the RetryingExecutorService is shutting downpublic void setRetryDelay(long delay,
java.util.concurrent.TimeUnit unit)
delay - the delay in units of unitunit - the TimeUnit of the delaypublic void shutdown(long timeout,
java.util.concurrent.TimeUnit unit)
throws java.lang.InterruptedException
Callables and waits for all submitted
Callables to finish within the specified timeout.timeout - the timeout in units of unitunit - the TimeUnit of timeoutjava.lang.InterruptedException