Package com.sun.jini.thread
Class RetryTask
java.lang.Object
com.sun.jini.thread.RetryTask
- All Implemented Interfaces:
TimeConstants,TaskManager.Task,Runnable
- Direct Known Subclasses:
ParticipantTask,SettlerTask
-
Field Summary
Fields inherited from interface com.sun.jini.constants.TimeConstants
DAYS, HOURS, MINUTES, SECONDS -
Constructor Summary
ConstructorsConstructorDescriptionRetryTask(TaskManager manager, WakeupManager wakeupManager) Create a newRetryTaskthat will be scheduled with the given task manager, and which will perform retry scheduling using the given wakeup manager. -
Method Summary
Modifier and TypeMethodDescriptionintattempt()Return the attempt number, starting with zero.voidcancel()Cancel the retrying of the task.booleanReturntrueifcancelhas been invoked.booleancomplete()ReturntrueiftryOncehas returned successfully.voidreset()Reset values for a new use of this task.longReturn the next time at which we should make another attempt.voidrun()Therunmethod used as aTaskManager.Task.longReturn the time this task was created, or the last timeresetwas called.abstract booleantryOnce()Make a single attempt.booleanwaitFor()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.sun.jini.thread.TaskManager.Task
runAfter
-
Constructor Details
-
RetryTask
Create a newRetryTaskthat will be scheduled with the given task manager, and which will perform retry scheduling using the given wakeup manager.
-
-
Method Details
-
tryOnce
public abstract boolean tryOnce()Make a single attempt. Returntrueif the attempt was successful. If the attempt is not successful, the task will be scheduled for a future retry. -
run
public void run()Therunmethod used as aTaskManager.Task. This invokestryOnce. If it is not successful, it schedules the task for a future retry at the time it gets by invokingretryTime. -
retryTime
public long retryTime()Return the next time at which we should make another attempt. This is not an interval, but the actual time.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
runmethod 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. -
startTime
public long startTime()Return the time this task was created, or the last timeresetwas called. -
attempt
public int attempt()Return the attempt number, starting with zero. -
cancel
public void cancel()Cancel the retrying of the task. This ensures that there will be no further attempts to invoketryOnce. It will not interfere with any ongoing invocation oftryOnceunless a subclass overrides this to do so. Any override of this method should invokesuper.cancel(). -
cancelled
public boolean cancelled()Returntrueifcancelhas been invoked. -
complete
public boolean complete()ReturntrueiftryOncehas returned successfully. -
waitFor
- Throws:
InterruptedException
-
reset
public void reset()Reset values for a new use of this task.
-