ResponseT - response typepublic class RetryAlgorithm<ResponseT> extends Object
This class is thread-safe.
| Constructor and Description |
|---|
RetryAlgorithm(ResultRetryAlgorithm<ResponseT> resultAlgorithm,
TimedRetryAlgorithm timedAlgorithm)
Deprecated.
|
RetryAlgorithm(ResultRetryAlgorithmWithContext<ResponseT> resultAlgorithm,
TimedRetryAlgorithmWithContext timedAlgorithm)
Creates a new retry algorithm instance, which uses thrown exception or returned response and
timed algorithms to make a decision.
|
@Deprecated public RetryAlgorithm(ResultRetryAlgorithm<ResponseT> resultAlgorithm, TimedRetryAlgorithm timedAlgorithm)
RetryAlgorithm(ResultRetryAlgorithmWithContext,
TimedRetryAlgorithmWithContext) insteadInstances that are created using this constructor will ignore the RetryingContext
that is passed in to the retrying methods. Use RetryAlgorithm(ResultRetryAlgorithmWithContext, TimedRetryAlgorithmWithContext) to create an
instance that will respect the RetryingContext.
resultAlgorithm - result algorithm to usetimedAlgorithm - timed algorithm to usepublic RetryAlgorithm(ResultRetryAlgorithmWithContext<ResponseT> resultAlgorithm, TimedRetryAlgorithmWithContext timedAlgorithm)
resultAlgorithm - result algorithm to usetimedAlgorithm - timed algorithm to use@Deprecated public TimedAttemptSettings createFirstAttempt()
createFirstAttempt(RetryingContext) insteadTimedAttemptSettings.public TimedAttemptSettings createFirstAttempt(RetryingContext context)
TimedAttemptSettings.context - the RetryingContext that can be used to get the initial RetrySettings@Deprecated public TimedAttemptSettings createNextAttempt(Throwable previousThrowable, ResponseT previousResponse, TimedAttemptSettings previousSettings)
createNextAttempt(RetryingContext, Throwable, Object,
TimedAttemptSettings) insteadTimedAttemptSettings. This method will return first non-null
value, returned by either result or timed retry algorithms in that particular order.previousThrowable - exception thrown by the previous attempt or null if a result was
returned insteadpreviousResponse - response returned by the previous attempt or null if an exception was
thrown insteadpreviousSettings - previous attempt settingsnull, if no there should be no new attemptpublic TimedAttemptSettings createNextAttempt(RetryingContext context, Throwable previousThrowable, ResponseT previousResponse, TimedAttemptSettings previousSettings)
TimedAttemptSettings. This method will return first non-null
value, returned by either result or timed retry algorithms in that particular order.context - the RetryingContext that can be used to determine the RetrySettings for the next attemptpreviousThrowable - exception thrown by the previous attempt or null if a result was
returned insteadpreviousResponse - response returned by the previous attempt or null if an exception was
thrown insteadpreviousSettings - previous attempt settingsnull, if there should be no new attempt@Deprecated public boolean shouldRetry(Throwable previousThrowable, ResponseT previousResponse, TimedAttemptSettings nextAttemptSettings) throws CancellationException
shouldRetry(RetryingContext, Throwable, Object, TimedAttemptSettings)
insteadtrue if another attempt should be made, or false otherwise.previousThrowable - exception thrown by the previous attempt or null if a result was
returned insteadpreviousResponse - 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 canceledpublic boolean shouldRetry(RetryingContext context, Throwable previousThrowable, ResponseT previousResponse, TimedAttemptSettings nextAttemptSettings) throws CancellationException
true if another attempt should be made, or false otherwise.context - the RetryingContext that can be used to determine whether another
attempt should be madepreviousThrowable - exception thrown by the previous attempt or null if a result was
returned insteadpreviousResponse - 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 cancelled@BetaApi(value="Surface for inspecting the a RetryAlgorithm is not yet stable") public ResultRetryAlgorithm<ResponseT> getResultAlgorithm()
@BetaApi(value="Surface for inspecting the a RetryAlgorithm is not yet stable") public TimedRetryAlgorithm getTimedAlgorithm()