com.twitter.common.util.concurrent
Class BackingOffFutureTask

java.lang.Object
  extended by java.util.concurrent.FutureTask<Boolean>
      extended by com.twitter.common.util.concurrent.RetryingFutureTask
          extended by com.twitter.common.util.concurrent.BackingOffFutureTask
All Implemented Interfaces:
Runnable, Future<Boolean>, RunnableFuture<Boolean>

public class BackingOffFutureTask
extends RetryingFutureTask

A RetryingFutureTask that will resubmit itself to a work queue with a backoff.


Field Summary
 
Fields inherited from class com.twitter.common.util.concurrent.RetryingFutureTask
callable, maxRetries, numRetries
 
Constructor Summary
BackingOffFutureTask(ScheduledExecutorService executor, Callable<Boolean> callable, int maxRetries, BackoffStrategy backoffStrategy)
          Creates a new retrying future task that will execute a unit of work until successfully completed, or the retry limit has been reached.
 
Method Summary
protected  void retry()
          Invokes a retry of this task.
 
Methods inherited from class com.twitter.common.util.concurrent.RetryingFutureTask
run
 
Methods inherited from class java.util.concurrent.FutureTask
cancel, done, get, get, isCancelled, isDone, runAndReset, set, setException
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BackingOffFutureTask

public BackingOffFutureTask(ScheduledExecutorService executor,
                            Callable<Boolean> callable,
                            int maxRetries,
                            BackoffStrategy backoffStrategy)
Creates a new retrying future task that will execute a unit of work until successfully completed, or the retry limit has been reached.

Parameters:
executor - The executor service to resubmit the task to upon failure.
callable - The unit of work. The work is considered successful when true is returned. It may return false or throw an exception when unsueccessful.
maxRetries - The maximum number of times to retry the task.
backoffStrategy - Strategy to use for determining backoff duration.
Method Detail

retry

protected void retry()
Description copied from class: RetryingFutureTask
Invokes a retry of this task.

Overrides:
retry in class RetryingFutureTask