Class Retry.JitterRetryPolicy

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
The following delays will be used for each call:
  • Initial call - always immediate (not handled by retry policy)
  • First retry: 50 (inclusive) - 150 (exclusive) millis
  • Second retry: 50 (inclusive) - 150 (exclusive) millis
  • Third retry: 50 (inclusive) - 150 (exclusive) millis
The final non-negative delay, including jitter, is capped by the configured maximum delay.
  • Method Details

    • builder

      public static Retry.JitterRetryPolicy.Builder builder()
      A new fluent API builder to configure instances of Retry.
      Returns:
      a new builder
    • nextDelayMillis

      public Optional<Long> nextDelayMillis(long firstCallMillis, 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 interface Retry.RetryPolicy
      Parameters:
      firstCallMillis - milliseconds recorded before the first call using System.currentTimeMillis()
      lastDelay - last delay that was used (0 for the first failed call)
      call - number of completed calls (1 for the first failed invocation)
      Returns:
      how long to wait before trying again, or empty to notify this is the end of retries
    • equals

      public boolean equals(Object object)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object