Class RetrySettings.Builder (2.59.0)

public abstract static class RetrySettings.Builder

A base builder class for RetrySettings. See the class documentation of RetrySettings for a description of the different values that can be set.

Inheritance

java.lang.Object > RetrySettings.Builder

Constructors

Builder()

public Builder()

Methods

build()

public RetrySettings build()
Returns
Type Description
RetrySettings

getInitialRetryDelay()

public final Duration getInitialRetryDelay()

This method is obsolete. Use #getInitialRetryDelayDuration() instead

Returns
Type Description
org.threeten.bp.Duration

getInitialRetryDelayDuration()

public abstract Duration getInitialRetryDelayDuration()

InitialRetryDelay controls the delay before the first retry/ poll. Subsequent retries and polls will use this value adjusted according to the RetryDelayMultiplier.

If there are no configurations, Retries have the default initial retry delay value of Duration.ZERO and LROs have a default initial poll delay value of Duration.ofMillis(5000) (5 seconds).

Returns
Type Description
Duration

getInitialRpcTimeout()

public final Duration getInitialRpcTimeout()

This method is obsolete. Use #getInitialRpcTimeoutDuration() instead

Returns
Type Description
org.threeten.bp.Duration

getInitialRpcTimeoutDuration()

public abstract Duration getInitialRpcTimeoutDuration()

InitialRpcTimeout controls the timeout for the initial RPC. Subsequent calls will use this value adjusted according to the RpcTimeoutMultiplier. RPC Timeout value of Duration.ZERO allows the RPC to continue indefinitely (until it hits a Connect Timeout or the connection has been terminated).

#getTotalTimeout() caps how long the logic should keep trying the RPC until it gives up completely. If #getTotalTimeout() is set, initialRpcTimeout should be <= totalTimeout.

If there are no configurations, Retries have the default initial RPC timeout value of Duration.ZERO. LRO polling does not use the Initial RPC Timeout value.

Returns
Type Description
Duration

getMaxAttempts()

public abstract int getMaxAttempts()

MaxAttempts defines the maximum number of retry attempts to perform. If this value is set to 0, the logic will instead use the totalTimeout value to determine retries. In the event that both the maxAttempts and totalTimeout values are both 0, the logic will not retry. If this value is greater than 0, and the number of attempts exceeds this limit, the logic will give up retrying even if the total retry time is still lower than totalTimeout.

If there are no configurations, Retries and LROs have the default max attempt value of 0. LRO polling does not use this value by default.

The first RPC invocation will be considered attempt #0. Subsequent calls (retries) will increment the number of attempts and the number of attempts will not exceed this value.

Returns
Type Description
int

getMaxRetryDelay()

public final Duration getMaxRetryDelay()

This method is obsolete. Use #getMaxRetryDelayDuration() instead

Returns
Type Description
org.threeten.bp.Duration

getMaxRetryDelayDuration()

public abstract Duration getMaxRetryDelayDuration()

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.

If there are no configurations, Retries have the default max retry delay value of Duration.ZERO and LROs have a default max poll retry delay value of Duration.ofMillis(45000) (45 seconds).

Returns
Type Description
Duration

getMaxRpcTimeout()

public final Duration getMaxRpcTimeout()

This method is obsolete. Use #getMaxRpcTimeoutDuration() instead

Returns
Type Description
org.threeten.bp.Duration

getMaxRpcTimeoutDuration()

public abstract Duration getMaxRpcTimeoutDuration()

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.

If there are no configurations, Retries have the default Max RPC Timeout value of Duration.ZERO. LRO polling does not use the Max RPC Timeout value.

Returns
Type Description
Duration

getRetryDelayMultiplier()

public abstract double getRetryDelayMultiplier()

RetryDelayMultiplier controls the change in delay before the next retry or poll. The retry delay of the previous call is multiplied by the RetryDelayMultiplier to calculate the retry delay for the next call.

If there are no configurations, Retries have the default retry delay multiplier value of 1.0 and LROs have a default retry delay multiplier of 1.5.

Returns
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.

If there are no configurations, Retries have the default RPC Timeout Multiplier value of 1.0. LRO polling does not use the RPC Timeout Multiplier value.

Returns
Type Description
double

getTotalTimeout()

public final Duration getTotalTimeout()

This method is obsolete. Use #getTotalTimeoutDuration() instead

Returns
Type Description
org.threeten.bp.Duration

getTotalTimeoutDuration()

