Class RetryPolicies.MultipleLinearRandomRetry

java.lang.Object
org.apache.hadoop.io.retry.RetryPolicies.MultipleLinearRandomRetry
All Implemented Interfaces:
RetryPolicy
Enclosing class:
RetryPolicies

public static class RetryPolicies.MultipleLinearRandomRetry extends Object implements RetryPolicy
Given pairs of number of retries and sleep time (n0, t0), (n1, t1), ..., the first n0 retries sleep t0 milliseconds on average, the following n1 retries sleep t1 milliseconds on average, and so on. For all the sleep, the actual sleep time is randomly uniform distributed in the close interval [0.5t, 1.5t], where t is the sleep time specified. The objects of this class are immutable.
  • Constructor Details

  • Method Details

    • shouldRetry

      public RetryPolicy.RetryAction shouldRetry(Exception e, int curRetry, int failovers, boolean isIdempotentOrAtMostOnce) throws Exception
      Description copied from interface: RetryPolicy

      Determines whether the framework should retry a method for the given exception, and the number of retries that have been made for that operation so far.

      Specified by:
      shouldRetry in interface RetryPolicy
      Parameters:
      e - The exception that caused the method to fail
      curRetry - The number of times the method has been retried
      failovers - The number of times the method has failed over to a different backend implementation
      isIdempotentOrAtMostOnce - true if the method is Idempotent or AtMostOnce and so can reasonably be retried on failover when we don't know if the previous attempt reached the server or not
      Returns:
      RetryPolicy.RetryAction with RetryDecision.FAIL if the method should not be retried, RetryDecision.RETRY if the method should be retried or RetryDecision.FAILOVER_AND_RETRY if failover has to be performed before retry.
      Throws:
      Exception - The re-thrown exception e indicating that the method failed and should not be retried further
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object that)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • parseCommaSeparatedString

      public static RetryPolicies.MultipleLinearRandomRetry parseCommaSeparatedString(String s)
      Parse the given string as a MultipleLinearRandomRetry object. The format of the string is "t_1, n_1, t_2, n_2, ...", where t_i and n_i are the i-th pair of sleep time and number of retries. Note that the white spaces in the string are ignored.
      Parameters:
      s - input string.
      Returns:
      the parsed object, or null if the parsing fails.