Package org.jitsi.retry
Class RetryTask
-
- All Implemented Interfaces:
public abstract class RetryTaskClass describes a retry task executed by RetryStrategy. It has the following properties:
initialDelay - specifies the time before this task is launched for the first timeretryDelay - tells how much time we wait before next retry attempt. Subclass can override getRetryDelay in order to provide dynamic value which can be different for each retrygetCallable - aCallablewhich is the job to be executed by retry strategy. The task will be retried as long as it returns true or until the job is cancelled. retryAfterException - indicates if retries should be continued after uncaught exception is thrown by retry callable task cancelled - indicates if RetryStrategy and this task has been cancelled using cancel. This does not interrupt currently executing task.Pawel Domas
-
-
Field Summary
Fields Modifier and Type Field Description public final longinitialDelaypublic final longretryDelay
-
Constructor Summary
Constructors Constructor Description RetryTask(long initialDelay, long retryDelay, boolean retryOnException)Initializes new instance of RetryTask.
-
Method Summary
Modifier and Type Method Description longgetInitialDelay()Returns the time in ms before this task is launched for the first time. longgetRetryDelay()Returns the delay in ms that we wait before next retry attempt. abstract Callable<Boolean>getCallable()Returns a Callablewhich is the job to be executed by retry strategy.booleanwillRetryAfterException()Indicates if we're going to continue retry task scheduling after the callable throws unexpected exception. booleanisCancelled()Returns true if this task has been cancelled. voidsetRetryAfterException(boolean retryAfterException)Should we continue retries after the callable throws unexpected exception ? voidsetCancelled(boolean cancelled)Method is called by RetryStrategy when it gets cancelled. -
-
Constructor Detail
-
RetryTask
RetryTask(long initialDelay, long retryDelay, boolean retryOnException)
Initializes new instance of RetryTask.- Parameters:
initialDelay- how long we're going to wait before running task callable for the first time(in ms).retryDelay- how often are we going to retry(in ms).retryOnException- should we continue retry after callable throws unexpected Exception.
-
-
Method Detail
-
getInitialDelay
long getInitialDelay()
Returns the time in ms before this task is launched for the first time.
-
getRetryDelay
long getRetryDelay()
Returns the delay in ms that we wait before next retry attempt.
-
getCallable
abstract Callable<Boolean> getCallable()
Returns a
Callablewhich is the job to be executed by retry strategy. The task will be retried as long as it returns true or until the job is cancelled.
-
willRetryAfterException
boolean willRetryAfterException()
Indicates if we're going to continue retry task scheduling after the callable throws unexpected exception.
-
isCancelled
boolean isCancelled()
Returns true if this task has been cancelled.
-
setRetryAfterException
void setRetryAfterException(boolean retryAfterException)
Should we continue retries after the callable throws unexpected exception ?
- Parameters:
retryAfterException- true to continue retries even though unexpected exception is thrown by the callable, otherwise retry strategy will be cancelled when that happens.
-
setCancelled
void setCancelled(boolean cancelled)
Method is called by RetryStrategy when it gets cancelled.
- Parameters:
cancelled- true when this task is being cancelled.
-
-
-
-