public abstract Duration getTotalTimeoutDuration()

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 and polls can be attempted. If this value is Duration.ZERO, then the logic will instead use the number of attempts to determine retries. In the event that both maxAttempts and totalTimeout values are both 0, the logic will not retry. If this value is non-Duration.ZERO, and the retry duration has reaches the timeout value, the logic will give up retrying even the number of attempts is lower than the maxAttempts value.

If there are no configurations, Retries have the default timeout value of Duration.ZERO and LROs have a default total timeout value of Duration.ofMillis(300000) (5 minutes).

Returns
Type Description
Duration

isJittered()

public abstract boolean isJittered()

Jitter determines if the delay time should be randomized. In most cases, if jitter is set to true the actual delay time is calculated in the following way:

actualDelay = rand_between(0, min(maxRetryDelay, exponentialDelay))

The default value is true.

Returns
Type Description
boolean

merge(RetrySettings.Builder newSettings)

public RetrySettings.Builder merge(RetrySettings.Builder newSettings)
Parameter
Name Description
newSettings RetrySettings.Builder
Returns
Type Description
RetrySettings.Builder

setInitialRetryDelay(Duration initialDelay)

public final RetrySettings.Builder setInitialRetryDelay(Duration initialDelay)

This method is obsolete. Use #setInitialRetryDelayDuration(java.time.Duration) instead

Parameter
Name Description
initialDelay org.threeten.bp.Duration
Returns
Type Description
RetrySettings.Builder

setInitialRetryDelayDuration(Duration initialDelay)

public abstract RetrySettings.Builder setInitialRetryDelayDuration(Duration initialDelay)

InitialRetryDelay controls the delay before the first retry/ poll. Subsequent retries and polls will use this value adjusted according to the RetryDelayMultiplier.

If there are no configurations, Retries have the default initial retry delay value of Duration.ZERO and LROs have a default initial poll delay value of Duration.ofMillis(5000) (5 seconds).

Parameter
Name Description
initialDelay Duration
Returns
Type Description
RetrySettings.Builder

setInitialRpcTimeout(Duration initialTimeout)

public final RetrySettings.Builder setInitialRpcTimeout(Duration initialTimeout)

This method is obsolete. Use #setInitialRpcTimeoutDuration(java.time.Duration) instead

Parameter
Name Description
initialTimeout org.threeten.bp.Duration
Returns
Type Description
RetrySettings.Builder

setInitialRpcTimeoutDuration(Duration initialTimeout)

public abstract RetrySettings.Builder setInitialRpcTimeoutDuration(Duration initialTimeout)

InitialRpcTimeout controls the timeout for the initial RPC. Subsequent calls will use this value adjusted according to the RpcTimeoutMultiplier. RPC Timeout value of Duration.ZERO allows the RPC to continue indefinitely (until it hits a Connect Timeout or the connection has been terminated).

#getTotalTimeout() caps how long the logic should keep trying the RPC until it gives up completely. If #getTotalTimeout() is set, initialRpcTimeout should be <= totalTimeout.

If there are no configurations, Retries have the default initial RPC timeout value of Duration.ZERO. LRO polling does not use the Initial RPC Timeout value.

Parameter
Name Description
initialTimeout Duration
Returns
Type Description
RetrySettings.Builder

setJittered(boolean jittered) (deprecated)

public abstract RetrySettings.Builder setJittered(boolean jittered)

Deprecated. Retries always jitter.

Jitter determines if the delay time should be randomized. If jitter is set to true the actual delay time is calculated in the following way:

actualDelay = rand_between(0, min(maxRetryDelay, exponentialDelay))

The default value is true, and this method will be a no-op soon.

Parameter
Name Description
jittered boolean
Returns
Type Description
RetrySettings.Builder

setLogicalTimeout(Duration timeout)

public RetrySettings.Builder setLogicalTimeout(Duration timeout)

Configures the timeout settings with the given timeout such that the logical call will take no longer than the given timeout and each RPC attempt will use only the time remaining in the logical call as a timeout.

Using this method in conjunction with individual RetrySettings timeout field setters is not advised, because only the order in which they are invoked determines which setter is respected.

Parameter
Name Description
timeout Duration
Returns
Type Description
RetrySettings.Builder

setLogicalTimeout(Duration timeout)

public RetrySettings.Builder setLogicalTimeout(Duration timeout)

This method is obsolete. Use #setLogicalTimeout(java.time.Duration) instead.

