@InternalApi(value="For internal use only") public final class StreamingRetryAlgorithm<ResponseT> extends RetryAlgorithm<ResponseT>
RetryAlgorithm to take
additional information (provided by ServerStreamingAttemptCallable) into account.
This class is thread-safe.
Internal use only - public for technical reasons.
| Constructor and Description |
|---|
StreamingRetryAlgorithm(ResultRetryAlgorithm<ResponseT> resultAlgorithm,
TimedRetryAlgorithm timedAlgorithm)
Deprecated.
|
StreamingRetryAlgorithm(ResultRetryAlgorithmWithContext<ResponseT> resultAlgorithm,
TimedRetryAlgorithmWithContext timedAlgorithm)
Creates a
StreamingRetryAlgorithm that will use the settings (if any) in the RetryingContext that is passed in to the retrying methods. |
| Modifier and Type | Method and Description |
|---|---|
TimedAttemptSettings |
createNextAttempt(RetryingContext context,
Throwable previousThrowable,
ResponseT previousResponse,
TimedAttemptSettings previousSettings)
Creates a next attempt
TimedAttemptSettings. |
TimedAttemptSettings |
createNextAttempt(Throwable previousThrowable,
ResponseT previousResponse,
TimedAttemptSettings previousSettings)
Creates a next attempt
TimedAttemptSettings. |
boolean |
shouldRetry(RetryingContext context,
Throwable previousThrowable,
ResponseT previousResponse,
TimedAttemptSettings nextAttemptSettings)
Returns
true if another attempt should be made, or false otherwise. |
boolean |
shouldRetry(Throwable previousThrowable,
ResponseT previousResponse,
TimedAttemptSettings nextAttemptSettings)
Returns
true if another attempt should be made, or false otherwise. |
createFirstAttempt, createFirstAttempt, getResultAlgorithm, getTimedAlgorithm@Deprecated public StreamingRetryAlgorithm(ResultRetryAlgorithm<ResponseT> resultAlgorithm, TimedRetryAlgorithm timedAlgorithm)
StreamingRetryAlgorithm(ResultRetryAlgorithmWithContext,
TimedRetryAlgorithmWithContext) insteadRetryingContext that
is passed in to the retrying methods. Use StreamingRetryAlgorithm(ResultRetryAlgorithmWithContext, TimedRetryAlgorithmWithContext) to
create an instance that will respect the RetryingContext.public StreamingRetryAlgorithm(ResultRetryAlgorithmWithContext<ResponseT> resultAlgorithm, TimedRetryAlgorithmWithContext timedAlgorithm)
StreamingRetryAlgorithm that will use the settings (if any) in the RetryingContext that is passed in to the retrying methods.public TimedAttemptSettings createNextAttempt(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.
The attempt settings will be reset if the stream attempt produced any messages.
createNextAttempt in class RetryAlgorithm<ResponseT>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.
The attempt settings will be reset if the stream attempt produced any messages.
createNextAttempt in class RetryAlgorithm<ResponseT>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 attemptpublic boolean shouldRetry(Throwable previousThrowable, ResponseT previousResponse, TimedAttemptSettings nextAttemptSettings) throws CancellationException
true if another attempt should be made, or false otherwise.
Ensures retries are only scheduled if the StreamResumptionStrategy in the ServerStreamingAttemptCallable supports it.
shouldRetry in class RetryAlgorithm<ResponseT>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.
Schedules retries only if the StreamResumptionStrategy in the ServerStreamingAttemptCallable supports it.
shouldRetry in class RetryAlgorithm<ResponseT>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