Package com.google.api.gax.retrying
Class BasicResultRetryAlgorithm<ResponseT>
java.lang.Object
com.google.api.gax.retrying.BasicResultRetryAlgorithm<ResponseT>
- Type Parameters:
ResponseT- attempt response type
- All Implemented Interfaces:
ResultRetryAlgorithm<ResponseT>,ResultRetryAlgorithmWithContext<ResponseT>
public class BasicResultRetryAlgorithm<ResponseT>
extends Object
implements ResultRetryAlgorithmWithContext<ResponseT>
A basic implementation of
ResultRetryAlgorithm. Using this implementation would mean that
all exceptions should be retried, all responses should be accepted (including null) and
no retrying process should ever be canceled.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateNextAttempt(RetryingContext context, Throwable previousThrowable, ResponseT previousResponse, TimedAttemptSettings previousSettings) Always returns null, indicating that this algorithm does not provide any specific settings for the next attempt.createNextAttempt(Throwable previousThrowable, ResponseT previousResponse, TimedAttemptSettings previousSettings) Always returns null, indicating that this algorithm does not provide any specific settings for the next attempt.booleanshouldRetry(RetryingContext context, Throwable previousThrowable, ResponseT previousResponse) Returnstrueif an exception was thrown (previousThrowable != null),falseotherwise.booleanshouldRetry(Throwable previousThrowable, ResponseT previousResponse) Returnstrueif an exception was thrown (previousThrowable != null),falseotherwise.
-
Constructor Details
-
BasicResultRetryAlgorithm
public BasicResultRetryAlgorithm()
-
-
Method Details
-
createNextAttempt
public TimedAttemptSettings createNextAttempt(Throwable previousThrowable, ResponseT previousResponse, TimedAttemptSettings previousSettings) Always returns null, indicating that this algorithm does not provide any specific settings for the next attempt.- Specified by:
createNextAttemptin interfaceResultRetryAlgorithm<ResponseT>
-
createNextAttempt
public TimedAttemptSettings createNextAttempt(RetryingContext context, Throwable previousThrowable, ResponseT previousResponse, TimedAttemptSettings previousSettings) Always returns null, indicating that this algorithm does not provide any specific settings for the next attempt.- Specified by:
createNextAttemptin interfaceResultRetryAlgorithmWithContext<ResponseT>- Parameters:
context- the retrying context of this invocation that can be used to determine the settings for the next attempt.previousThrowable- exception thrown by the previous attempt (null, if none)previousResponse- response returned by the previous attemptpreviousSettings- previous attempt settings
-
shouldRetry
Returnstrueif an exception was thrown (previousThrowable != null),falseotherwise.- Specified by:
shouldRetryin interfaceResultRetryAlgorithm<ResponseT>
-
shouldRetry
public boolean shouldRetry(RetryingContext context, Throwable previousThrowable, ResponseT previousResponse) throws CancellationException Returnstrueif an exception was thrown (previousThrowable != null),falseotherwise.- Specified by:
shouldRetryin interfaceResultRetryAlgorithmWithContext<ResponseT>- Parameters:
context- the retrying context of this invocation that can be used to determine whether the call should be retried.previousThrowable- exception thrown by the previous attempt (null, if none)previousResponse- response returned by the previous attempt.- Throws:
CancellationException
-