|
@@ -116,6 +116,41 @@ public class RMProxy<T> {
|
|
|
return newProxyInstance(conf, protocol, instance, retryPolicy);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * This functionality is only used for NodeManager and only in non-HA mode.
|
|
|
+ * Its purpose is to ensure that when initializes UAM, it can find the correct cluster.
|
|
|
+ *
|
|
|
+ * @param configuration configuration.
|
|
|
+ * @param protocol protocol.
|
|
|
+ * @param instance RMProxy instance.
|
|
|
+ * @return RMProxy.
|
|
|
+ * @param <T> Generic T.
|
|
|
+ * @throws IOException io error occur.
|
|
|
+ */
|
|
|
+ protected static <T> T createRMProxyFederation(final Configuration configuration,
|
|
|
+ final Class<T> protocol, RMProxy<T> instance) throws IOException {
|
|
|
+ YarnConfiguration yarnConf = new YarnConfiguration(configuration);
|
|
|
+ RetryPolicy retryPolicy = createRetryPolicy(yarnConf, isFailoverEnabled(yarnConf));
|
|
|
+ return newProxyInstanceFederation(yarnConf, protocol, instance, retryPolicy);
|
|
|
+ }
|
|
|
+
|
|
|
+ protected static <T> T newProxyInstanceFederation(final YarnConfiguration conf,
|
|
|
+ final Class<T> protocol, RMProxy<T> instance, RetryPolicy retryPolicy) {
|
|
|
+ RMFailoverProxyProvider<T> provider = getRMFailoverProxyProvider(conf, protocol, instance);
|
|
|
+ return (T) RetryProxy.create(protocol, provider, retryPolicy);
|
|
|
+ }
|
|
|
+
|
|
|
+ protected static <T> RMFailoverProxyProvider<T> getRMFailoverProxyProvider(
|
|
|
+ final YarnConfiguration conf, final Class<T> protocol, RMProxy<T> instance) {
|
|
|
+ RMFailoverProxyProvider<T> provider;
|
|
|
+ if (isFederationNonHAEnabled(conf)) {
|
|
|
+ provider = instance.createRMFailoverProxyProvider(conf, protocol);
|
|
|
+ } else {
|
|
|
+ provider = instance.createNonHaRMFailoverProxyProvider(conf, protocol);
|
|
|
+ }
|
|
|
+ return provider;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Currently, used by NodeManagers only.
|
|
|
* Create a proxy for the specified protocol. For non-HA,
|
|
@@ -355,4 +390,24 @@ public class RMProxy<T> {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * If RM is not configured with HA, NM will not configure yarn.resourcemanager.ha.rmIds locally.
|
|
|
+ *
|
|
|
+ * If federation mode is enabled and RMProxy#isFailoverEnabled returns true,
|
|
|
+ * when NM starts Container, it will try to find the yarn.resourcemanager.ha.rmIds property.
|
|
|
+ *
|
|
|
+ * However, an error will occur because this property is not configured
|
|
|
+ * if the user has not configured HA.
|
|
|
+ *
|
|
|
+ * To solve this issue, we can configure the yarn.federation.no-ha.enabled property in NM,
|
|
|
+ * which tells NM to run in a non-HA environment.
|
|
|
+ *
|
|
|
+ * @param conf YarnConfiguration
|
|
|
+ * @return true, federation support non-HA, false, federation not support non-HA.
|
|
|
+ */
|
|
|
+ private static boolean isFederationNonHAEnabled(YarnConfiguration conf) {
|
|
|
+ boolean isNonHAEnabled = conf.getBoolean(YarnConfiguration.FEDERATION_NON_HA_ENABLED,
|
|
|
+ YarnConfiguration.DEFAULT_FEDERATION_NON_HA_ENABLED);
|
|
|
+ return isNonHAEnabled;
|
|
|
+ }
|
|
|
}
|