diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestFederationRMFailoverProxyProvider.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestFederationRMFailoverProxyProvider.java index 0a7ee3ff73..74cf5152d5 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestFederationRMFailoverProxyProvider.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestFederationRMFailoverProxyProvider.java @@ -107,7 +107,8 @@ private void testProxyProvider(boolean facadeFlushCache) throws Exception { conf.setBoolean(YarnConfiguration.FEDERATION_FLUSH_CACHE_FOR_RM_ADDR, facadeFlushCache); - conf.setBoolean(YarnConfiguration.RM_HA_ENABLED, true); + conf.setBoolean(YarnConfiguration.FEDERATION_ENABLED, true); + conf.setBoolean(YarnConfiguration.FEDERATION_FAILOVER_ENABLED, true); conf.setBoolean(YarnConfiguration.AUTO_FAILOVER_ENABLED, false); conf.set(YarnConfiguration.RM_CLUSTER_ID, "cluster1"); conf.set(YarnConfiguration.RM_HA_IDS, "rm1,rm2,rm3"); 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 eb39cc1344..95c8f2a01c 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 @@ -98,8 +98,7 @@ protected static T createRMProxy(final Configuration configuration, YarnConfiguration conf = (configuration instanceof YarnConfiguration) ? (YarnConfiguration) configuration : new YarnConfiguration(configuration); - RetryPolicy retryPolicy = createRetryPolicy(conf, - (HAUtil.isHAEnabled(conf) || HAUtil.isFederationFailoverEnabled(conf))); + RetryPolicy retryPolicy = createRetryPolicy(conf, isFailoverEnabled(conf)); return newProxyInstance(conf, protocol, instance, retryPolicy); } @@ -126,7 +125,7 @@ private static T newProxyInstance(final YarnConfiguration conf, final Class protocol, RMProxy instance, RetryPolicy retryPolicy) throws IOException{ RMFailoverProxyProvider provider; - if (HAUtil.isHAEnabled(conf) || HAUtil.isFederationEnabled(conf)) { + if (isFailoverEnabled(conf)) { provider = instance.createRMFailoverProxyProvider(conf, protocol); } else { provider = instance.createNonHaRMFailoverProxyProvider(conf, protocol); @@ -303,4 +302,17 @@ protected static RetryPolicy createRetryPolicy(Configuration conf, return RetryPolicies.retryOtherThanRemoteAndSaslException( RetryPolicies.TRY_ONCE_THEN_FAIL, exceptionToPolicyMap); } + + private static boolean isFailoverEnabled(YarnConfiguration conf) { + if (HAUtil.isHAEnabled(conf)) { + // Considering Resource Manager HA is enabled. + return true; + } + if (HAUtil.isFederationEnabled(conf) && HAUtil.isFederationFailoverEnabled(conf)) { + // Considering both federation and federation failover are enabled. + return true; + } + return false; + } + }