V - public abstract class RetryTask<V> extends Object implements java.util.concurrent.RunnableFuture<V>, FutureObserver.ObservableFuture<V>, org.apache.river.constants.TimeConstants
| Modifier and Type | Field and Description |
|---|---|
protected static Logger |
logger
Logger for this class
|
| Constructor and Description |
|---|
RetryTask(java.util.concurrent.ExecutorService executor,
WakeupManager wakeupManager)
Create a new
RetryTask that will be scheduled with
the given executor service, and which will perform retry scheduling
using the given wakeup manager. |
RetryTask(TaskManager manager,
WakeupManager wakeupManager)
Deprecated.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
addObserver(FutureObserver<V> listener)
Adds FutureObserver's to this ObservableFuture.
|
int |
attempt()
Return the attempt number, starting with zero.
|
boolean |
cancel(boolean mayInterruptIfRunning)
Cancel the retrying of the task.
|
V |
get() |
V |
get(long time,
java.util.concurrent.TimeUnit unit) |
boolean |
isCancelled()
Return
true if cancel has been invoked. |
boolean |
isDone()
Return
true if tryOnce has returned
successfully. |
long |
retryTime()
Return the next time at which we should make another attempt.
|
void |
run()
The
run method used as a
TaskManager.Task. |
long |
startTime()
Return the time this task was created, or the last
time
reset was called. |
abstract boolean |
tryOnce()
Make a single attempt.
|
boolean |
waitFor(long duration) |
protected static final Logger logger
@Deprecated public RetryTask(TaskManager manager, WakeupManager wakeupManager)
RetryTask that will be scheduled with
the given task manager, and which will perform retry scheduling
using the given wakeup manager.public RetryTask(java.util.concurrent.ExecutorService executor, WakeupManager wakeupManager)
RetryTask that will be scheduled with
the given executor service, and which will perform retry scheduling
using the given wakeup manager.
TaskManager's Task.runAfter() is not called when using
this constructor.executor - wakeupManager - public boolean addObserver(FutureObserver<V> listener)
FutureObserver.ObservableFutureaddObserver in interface FutureObserver.ObservableFuture<V>listener - to observe this.public abstract boolean tryOnce()
true if the attempt
was successful. If the attempt is not successful, the task
will be scheduled for a future retry.public void run()
run method used as a
TaskManager.Task. This invokes
tryOnce. If it is not successful, it schedules
the task for a future retry at the time it gets by invoking
retryTime.public long retryTime()
The implementation is free to do as it pleases with the policy here. The default implementation is to delay using intervals of 1 second, 5 seconds, 10 seconds, 1 minute, and 1 minute between attempts, and then retrying every five minutes forever.
The default implementation assumes it is being called from
the default run method and that the current thread
holds the lock on this object. If the caller does
not own the lock the result is undefined and could result in an
exception.
public long startTime()
reset was called.public int attempt()
public boolean cancel(boolean mayInterruptIfRunning)
tryOnce. It will not
interfere with any ongoing invocation of tryOnce
unless a subclass overrides this to do so. Any override of this
method should invoke super.cancel().cancel in interface java.util.concurrent.Future<V>public boolean isCancelled()
true if cancel has been invoked.isCancelled in interface java.util.concurrent.Future<V>public boolean isDone()
true if tryOnce has returned
successfully.isDone in interface java.util.concurrent.Future<V>public boolean waitFor(long duration)
throws InterruptedException
InterruptedExceptionpublic V get() throws InterruptedException, java.util.concurrent.ExecutionException
get in interface java.util.concurrent.Future<V>InterruptedExceptionjava.util.concurrent.ExecutionExceptionpublic V get(long time, java.util.concurrent.TimeUnit unit) throws InterruptedException, java.util.concurrent.ExecutionException, java.util.concurrent.TimeoutException
get in interface java.util.concurrent.Future<V>InterruptedExceptionjava.util.concurrent.ExecutionExceptionjava.util.concurrent.TimeoutExceptionCopyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.