public abstract class AbstractRetryScheduler extends Object implements RetryScheduler
RetrySchedulers. This class provides methods to do the actual rescheduling and
decides if a given Throwable is explicitly transient.| Modifier and Type | Class and Description |
|---|---|
static class |
AbstractRetryScheduler.Builder<B extends AbstractRetryScheduler.Builder>
A builder class for the
RetryScheduler implementations. |
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractRetryScheduler(AbstractRetryScheduler.Builder builder)
Construct the
AbstractRetryScheduler from its builder. |
| Modifier and Type | Method and Description |
|---|---|
protected abstract long |
computeRetryInterval(CommandMessage commandMessage,
RuntimeException lastFailure,
List<Class<? extends Throwable>[]> failures)
Compute the amount of milliseconds delay until the next retry, given the information passed.
|
protected boolean |
isExplicitlyNonTransient(Throwable failure)
Indicates whether the given
failure is clearly non-transient. |
boolean |
scheduleRetry(CommandMessage commandMessage,
RuntimeException lastFailure,
List<Class<? extends Throwable>[]> failures,
Runnable dispatchTask)
This is the entrypoint of the
RetryScheduler. |
protected boolean |
scheduleRetry(Runnable commandDispatch,
long interval)
Schedule the provided task to run after the given interval.
|
protected AbstractRetryScheduler(AbstractRetryScheduler.Builder builder)
AbstractRetryScheduler from its builder.builder - the AbstractRetryScheduler.Builderprotected boolean isExplicitlyNonTransient(Throwable failure)
failure is clearly non-transient. That means, whether the
failure explicitly states that a retry of the same Command would result in the same failure to
occur again.failure - the exception that occurred while processing a commandtrue if the exception is clearly non-transient and the command should not be
retried, or false when the command has a chance of succeeding if it retried.protected boolean scheduleRetry(Runnable commandDispatch, long interval)
commandDispatch - the Runnable to schedule.interval - the number of milliseconds delay.true if the task was accepted for scheduling, false otherwise.protected abstract long computeRetryInterval(CommandMessage commandMessage, RuntimeException lastFailure, List<Class<? extends Throwable>[]> failures)
commandMessage - the command that was sent (and failed).lastFailure - the last failure that caused this retry scheduler to be called.failures - a List of all failures up to now.public boolean scheduleRetry(CommandMessage commandMessage, RuntimeException lastFailure, List<Class<? extends Throwable>[]> failures, Runnable dispatchTask)
RetryScheduler. This default implementation checks if the last failure was
transient, and if so reschedules a command dispatch.scheduleRetry in interface RetrySchedulercommandMessage - The Command Message being dispatchedlastFailure - The last failure recorded for this commandfailures - A condensed view of all known failures of this command. Each element in the array
represents the cause of the element preceding it.dispatchTask - the task that performs the actual dispatching.true if rescheduling succeeded, false if otherwise.Copyright © 2010–2020. All rights reserved.