public abstract class RetryTask extends Object implements TaskManager.Task, TimeConstants
DAYS, HOURS, MINUTES, SECONDS
Constructor and Description |
---|
RetryTask(TaskManager manager,
WakeupManager wakeupManager)
Create a new
RetryTask that will be scheduled with
the given task manager, and which will perform retry scheduling
using the given wakeup manager. |
Modifier and Type | Method and Description |
---|---|
int |
attempt()
Return the attempt number, starting with zero.
|
void |
cancel()
Cancel the retrying of the task.
|
boolean |
cancelled()
Return
true if cancel has been invoked. |
boolean |
complete()
Return
true if tryOnce has returned
successfully. |
void |
reset()
Reset values for a new use of this task.
|
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() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
runAfter
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 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 void cancel()
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()
.public boolean cancelled()
true
if cancel
has been invoked.public boolean complete()
true
if tryOnce
has returned
successfully.public boolean waitFor() throws InterruptedException
InterruptedException
public void reset()
Copyright © GigaSpaces.