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/branches/branch-2@1552921 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Karthik Kambatla 2013-12-21 16:30:06 +00:00
parent 68164b197b
commit 2dc61dea3c
3 changed files with 5 additions and 24 deletions

View File

@ -69,13 +69,6 @@ public class RetryPolicies {
*/ */
public static final RetryPolicy RETRY_FOREVER = new RetryForever(); public static final RetryPolicy RETRY_FOREVER = new RetryForever();
/**
* <p>
* Keep failing over forever
* </p>
*/
public static final RetryPolicy FAILOVER_FOREVER = new FailoverForever();
/** /**
* <p> * <p>
* Keep trying a limited number of times, waiting a fixed time between attempts, * Keep trying a limited number of times, waiting a fixed time between attempts,
@ -174,14 +167,6 @@ public class RetryPolicies {
} }
} }
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. * Retry up to maxRetries.
* The actual sleep time of the n-th retry is f(n, sleepTime), * The actual sleep time of the n-th retry is f(n, sleepTime),

View File

@ -86,9 +86,7 @@ public class TestRMFailover {
setRpcAddressForRM(RM1_NODE_ID, RM1_PORT_BASE); setRpcAddressForRM(RM1_NODE_ID, RM1_PORT_BASE);
setRpcAddressForRM(RM2_NODE_ID, RM2_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_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_FIXED_PORTS, true);
conf.setBoolean(YarnConfiguration.YARN_MINICLUSTER_USE_RPC, true); conf.setBoolean(YarnConfiguration.YARN_MINICLUSTER_USE_RPC, true);

View File

@ -225,19 +225,17 @@ public class RMProxy<T> {
int maxFailoverAttempts = conf.getInt( int maxFailoverAttempts = conf.getInt(
YarnConfiguration.CLIENT_FAILOVER_MAX_ATTEMPTS, -1); YarnConfiguration.CLIENT_FAILOVER_MAX_ATTEMPTS, -1);
RetryPolicy basePolicy = RetryPolicies.TRY_ONCE_THEN_FAIL;
if (maxFailoverAttempts == -1) { if (maxFailoverAttempts == -1) {
if (waitForEver) { if (waitForEver) {
basePolicy = RetryPolicies.FAILOVER_FOREVER; maxFailoverAttempts = Integer.MAX_VALUE;
} else { } else {
basePolicy = new FailoverUptoMaximumTimePolicy( maxFailoverAttempts = (int) (rmConnectWaitMS / failoverSleepBaseMs);
System.currentTimeMillis() + rmConnectWaitMS);
} }
maxFailoverAttempts = 0;
} }
return RetryPolicies.failoverOnNetworkException(basePolicy, return RetryPolicies.failoverOnNetworkException(
maxFailoverAttempts, failoverSleepBaseMs, failoverSleepMaxMs); RetryPolicies.TRY_ONCE_THEN_FAIL, maxFailoverAttempts,
failoverSleepBaseMs, failoverSleepMaxMs);
} }
if (waitForEver) { if (waitForEver) {