Record Class RetryPolicy
java.lang.Object
java.lang.Record
org.openspaces.core.multicluster.internal.health.RetryPolicy
- Record Components:
maxAttempts- total attempts including the first,>= 1initialBackoff- delay before the second attemptmaxBackoff- ceiling for the delay, however many attempts have failedmultiplier- factor applied per attempt,>= 1.0jitter- fraction of the delay to randomise,0.0to1.0
public record RetryPolicy(int maxAttempts, Duration initialBackoff, Duration maxBackoff, double multiplier, double jitter)
extends Record
Exponential backoff with jitter, for retrying a mutation against a cluster that was briefly unavailable.
The jitter matters more than it looks. Without it, every client that lost the same cluster retries on exactly the same schedule, so the cluster comes back up into a synchronised thundering herd and falls over again. Spreading each delay randomly across a band breaks that lockstep.
-
Constructor Summary
ConstructorsConstructorDescriptionRetryPolicy(int maxAttempts, Duration initialBackoff, Duration maxBackoff, double multiplier, double jitter) Creates an instance of aRetryPolicyrecord class. -
Method Summary
Modifier and TypeMethodDescriptionbackoffFor(int attempt) How long to wait before attempt numberattempt(1-based, sobackoffFor(1)is the pause after the first failure).static RetryPolicydefaults()Three attempts, 100 ms growing to 5 s, jittered by a fifth.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.Returns the value of theinitialBackoffrecord component.doublejitter()Returns the value of thejitterrecord component.intReturns the value of themaxAttemptsrecord component.Returns the value of themaxBackoffrecord component.doubleReturns the value of themultiplierrecord component.static RetryPolicynoRetry()A policy that never retries - one attempt and done.static RetryPolicyquiesce()A maintenance window's worth of patience: up to 60 attempts, 1 s growing to 30 s, jittered.booleanshouldRetry(int attemptsSoFar) Whether another attempt is allowed afterattemptsSoFarhave failed.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
RetryPolicy
public RetryPolicy(int maxAttempts, Duration initialBackoff, Duration maxBackoff, double multiplier, double jitter) Creates an instance of aRetryPolicyrecord class.- Parameters:
maxAttempts- the value for themaxAttemptsrecord componentinitialBackoff- the value for theinitialBackoffrecord componentmaxBackoff- the value for themaxBackoffrecord componentmultiplier- the value for themultiplierrecord componentjitter- the value for thejitterrecord component
-
-
Method Details
-
defaults
Three attempts, 100 ms growing to 5 s, jittered by a fifth. -
quiesce
A maintenance window's worth of patience: up to 60 attempts, 1 s growing to 30 s, jittered.For a quiesced cluster the short transport budget is exactly wrong - the cluster is alive and deliberately refusing writes for as long as an operator needs, and giving up after three attempts would guarantee the divergence the retry exists to prevent.
-
noRetry
A policy that never retries - one attempt and done. -
shouldRetry
public boolean shouldRetry(int attemptsSoFar) Whether another attempt is allowed afterattemptsSoFarhave failed. -
backoffFor
How long to wait before attempt numberattempt(1-based, sobackoffFor(1)is the pause after the first failure). -
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
maxAttempts
public int maxAttempts()Returns the value of themaxAttemptsrecord component.- Returns:
- the value of the
maxAttemptsrecord component
-
initialBackoff
Returns the value of theinitialBackoffrecord component.- Returns:
- the value of the
initialBackoffrecord component
-
maxBackoff
Returns the value of themaxBackoffrecord component.- Returns:
- the value of the
maxBackoffrecord component
-
multiplier
public double multiplier()Returns the value of themultiplierrecord component.- Returns:
- the value of the
multiplierrecord component
-
jitter
-