ResponseT - response typepublic class RetryAlgorithm<ResponseT> extends Object
This class is thread-safe.
| Constructor and Description |
|---|
RetryAlgorithm(ResultRetryAlgorithm<ResponseT> resultAlgorithm,
TimedRetryAlgorithm timedAlgorithm)
Creates a new retry algorithm instance, which uses thrown exception or returned response and
timed algorithms to make a decision.
|
| Modifier and Type | Method and Description |
|---|---|
TimedAttemptSettings |
createFirstAttempt()
Creates a first attempt
TimedAttemptSettings. |
TimedAttemptSettings |
createNextAttempt(Throwable prevThrowable,
ResponseT prevResponse,
TimedAttemptSettings prevSettings)
Creates a next attempt
TimedAttemptSettings. |
boolean |
shouldRetry(Throwable prevThrowable,
ResponseT prevResponse,
TimedAttemptSettings nextAttemptSettings)
Returns
true if another attempt should be made, or false otherwise. |
public RetryAlgorithm(ResultRetryAlgorithm<ResponseT> resultAlgorithm, TimedRetryAlgorithm timedAlgorithm)
resultAlgorithm - result algorithm to usetimedAlgorithm - timed algorithm to usepublic TimedAttemptSettings createFirstAttempt()
TimedAttemptSettings.public TimedAttemptSettings createNextAttempt(Throwable prevThrowable, ResponseT prevResponse, TimedAttemptSettings prevSettings)
TimedAttemptSettings. This method will return first non-null
value, returned by either result or timed retry algorithms in that particular order.prevThrowable - exception thrown by the previous attempt or null if a result was returned
insteadprevResponse - response returned by the previous attempt or null if an exception was
thrown insteadprevSettings - previous attempt settingsnull, if no there should be no new attemptpublic boolean shouldRetry(Throwable prevThrowable, ResponseT prevResponse, TimedAttemptSettings nextAttemptSettings) throws CancellationException
true if another attempt should be made, or false otherwise.prevThrowable - exception thrown by the previous attempt or null if a result was returned
insteadprevResponse - response returned by the previous attempt or null if an exception was
thrown insteadnextAttemptSettings - attempt settings, which will be used for the next attempt, if
acceptedtrue if another attempt should be made, or false otherwiseCancellationException - if the retrying process should be canceled