public interface Jitter
Strategy interface for applying jitter to exponential backoff calculations.
Author:
Bruno Garcia, Rafael Pavarini, Tomaz Fernandes
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static class 
    Context for jitter calculations.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Jitter
    Full jitter strategy - returns a random value between 0 and the original timeout.
    static final Jitter
    Half jitter strategy - returns a value uniformly between ceil(timeout/2) and timeout.
    static final Jitter
    No jitter strategy - returns the original timeout value.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Apply jitter to the calculated timeout value.
  • Field Details

    • NONE

      static final Jitter NONE
      No jitter strategy - returns the original timeout value. The original timeout value is expected to be valid (greater than 0) as it's validated in the builder.
    • FULL

      static final Jitter FULL
      Full jitter strategy - returns a random value between 0 and the original timeout. Ensures the result is at least 1 to avoid invalid timeout values.
    • HALF

      static final Jitter HALF
      Half jitter strategy - returns a value uniformly between ceil(timeout/2) and timeout. Ensures the result is at least 1 to avoid invalid timeout values.
  • Method Details

    • applyJitter

      int applyJitter(Jitter.Context context)
      Apply jitter to the calculated timeout value.
      Parameters:
      context - the jitter context containing timeout and random supplier
      Returns:
      the timeout value with jitter applied