Class MockBackOff

  • All Implemented Interfaces:
    BackOff

    @Beta
    public class MockBackOff
    extends Object
    implements BackOff
    Beta
    Mock for BackOff that always returns a fixed number.

    Implementation is not thread-safe.

    Since:
    1.15
    Author:
    Yaniv Inbar
    • Constructor Detail

      • MockBackOff

        public MockBackOff()
    • Method Detail

      • nextBackOffMillis

        public long nextBackOffMillis()
                               throws IOException
        Description copied from interface: BackOff
        Gets the number of milliseconds to wait before retrying the operation or BackOff.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
           }
         
        Specified by:
        nextBackOffMillis in interface BackOff
        Throws:
        IOException
      • setBackOffMillis

        public MockBackOff setBackOffMillis​(long backOffMillis)
        Sets the fixed back-off milliseconds (defaults to 0).

        Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.

      • setMaxTries

        public MockBackOff setMaxTries​(int maxTries)
        Sets the maximum number of tries before returning BackOff.STOP (defaults to 10).

        Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.

      • getMaxTries

        public final int getMaxTries()
        Returns the maximum number of tries before returning BackOff.STOP.
      • getNumberOfTries

        public final int getNumberOfTries()
        Returns the number of tries so far.