com.twitter.common.util
Class RetryingRunnable<E extends Exception>

java.lang.Object
  extended by com.twitter.common.util.RetryingRunnable<E>
Type Parameters:
E - The type of exception that the ExceptionalCommand throws.
All Implemented Interfaces:
Runnable

public class RetryingRunnable<E extends Exception>
extends Object
implements Runnable

A runnable task that is retried in a user-configurable fashion.


Constructor Summary
RetryingRunnable(String name, ExceptionalCommand<E> task, Class<E> exceptionClass, int numTries, Amount<Long,Time> retryDelay, CommandExecutor commandExecutor)
          Create a Task with name name that executes at most numTries in case of failure with an interval of retryDelay between attempts and sets tryNum to be the first (=1).
RetryingRunnable(String name, ExceptionalCommand<E> task, Class<E> exceptionClass, int numTries, Amount<Long,Time> retryDelay, CommandExecutor commandExecutor, int tryNum)
          Create a Task with name name that executes at most numTries in case of failure with an interval of retryDelay between attempts.
 
Method Summary
 void run()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RetryingRunnable

public RetryingRunnable(String name,
                        ExceptionalCommand<E> task,
                        Class<E> exceptionClass,
                        int numTries,
                        Amount<Long,Time> retryDelay,
                        CommandExecutor commandExecutor,
                        int tryNum)
Create a Task with name name that executes at most numTries in case of failure with an interval of retryDelay between attempts.

Parameters:
name - Human readable name for this task.
task - the task to execute.
exceptionClass - class of the exception thrown by the task.
numTries - the total number of times to try.
retryDelay - the delay between successive tries.
commandExecutor - Executor to resubmit retries to.
tryNum - the seq number of this try.

RetryingRunnable

public RetryingRunnable(String name,
                        ExceptionalCommand<E> task,
                        Class<E> exceptionClass,
                        int numTries,
                        Amount<Long,Time> retryDelay,
                        CommandExecutor commandExecutor)
Create a Task with name name that executes at most numTries in case of failure with an interval of retryDelay between attempts and sets tryNum to be the first (=1).

Parameters:
name - Human readable name for this task.
task - the task to execute.
exceptionClass - class of the exception thrown by the task.
numTries - the total number of times to try.
retryDelay - the delay between successive tries.
commandExecutor - Executor to resubmit retries to.
Method Detail

run

public void run()
Specified by:
run in interface Runnable

toString

public String toString()
Overrides:
toString in class Object