Class RetrySchedule
java.lang.Object
io.github.flink.gcp.connector.base.retry.RetrySchedule
An immutable retry schedule: exponential backoff from an initial delay up to a cap, a bounded
number of attempts, and optional proportional jitter (to de-synchronize parallel subtasks
retrying against the same destination).
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleThe jitter every schedule in this project uses, unless it has a recorded reason not to. -
Constructor Summary
ConstructorsConstructorDescriptionRetrySchedule(long initialBackoffMs, long maxBackoffMs, int maxAttempts, double jitterRatio) Creates a schedule. -
Method Summary
Modifier and TypeMethodDescriptionlongbackoffMs(int attempt) Returns the jittered backoff after the given attempt (1-based): the initial delay doubled per attempt up to the cap, multiplied by a random factor in[1 - jitterRatio, 1 + jitterRatio].doubleReturns the proportional jitter applied to each backoff.intReturns the maximum number of attempts.
-
Field Details
-
DEFAULT_JITTER_RATIO
public static final double DEFAULT_JITTER_RATIOThe jitter every schedule in this project uses, unless it has a recorded reason not to.One number rather than a per-site choice, because the value is not load-bearing: the jitter is mean-preserving (the backoff is multiplied by a factor in
[1 - ratio, 1 + ratio], so the expected delay stays the design value) and all it has to do is break the synchronization between parallel subtasks retrying against the same destination. Only being non-zero serves that purpose, so a site picking its own ratio would be picking a number nothing distinguishes.Not a builder knob on any connector's options: there is no workload for which a particular ratio is the right answer, which is the test the
recovery*andretry*knobs pass and this does not.- See Also:
-
-
Constructor Details
-
RetrySchedule
public RetrySchedule(long initialBackoffMs, long maxBackoffMs, int maxAttempts, double jitterRatio) Creates a schedule.- Parameters:
initialBackoffMs- the first backoffmaxBackoffMs- the backoff capmaxAttempts- the maximum number of attemptsjitterRatio- the proportional jitter, in[0, 1)
-
-
Method Details
-
maxAttempts
public int maxAttempts()Returns the maximum number of attempts. -
jitterRatio
public double jitterRatio()Returns the proportional jitter applied to each backoff. -
backoffMs
public long backoffMs(int attempt) Returns the jittered backoff after the given attempt (1-based): the initial delay doubled per attempt up to the cap, multiplied by a random factor in[1 - jitterRatio, 1 + jitterRatio].
-