com.pmease.quickbuild.util
Class RetryingFutureTask
java.lang.Object
java.util.concurrent.FutureTask<java.lang.Boolean>
com.pmease.quickbuild.util.RetryingFutureTask
- All Implemented Interfaces:
- java.lang.Runnable, java.util.concurrent.Future<java.lang.Boolean>, java.util.concurrent.RunnableFuture<java.lang.Boolean>
public class RetryingFutureTask
- extends java.util.concurrent.FutureTask<java.lang.Boolean>
A future task that supports retries by resubmitting itself to an
ExecutorService
.
Field Summary |
protected java.util.concurrent.Callable<java.lang.Boolean> |
callable
|
protected java.util.concurrent.ExecutorService |
executor
|
protected int |
maxRetries
|
protected int |
numRetries
|
Constructor Summary |
RetryingFutureTask(java.util.concurrent.ExecutorService executor,
java.util.concurrent.Callable<java.lang.Boolean> callable,
int maxRetries)
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. |
void |
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 |
executor
protected final java.util.concurrent.ExecutorService executor
maxRetries
protected final int maxRetries
numRetries
protected int numRetries
callable
protected final java.util.concurrent.Callable<java.lang.Boolean> callable
RetryingFutureTask
public RetryingFutureTask(java.util.concurrent.ExecutorService executor,
java.util.concurrent.Callable<java.lang.Boolean> callable,
int maxRetries)
- 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.
retry
protected void retry()
- Invokes a retry of this task.
run
public void run()
- Specified by:
run
in interface java.lang.Runnable
- Specified by:
run
in interface java.util.concurrent.RunnableFuture<java.lang.Boolean>
- Overrides:
run
in class java.util.concurrent.FutureTask<java.lang.Boolean>
Copyright © 2005-2010 PMEase Inc. All Rights Reserved.