- java.lang.Object
-
- io.helidon.faulttolerance.Retry.JitterRetryPolicy
-
- All Implemented Interfaces:
Retry.RetryPolicy
- Enclosing interface:
- Retry
public static class Retry.JitterRetryPolicy extends Object implements Retry.RetryPolicy
A retry policy that randomizes delays between execution using a "jitter" time.Consider the following setup:
calls = 4
delayMillis = 100
jitter = 50
- Initial call - always immediate (not handled by retry policy)
- First retry: 50 - 150 millis (delay +- Random.nextInt(jitter)
- Second retry: 50 - 150 millis
- Third retry: 50 - 150 millis
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Retry.JitterRetryPolicy.Builder
Fluent API builder forRetry.JitterRetryPolicy
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Retry.JitterRetryPolicy.Builder
builder()
Optional<Long>
nextDelayMillis(long firstCallNanos, long lastDelay, int call)
Return next delay in milliseconds, or an empty optional to finish retries.
-
-
-
Method Detail
-
builder
public static Retry.JitterRetryPolicy.Builder builder()
-
nextDelayMillis
public Optional<Long> nextDelayMillis(long firstCallNanos, long lastDelay, int call)
Description copied from interface:Retry.RetryPolicy
Return next delay in milliseconds, or an empty optional to finish retries.- Specified by:
nextDelayMillis
in interfaceRetry.RetryPolicy
- Parameters:
firstCallNanos
- milliseconds recorded before the first call usingSystem.currentTimeMillis()
lastDelay
- last delay that was used (0 for the first failed call)call
- call index (0 for the first failed call)- Returns:
- how long to wait before trying again, or empty to notify this is the end of retries
-
-