Package org.apache.hadoop.io.retry
Class RetryPolicies.MultipleLinearRandomRetry
java.lang.Object
org.apache.hadoop.io.retry.RetryPolicies.MultipleLinearRandomRetry
- All Implemented Interfaces:
RetryPolicy
- Enclosing class:
- RetryPolicies
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classPairs of numRetries and sleepSecondsNested classes/interfaces inherited from interface org.apache.hadoop.io.retry.RetryPolicy
RetryPolicy.RetryAction -
Constructor Summary
ConstructorsConstructorDescription -
Method Summary
Modifier and TypeMethodDescriptionbooleaninthashCode()Parse the given string as a MultipleLinearRandomRetry object.shouldRetry(Exception e, int curRetry, int failovers, boolean isIdempotentOrAtMostOnce) 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.toString()
-
Constructor Details
-
MultipleLinearRandomRetry
-
-
Method Details
-
shouldRetry
public RetryPolicy.RetryAction shouldRetry(Exception e, int curRetry, int failovers, boolean isIdempotentOrAtMostOnce) throws Exception Description copied from interface:RetryPolicyDetermines 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:
shouldRetryin interfaceRetryPolicy- Parameters:
e- The exception that caused the method to failcurRetry- The number of times the method has been retriedfailovers- The number of times the method has failed over to a different backend implementationisIdempotentOrAtMostOnce-trueif the method isIdempotentorAtMostOnceand so can reasonably be retried on failover when we don't know if the previous attempt reached the server or not- Returns:
RetryPolicy.RetryActionwithRetryDecision.FAILif the method should not be retried,RetryDecision.RETRYif the method should be retried orRetryDecision.FAILOVER_AND_RETRYif failover has to be performed before retry.- Throws:
Exception- The re-thrown exceptioneindicating that the method failed and should not be retried further
-
hashCode
public int hashCode() -
equals
-
toString
-
parseCommaSeparatedString
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.
-