YARN-11237. Fix Bug while disabling proxy failover with Federation (#4658)

This commit is contained in:
Ashutosh Gupta 2022-08-08 21:29:27 +01:00 committed by GitHub
parent 977f4b6165
commit 92abd99450
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 4 deletions

View File

@ -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");

View File

@ -98,8 +98,7 @@ protected static <T> 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> T newProxyInstance(final YarnConfiguration conf,
final Class<T> protocol, RMProxy<T> instance, RetryPolicy retryPolicy)
throws IOException{
RMFailoverProxyProvider<T> 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;
}
}