Package com.google.api.gax.retrying
Class StreamingRetryAlgorithm<ResponseT>
java.lang.Object
com.google.api.gax.retrying.RetryAlgorithm<ResponseT>
com.google.api.gax.retrying.StreamingRetryAlgorithm<ResponseT>
@InternalApi("For internal use only")
public final class StreamingRetryAlgorithm<ResponseT>
extends RetryAlgorithm<ResponseT>
The streaming retry algorithm, which makes decision based either on the thrown exception and the
execution time settings of the previous attempt. This extends
RetryAlgorithm to take
additional information (provided by ServerStreamingAttemptCallable) into account.
This class is thread-safe.
Internal use only - public for technical reasons.
-
Constructor Summary
ConstructorsConstructorDescriptionStreamingRetryAlgorithm(ResultRetryAlgorithm<ResponseT> resultAlgorithm, TimedRetryAlgorithm timedAlgorithm) Deprecated.StreamingRetryAlgorithm(ResultRetryAlgorithmWithContext<ResponseT> resultAlgorithm, TimedRetryAlgorithmWithContext timedAlgorithm) Creates aStreamingRetryAlgorithmthat will use the settings (if any) in theRetryingContextthat is passed in to the retrying methods. -
Method Summary
Modifier and TypeMethodDescriptioncreateNextAttempt(RetryingContext context, Throwable previousThrowable, ResponseT previousResponse, TimedAttemptSettings previousSettings) Creates a next attemptTimedAttemptSettings.createNextAttempt(Throwable previousThrowable, ResponseT previousResponse, TimedAttemptSettings previousSettings) Creates a next attemptTimedAttemptSettings.booleanshouldRetry(RetryingContext context, Throwable previousThrowable, ResponseT previousResponse, TimedAttemptSettings nextAttemptSettings) Returnstrueif another attempt should be made, orfalseotherwise.booleanshouldRetry(Throwable previousThrowable, ResponseT previousResponse, TimedAttemptSettings nextAttemptSettings) Returnstrueif another attempt should be made, orfalseotherwise.Methods inherited from class com.google.api.gax.retrying.RetryAlgorithm
createFirstAttempt, createFirstAttempt, getResultAlgorithm, getTimedAlgorithm
-
Constructor Details
-
StreamingRetryAlgorithm
@Deprecated public StreamingRetryAlgorithm(ResultRetryAlgorithm<ResponseT> resultAlgorithm, TimedRetryAlgorithm timedAlgorithm) Deprecated.Instances that are created using this constructor will ignore theRetryingContextthat is passed in to the retrying methods. UseStreamingRetryAlgorithm(ResultRetryAlgorithmWithContext, TimedRetryAlgorithmWithContext)to create an instance that will respect theRetryingContext. -
StreamingRetryAlgorithm
public StreamingRetryAlgorithm(ResultRetryAlgorithmWithContext<ResponseT> resultAlgorithm, TimedRetryAlgorithmWithContext timedAlgorithm) Creates aStreamingRetryAlgorithmthat will use the settings (if any) in theRetryingContextthat is passed in to the retrying methods.
-
-
Method Details
-
createNextAttempt
public TimedAttemptSettings createNextAttempt(Throwable previousThrowable, ResponseT previousResponse, TimedAttemptSettings previousSettings) Creates a next attemptTimedAttemptSettings. 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.
- Overrides:
createNextAttemptin classRetryAlgorithm<ResponseT>- Parameters:
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 settings- Returns:
- next attempt settings, can be
null, if no there should be no new attempt
-
createNextAttempt
public TimedAttemptSettings createNextAttempt(RetryingContext context, Throwable previousThrowable, ResponseT previousResponse, TimedAttemptSettings previousSettings) Creates a next attemptTimedAttemptSettings. 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.
- Overrides:
createNextAttemptin classRetryAlgorithm<ResponseT>- Parameters:
context- theRetryingContextthat can be used to determine theRetrySettingsfor 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 settings- Returns:
- next attempt settings, can be
null, if there should be no new attempt
-
shouldRetry
public boolean shouldRetry(Throwable previousThrowable, ResponseT previousResponse, TimedAttemptSettings nextAttemptSettings) throws CancellationException Returnstrueif another attempt should be made, orfalseotherwise.Ensures retries are only scheduled if the
StreamResumptionStrategyin theServerStreamingAttemptCallablesupports it.- Overrides:
shouldRetryin classRetryAlgorithm<ResponseT>- Parameters:
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 accepted- Returns:
trueif another attempt should be made, orfalseotherwise- Throws:
CancellationException- if the retrying process should be canceled
-
shouldRetry
public boolean shouldRetry(RetryingContext context, Throwable previousThrowable, ResponseT previousResponse, TimedAttemptSettings nextAttemptSettings) throws CancellationException Returnstrueif another attempt should be made, orfalseotherwise.Schedules retries only if the
StreamResumptionStrategyin theServerStreamingAttemptCallablesupports it.- Overrides:
shouldRetryin classRetryAlgorithm<ResponseT>- Parameters:
context- theRetryingContextthat 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 accepted- Returns:
trueif another attempt should be made, orfalseotherwise- Throws:
CancellationException- if the retrying process should be cancelled
-
StreamingRetryAlgorithm(ResultRetryAlgorithmWithContext, TimedRetryAlgorithmWithContext)instead