From 2636b630b4f71bf04c1a76981e51b937e830578f Mon Sep 17 00:00:00 2001 From: Jim Brennan Date: Tue, 15 Jun 2021 18:58:42 +0000 Subject: [PATCH] YARN-10767. Yarn Logs Command retrying on Standby RM for 30 times. Contributed by D M Murali Krishna Reddy. (cherry picked from commit 9a6a11c4522f34fa4245983d8719675036879d7a) --- .../apache/hadoop/yarn/util/RMHAUtils.java | 3 ++- .../hadoop/yarn/webapp/util/WebAppUtils.java | 26 +++++++------------ 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/RMHAUtils.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/RMHAUtils.java index 2e996e90ee8..1c379409c22 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/RMHAUtils.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/RMHAUtils.java @@ -23,6 +23,7 @@ import java.util.Collection; import java.util.List; import org.apache.hadoop.classification.InterfaceAudience.Private; import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.CommonConfigurationKeys; import org.apache.hadoop.ha.HAServiceProtocol; import org.apache.hadoop.ha.HAServiceProtocol.HAServiceState; @@ -35,7 +36,7 @@ import org.apache.hadoop.yarn.conf.YarnConfiguration; @Unstable public class RMHAUtils { - public static String findActiveRMHAId(YarnConfiguration conf) { + public static String findActiveRMHAId(Configuration conf) { YarnConfiguration yarnConf = new YarnConfiguration(conf); Collection rmIds = yarnConf.getStringCollection(YarnConfiguration.RM_HA_IDS); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/webapp/util/WebAppUtils.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/webapp/util/WebAppUtils.java index 09daf424d15..5b578197100 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/webapp/util/WebAppUtils.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/webapp/util/WebAppUtils.java @@ -20,6 +20,7 @@ package org.apache.hadoop.yarn.webapp.util; import static org.apache.hadoop.yarn.util.StringHelper.PATH_JOINER; import java.io.IOException; +import java.net.ConnectException; import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.UnknownHostException; @@ -97,24 +98,17 @@ public class WebAppUtils { */ public static R execOnActiveRM(Configuration conf, ThrowingBiFunction func, T arg) throws Exception { - String rm1Address = getRMWebAppURLWithScheme(conf, 0); - try { - return func.apply(rm1Address, arg); - } catch (Exception e) { - if (HAUtil.isHAEnabled(conf)) { - int rms = HAUtil.getRMHAIds(conf).size(); - for (int i=1; i(HAUtil.getRMHAIds(conf)).indexOf(activeRMId); + } else { + throw new ConnectException("No Active RM available"); } - throw e; } + String rm1Address = getRMWebAppURLWithScheme(conf, haIndex); + return func.apply(rm1Address, arg); } /** A BiFunction which throws on Exception. */