public class RetryingExecutorService
extends java.lang.Object
ScheduledExecutorService
to execute Callable
s 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
Callable s and waits for all submitted
Callable s 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 unit
unit
- the TimeUnit
of the delaypublic void shutdown(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
Callable
s and waits for all submitted
Callable
s to finish within the specified timeout.timeout
- the timeout in units of unit
unit
- the TimeUnit
of timeout
java.lang.InterruptedException