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
-
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.boolean
shouldRetry
(RetryingContext context, Throwable previousThrowable, ResponseT previousResponse) Returnstrue
if an exception was thrown (previousThrowable != null
),false
otherwise.boolean
shouldRetry
(Throwable previousThrowable, ResponseT previousResponse) Returnstrue
if an exception was thrown (previousThrowable != null
),false
otherwise.
-
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:
createNextAttempt
in 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:
createNextAttempt
in 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
Returnstrue
if an exception was thrown (previousThrowable != null
),false
otherwise.- Specified by:
shouldRetry
in interfaceResultRetryAlgorithm<ResponseT>
-
shouldRetry
public boolean shouldRetry(RetryingContext context, Throwable previousThrowable, ResponseT previousResponse) throws CancellationException Returnstrue
if an exception was thrown (previousThrowable != null
),false
otherwise.- Specified by:
shouldRetry
in 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
-