springs.util.retries
Class RetryingTask

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--springs.util.retries.RetryingTask
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
AccessService.RetryingGettingReference, RetryingAgentCreation, RetryingAgentInvoking, RetryingRemoteReferenceUpdate

public class RetryingTask
extends java.lang.Thread

A class that implements a retrying mechanism for tasks.

Author:
Sergio Ilarri Artigas

Field Summary
private  boolean _aborted
           
private  java.lang.Exception _lastException
           
protected  long _millisAfterSleep
           
protected  long _millisBetweenIterations
           
protected  long _millisLastTry
           
protected  long _millisLate
           
protected  long _millisNextTry
           
protected  long _millisTillNextTry
           
protected  java.lang.Object _result
           
private  springs.util.retries.RetryingStrategy _retryingStrategy
           
private  boolean _success
           
private  java.lang.String _taskDescription
           
private  java.util.Timer _timer
           
 long maxDelay
           
 long minDelay
           
 int numRetries
           
 long totalDelay
          Statistics
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
RetryingTask(springs.util.retries.RetryingStrategy retryingStrategy, java.lang.String taskDescription)
          Constructor.
 
Method Summary
 java.lang.Exception getException()
          Gets the last exception produced.waitCompletion
 java.lang.Object getResult()
          Gets the result.
 boolean getSuccess()
          Checks if the task was performed successfully.
 void mainMethod()
          Main method.
 void run()
          Execution of the main method in background.
 void setResult(java.lang.Object result)
          Sets the result.
 void task()
          Performs the task.
 void waitCompletion()
          Blocks until the task has been completed or the maximum number of retries has been reached.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_retryingStrategy

private springs.util.retries.RetryingStrategy _retryingStrategy

_taskDescription

private java.lang.String _taskDescription

_timer

private java.util.Timer _timer

_success

private boolean _success

_aborted

private boolean _aborted

_lastException

private java.lang.Exception _lastException

_result

protected java.lang.Object _result

totalDelay

public long totalDelay
Statistics


maxDelay

public long maxDelay

minDelay

public long minDelay

numRetries

public int numRetries

_millisLate

protected long _millisLate

_millisTillNextTry

protected long _millisTillNextTry

_millisLastTry

protected long _millisLastTry

_millisNextTry

protected long _millisNextTry

_millisBetweenIterations

protected long _millisBetweenIterations

_millisAfterSleep

protected long _millisAfterSleep
Constructor Detail

RetryingTask

public RetryingTask(springs.util.retries.RetryingStrategy retryingStrategy,
                    java.lang.String taskDescription)
Constructor.

Parameters:
retryingStrategy - the retrying strategy.
See Also:
RetryingStrategy, String
Method Detail

run

public void run()
Execution of the main method in background.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

mainMethod

public void mainMethod()
Main method.


task

public void task()
          throws java.lang.Exception
Performs the task. This method should be overriden by specific subclasses to perform the desired task.

Throws:
java.lang.Exception - if error.
See Also:
Exception

getException

public java.lang.Exception getException()
Gets the last exception produced.waitCompletion

Returns:
the last exception.
See Also:
Exception

getSuccess

public boolean getSuccess()
Checks if the task was performed successfully.

Returns:
a boolean indicating that.

waitCompletion

public void waitCompletion()
Blocks until the task has been completed or the maximum number of retries has been reached.


getResult

public java.lang.Object getResult()
Gets the result.

Returns:
the task's result.
See Also:
Object

setResult

public void setResult(java.lang.Object result)
Sets the result.

Parameters:
result - the task's result.
See Also:
Object