From 624703ed7b6d80855d3e0567bee5c1b7659bc635 Mon Sep 17 00:00:00 2001 From: Karthik Kambatla Date: Sat, 21 Dec 2013 16:29:10 +0000 Subject: [PATCH] YARN-1028. Addendum patch. Added FailoverProxyProvider capability to ResourceManager to help with RM failover. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1552920 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/hadoop/io/retry/RetryPolicies.java | 15 --------------- .../apache/hadoop/yarn/client/TestRMFailover.java | 2 -- .../org/apache/hadoop/yarn/client/RMProxy.java | 12 +++++------- 3 files changed, 5 insertions(+), 24 deletions(-) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/RetryPolicies.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/RetryPolicies.java index e2770030b11..3d5992716f4 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/RetryPolicies.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/RetryPolicies.java @@ -69,13 +69,6 @@ public class RetryPolicies { */ public static final RetryPolicy RETRY_FOREVER = new RetryForever(); - /** - *

- * Keep failing over forever - *

- */ - public static final RetryPolicy FAILOVER_FOREVER = new FailoverForever(); - /** *

* Keep trying a limited number of times, waiting a fixed time between attempts, @@ -173,14 +166,6 @@ public class RetryPolicies { return RetryAction.RETRY; } } - - static class FailoverForever implements RetryPolicy { - @Override - public RetryAction shouldRetry(Exception e, int retries, int failovers, - boolean isIdempotentOrAtMostOnce) throws Exception { - return RetryAction.FAILOVER_AND_RETRY; - } - } /** * Retry up to maxRetries. diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestRMFailover.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestRMFailover.java index 8545a1a2839..fed26d7f5aa 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestRMFailover.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestRMFailover.java @@ -86,9 +86,7 @@ public class TestRMFailover { setRpcAddressForRM(RM1_NODE_ID, RM1_PORT_BASE); setRpcAddressForRM(RM2_NODE_ID, RM2_PORT_BASE); - conf.setInt(YarnConfiguration.CLIENT_FAILOVER_MAX_ATTEMPTS, 100); conf.setLong(YarnConfiguration.CLIENT_FAILOVER_SLEEPTIME_BASE_MS, 100L); - conf.setLong(YarnConfiguration.CLIENT_FAILOVER_SLEEPTIME_MAX_MS, 1000L); conf.setBoolean(YarnConfiguration.YARN_MINICLUSTER_FIXED_PORTS, true); conf.setBoolean(YarnConfiguration.YARN_MINICLUSTER_USE_RPC, true); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/client/RMProxy.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/client/RMProxy.java index 1651c13100c..913eb04613c 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/client/RMProxy.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/client/RMProxy.java @@ -225,19 +225,17 @@ public class RMProxy { int maxFailoverAttempts = conf.getInt( YarnConfiguration.CLIENT_FAILOVER_MAX_ATTEMPTS, -1); - RetryPolicy basePolicy = RetryPolicies.TRY_ONCE_THEN_FAIL; if (maxFailoverAttempts == -1) { if (waitForEver) { - basePolicy = RetryPolicies.FAILOVER_FOREVER; + maxFailoverAttempts = Integer.MAX_VALUE; } else { - basePolicy = new FailoverUptoMaximumTimePolicy( - System.currentTimeMillis() + rmConnectWaitMS); + maxFailoverAttempts = (int) (rmConnectWaitMS / failoverSleepBaseMs); } - maxFailoverAttempts = 0; } - return RetryPolicies.failoverOnNetworkException(basePolicy, - maxFailoverAttempts, failoverSleepBaseMs, failoverSleepMaxMs); + return RetryPolicies.failoverOnNetworkException( + RetryPolicies.TRY_ONCE_THEN_FAIL, maxFailoverAttempts, + failoverSleepBaseMs, failoverSleepMaxMs); } if (waitForEver) {