@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) |
| Modifier and Type | Method and Description |
|---|---|
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. |
createFirstAttemptpublic StreamingRetryAlgorithm(ResultRetryAlgorithm<ResponseT> resultAlgorithm, TimedRetryAlgorithm timedAlgorithm)
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.
The attempt settings will be reset if the stream attempt produced any messages.
createNextAttempt in class RetryAlgorithm<ResponseT>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.
Ensures retries are only scheduled if the StreamResumptionStrategy in the ServerStreamingAttemptCallable supports it.
shouldRetry in class RetryAlgorithm<ResponseT>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