Interface BackOff

All Known Implementing Classes:
ExponentialBackOff, MockBackOff

public interface BackOff
Back-off policy when retrying an operation.
Since:
1.15
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final long
    Indicates that no more retries should be made for use in nextBackOffMillis().
    static final BackOff
    Fixed back-off policy that always returns #STOP for nextBackOffMillis(), meaning that the operation should not be retried.
    static final BackOff
    Fixed back-off policy whose back-off time is always zero, meaning that the operation is retried immediately without waiting.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Gets the number of milliseconds to wait before retrying the operation or STOP to indicate that no retries should be made.
    void
    Reset to initial state.
  • Field Details

    • STOP

      static final long STOP
      Indicates that no more retries should be made for use in nextBackOffMillis().
      See Also:
    • ZERO_BACKOFF

      static final BackOff ZERO_BACKOFF
      Fixed back-off policy whose back-off time is always zero, meaning that the operation is retried immediately without waiting.
    • STOP_BACKOFF

      static final BackOff STOP_BACKOFF
      Fixed back-off policy that always returns #STOP for nextBackOffMillis(), meaning that the operation should not be retried.
  • Method Details

    • reset

      void reset() throws IOException
      Reset to initial state.
      Throws:
      IOException
    • nextBackOffMillis

      long nextBackOffMillis() throws IOException
      Gets the number of milliseconds to wait before retrying the operation or STOP to indicate that no retries should be made.

      Example usage:

         long backOffMillis = backoff.nextBackOffMillis();
         if (backOffMillis == Backoff.STOP) {
           // do not retry operation
         } else {
           // sleep for backOffMillis milliseconds and retry operation
         }
       
      Throws:
      IOException