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 e2770030b1..3d5992716f 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 @@ protected Random initialValue() { */ 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 RetryAction shouldRetry(Exception e, int retries, int failovers, 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 8545a1a283..fed26d7f5a 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 static void setup() throws IOException { 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 1651c13100..913eb04613 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 static RetryPolicy createRetryPolicy(Configuration conf) { 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) {