GigaSpaces XAP 9.7.2 API

com.sun.jini.thread
Class RetryTask

java.lang.Object
  extended by com.sun.jini.thread.RetryTask
All Implemented Interfaces:
TimeConstants, TaskManager.Task, Runnable
Direct Known Subclasses:
ParticipantTask, SettlerTask

public abstract class RetryTask
extends Object
implements TaskManager.Task, TimeConstants


Field Summary
 
Fields inherited from interface com.sun.jini.constants.TimeConstants
DAYS, HOURS, MINUTES, SECONDS
 
Constructor Summary
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.
 
Method Summary
 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()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.sun.jini.thread.TaskManager.Task
runAfter
 

Constructor Detail

RetryTask

public 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.

Method Detail

tryOnce

public abstract boolean tryOnce()
Make a single attempt. Return true if the attempt was successful. If the attempt is not successful, the task will be scheduled for a future retry.


run

public void run()
The 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.

Specified by:
run in interface Runnable
See Also:
tryOnce(), startTime

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 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.


startTime

public long startTime()
Return the time this task was created, or the last time reset was 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 invoke 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().


cancelled

public boolean cancelled()
Return true if cancel has been invoked.


complete

public boolean complete()
Return true if tryOnce has returned successfully.


waitFor

public boolean waitFor()
                throws InterruptedException
Throws:
InterruptedException

reset

public void reset()
Reset values for a new use of this task.


GigaSpaces XAP 9.7.2 API

Copyright © GigaSpaces.