- 2.59.0 (latest)
- 2.58.0
- 2.57.0
- 2.55.0
- 2.54.1
- 2.53.0
- 2.52.0
- 2.51.0
- 2.50.0
- 2.49.0
- 2.48.1
- 2.47.0
- 2.46.1
- 2.45.0
- 2.43.0
- 2.42.0
- 2.41.0
- 2.39.0
- 2.38.0
- 2.37.0
- 2.36.0
- 2.35.0
- 2.34.1
- 2.33.0
- 2.32.1
- 2.31.1
- 2.30.1
- 2.24.0
- 2.23.3
- 2.22.0
- 2.21.0
- 2.20.1
- 2.19.6
- 2.18.7
- 2.17.0
- 2.16.0
- 2.15.0
- 2.14.0
- 2.13.0
- 2.12.2
- 2.11.0
- 2.10.0
- 2.9.0
- 2.8.1
- 2.7.1
public abstract class RetrySettings implements Serializable
Holds the parameters for retry or poll logic with jitter, timeout and exponential backoff. Actual implementation of the logic is elsewhere.
The intent of these settings is to be used with a call to a remote server, which could either fail (and return an error code) or not respond (and cause a timeout). When there is a failure or timeout, the logic should keep trying until the total timeout has passed.
The "total timeout" and "max attempts" settings have ultimate control over how long the logic should keep trying the remote call until it gives up completely. The remote call will be retried until one of those thresholds is crossed. To avoid unbounded rpc calls, it is required to configure one of those settings. If both are 0, then retries will be disabled. The other settings are considered more advanced.
Retry delay and timeout start at specific values, and are tracked separately from each other. The very first call (before any retries) will use the initial timeout.
If the last remote call is a failure, then the retrier will wait for the current retry delay before attempting another call, and then the retry delay will be multiplied by the retry delay multiplier for the next failure. The timeout will not be affected, except in the case where the timeout would result in a deadline past the total timeout; in that circumstance, a new timeout value is computed which will terminate the call when the total time is up.
If the last remote call is a timeout, then the retrier will compute a new timeout and make another call. The new timeout is computed by multiplying the current timeout by the timeout multiplier, but if that results in a deadline after the total timeout, then a new timeout value is computed which will terminate the call when the total time is up.
Server streaming RPCs interpret RPC timeouts a bit differently. For server streaming RPCs, the RPC timeout gets converted into a wait timeout com.google.api.gax.rpc.ApiCallContext#withStreamWaitTimeout(Duration).
Implements
SerializableConstructors
RetrySettings()
public RetrySettings()
Methods
getInitialRetryDelay()
public abstract Duration getInitialRetryDelay()
InitialRetryDelay controls the delay before the first retry. Subsequent retries will use this
value adjusted according to the RetryDelayMultiplier. The default value is
Duration.ZERO
.
Type | Description |
org.threeten.bp.Duration |
getInitialRpcTimeout()
public abstract Duration getInitialRpcTimeout()
InitialRpcTimeout controls the timeout for the initial RPC. Subsequent calls will use this
value adjusted according to the RpcTimeoutMultiplier. The default value is
Duration.ZERO
.
Type | Description |
org.threeten.bp.Duration |
getMaxAttempts()
public abstract int getMaxAttempts()
MaxAttempts defines the maximum number of attempts to perform. The default value is 0
.
If this value is greater than 0, and the number of attempts reaches this limit, the logic will
give up retrying even if the total retry time is still lower than TotalTimeout.
Type | Description |
int |
getMaxRetryDelay()
public abstract Duration getMaxRetryDelay()
MaxRetryDelay puts a limit on the value of the retry delay, so that the RetryDelayMultiplier
can't increase the retry delay higher than this amount. The default value is
Duration.ZERO
.
Type | Description |
org.threeten.bp.Duration |
getMaxRpcTimeout()
public abstract Duration getMaxRpcTimeout()
MaxRpcTimeout puts a limit on the value of the RPC timeout, so that the RpcTimeoutMultiplier
can't increase the RPC timeout higher than this amount. The default value is
Duration.ZERO
.
Type | Description |
org.threeten.bp.Duration |
getRetryDelayMultiplier()
public abstract double getRetryDelayMultiplier()
RetryDelayMultiplier controls the change in retry delay. The retry delay of the previous call
is multiplied by the RetryDelayMultiplier to calculate the retry delay for the next call. The
default value is 1.0
.
Type | Description |
double |
getRpcTimeoutMultiplier()
public abstract double getRpcTimeoutMultiplier()
RpcTimeoutMultiplier controls the change in RPC timeout. The timeout of the previous call is
multiplied by the RpcTimeoutMultiplier to calculate the timeout for the next call. The default
value is 1.0
.
Type | Description |
double |
getTotalTimeout()
public abstract Duration getTotalTimeout()
TotalTimeout has ultimate control over how long the logic should keep trying the remote call
until it gives up completely. The higher the total timeout, the more retries can be attempted.
The default value is Duration.ZERO
.
Type | Description |
org.threeten.bp.Duration |
isJittered() (deprecated)
public abstract boolean isJittered()
(deprecated) Retries always jitter.
Jitter determines if the delay time should be randomized. In most cases, if jitter is set totrue
the actual delay time is calculated in the following way:
actualDelay = rand_between(0, min(maxRetryDelay, delay))
The default value is true
.
Type | Description |
boolean |
newBuilder()
public static RetrySettings.Builder newBuilder()
Type | Description |
RetrySettings.Builder |
toBuilder()
public abstract RetrySettings.Builder toBuilder()
Type | Description |
RetrySettings.Builder |