You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by to...@apache.org on 2014/02/05 05:18:11 UTC
svn commit: r1564627 -
/hadoop/common/branches/branch-2.3/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/RetryPolicies.java
Author: todd
Date: Wed Feb 5 04:18:11 2014
New Revision: 1564627
URL: http://svn.apache.org/r1564627
Log:
HDFS-5399. Revisit SafeModeException and corresponding retry policies. Contributed by Haohui Mai.
Modified:
hadoop/common/branches/branch-2.3/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/RetryPolicies.java
Modified: hadoop/common/branches/branch-2.3/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/RetryPolicies.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.3/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/RetryPolicies.java?rev=1564627&r1=1564626&r2=1564627&view=diff
==============================================================================
--- hadoop/common/branches/branch-2.3/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/RetryPolicies.java (original)
+++ hadoop/common/branches/branch-2.3/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/RetryPolicies.java Wed Feb 5 04:18:11 2014
@@ -151,6 +151,13 @@ public class RetryPolicies {
delayMillis, maxDelayBase);
}
+ public static final RetryPolicy failoverOnNetworkException(
+ RetryPolicy fallbackPolicy, int maxFailovers, int maxRetries,
+ long delayMillis, long maxDelayBase) {
+ return new FailoverOnNetworkExceptionRetry(fallbackPolicy, maxFailovers,
+ maxRetries, delayMillis, maxDelayBase);
+ }
+
static class TryOnceThenFail implements RetryPolicy {
@Override
public RetryAction shouldRetry(Exception e, int retries, int failovers,
@@ -516,18 +523,25 @@ public class RetryPolicies {
private RetryPolicy fallbackPolicy;
private int maxFailovers;
+ private int maxRetries;
private long delayMillis;
private long maxDelayBase;
public FailoverOnNetworkExceptionRetry(RetryPolicy fallbackPolicy,
int maxFailovers) {
- this(fallbackPolicy, maxFailovers, 0, 0);
+ this(fallbackPolicy, maxFailovers, 0, 0, 0);
}
public FailoverOnNetworkExceptionRetry(RetryPolicy fallbackPolicy,
int maxFailovers, long delayMillis, long maxDelayBase) {
+ this(fallbackPolicy, maxFailovers, 0, delayMillis, maxDelayBase);
+ }
+
+ public FailoverOnNetworkExceptionRetry(RetryPolicy fallbackPolicy,
+ int maxFailovers, int maxRetries, long delayMillis, long maxDelayBase) {
this.fallbackPolicy = fallbackPolicy;
this.maxFailovers = maxFailovers;
+ this.maxRetries = maxRetries;
this.delayMillis = delayMillis;
this.maxDelayBase = maxDelayBase;
}
@@ -549,6 +563,10 @@ public class RetryPolicies {
"failovers (" + failovers + ") exceeded maximum allowed ("
+ maxFailovers + ")");
}
+ if (retries - failovers > maxRetries) {
+ return new RetryAction(RetryAction.RetryDecision.FAIL, 0, "retries ("
+ + retries + ") exceeded maximum allowed (" + maxRetries + ")");
+ }
if (e instanceof ConnectException ||
e instanceof NoRouteToHostException ||