Parameter
Name Description
timeout org.threeten.bp.Duration
Returns
Type Description
RetrySettings.Builder

setMaxAttempts(int maxAttempts)

public abstract RetrySettings.Builder setMaxAttempts(int maxAttempts)

MaxAttempts defines the maximum number of retry attempts to perform. If this value is set to 0, the logic will instead use the totalTimeout value to determine retries. In the event that both the maxAttempts and totalTimeout values are both 0, the logic will not retry. If this value is greater than 0, and the number of attempts exceeds this limit, the logic will give up retrying even if the total retry time is still lower than totalTimeout.

If there are no configurations, Retries and LROs have the default max attempt value of 0. LRO polling does not use this value by default.

The first RPC invocation will be considered attempt #0. Subsequent calls (retries) will increment the number of attempts and the number of attempts will not exceed this value.

Parameter
Name Description
maxAttempts int
Returns
Type Description
RetrySettings.Builder

setMaxRetryDelay(Duration maxDelay)

public final RetrySettings.Builder setMaxRetryDelay(Duration maxDelay)

This method is obsolete. Use #setMaxRetryDelayDuration(java.time.Duration) instead

Parameter
Name Description
maxDelay org.threeten.bp.Duration
Returns
Type Description
RetrySettings.Builder

setMaxRetryDelayDuration(Duration maxDelay)

public abstract RetrySettings.Builder setMaxRetryDelayDuration(Duration maxDelay)

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.

If there are no configurations, Retries have the default max retry delay value of Duration.ZERO and LROs have a default max poll retry delay value of Duration.ofMillis(45000) (45 seconds).

Parameter
Name Description
maxDelay Duration
Returns
Type Description
RetrySettings.Builder

setMaxRpcTimeout(Duration maxTimeout)

public final RetrySettings.Builder setMaxRpcTimeout(Duration maxTimeout)

This method is obsolete. Use #setMaxRpcTimeoutDuration(java.time.Duration) instead

Parameter
Name Description
maxTimeout org.threeten.bp.Duration
Returns
Type Description
RetrySettings.Builder

setMaxRpcTimeoutDuration(Duration maxTimeout)

public abstract RetrySettings.Builder setMaxRpcTimeoutDuration(Duration maxTimeout)

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.

If there are no configurations, Retries have the default Max RPC Timeout value of Duration.ZERO. LRO polling does not use the Max RPC Timeout value.

Parameter
Name Description
maxTimeout Duration
Returns
Type Description
RetrySettings.Builder

setRetryDelayMultiplier(double multiplier)

public abstract RetrySettings.Builder setRetryDelayMultiplier(double multiplier)

RetryDelayMultiplier controls the change in delay before the next retry or poll. The retry delay of the previous call is multiplied by the RetryDelayMultiplier to calculate the retry delay for the next call.

If there are no configurations, Retries have the default retry delay multiplier value of 1.0 and LROs have a default retry delay multiplier of 1.5.

Parameter
Name Description
multiplier double
Returns
Type Description
RetrySettings.Builder

setRpcTimeoutMultiplier(double multiplier)

public abstract RetrySettings.Builder setRpcTimeoutMultiplier(double multiplier)

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.

If there are no configurations, Retries have the default RPC Timeout Multiplier value of 1.0. LRO polling does not use the RPC Timeout Multiplier value.

Parameter
Name Description
multiplier double
Returns
Type Description
RetrySettings.Builder

setTotalTimeout(Duration totalTimeout)

public final RetrySettings.Builder setTotalTimeout(Duration totalTimeout)

This method is obsolete. Use #setTotalTimeoutDuration(java.time.Duration) instead

Parameter
Name Description
totalTimeout org.threeten.bp.Duration
Returns
Type Description
RetrySettings.Builder

setTotalTimeoutDuration(Duration totalTimeout)

public abstract RetrySettings.Builder setTotalTimeoutDuration(Duration totalTimeout)

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 and polls can be attempted. If this value is Duration.ZERO, then the logic will instead use the number of attempts to determine retries. In the event that both maxAttempts and totalTimeout values are both 0, the logic will not retry. If this value is non-Duration.ZERO, and the retry duration has reaches the timeout value, the logic will give up retrying even the number of attempts is lower than the maxAttempts value.

If there are no configurations, Retries have the default timeout value of Duration.ZERO and LROs have a default total timeout value of Duration.ofMillis(300000) (5 minutes).

Parameter
Name Description
totalTimeout Duration
Returns
Type Description
RetrySettings.Builder