org.apache.hadoop.io.retry
Class RetryPolicies.MultipleLinearRandomRetry

java.lang.Object
  extended by 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.


Nested Class Summary
static class RetryPolicies.MultipleLinearRandomRetry.Pair
          Pairs of numRetries and sleepSeconds
 
Constructor Summary
RetryPolicies.MultipleLinearRandomRetry(List<RetryPolicies.MultipleLinearRandomRetry.Pair> pairs)
           
 
Method Summary
 boolean equals(Object that)
           
 int hashCode()
           
static RetryPolicies.MultipleLinearRandomRetry parseCommaSeparatedString(String s)
          Parse the given string as a MultipleLinearRandomRetry object.
 boolean shouldRetry(Exception e, int curRetry)
           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.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RetryPolicies.MultipleLinearRandomRetry

public RetryPolicies.MultipleLinearRandomRetry(List<RetryPolicies.MultipleLinearRandomRetry.Pair> pairs)
Method Detail

shouldRetry

public boolean shouldRetry(Exception e,
                           int curRetry)
                    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.
Returns:
true if the method should be retried, false if the method should not be retried but shouldn't fail with an exception (only for void methods).
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 retires. Note that the white spaces in the string are ignored.

Returns:
the parsed object, or null if the parsing fails.


Copyright © 2009 The Apache Software Foundation