From 8739c4d2f864059cf1944515452b448e6c0dc7d9 Mon Sep 17 00:00:00 2001 From: Jason Lowe Date: Thu, 25 May 2017 16:07:52 -0500 Subject: [PATCH] YARN-6643. TestRMFailover fails rarely due to port conflict. Contributed by Robert Kanter (cherry picked from commit 3fd6a2da4e537423d1462238e10cc9e1f698d1c2) --- .../hadoop/yarn/server/resourcemanager/HATestUtil.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/HATestUtil.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/HATestUtil.java index 710ce8704a2..ac245c3207d 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/HATestUtil.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/HATestUtil.java @@ -18,16 +18,19 @@ package org.apache.hadoop.yarn.server.resourcemanager; import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.net.ServerSocketUtil; import org.apache.hadoop.yarn.conf.HAUtil; import org.apache.hadoop.yarn.conf.YarnConfiguration; +import java.io.IOException; + public class HATestUtil { public static void setRpcAddressForRM(String rmId, int base, - Configuration conf) { + Configuration conf) throws IOException { for (String confKey : YarnConfiguration.getServiceAddressConfKeys(conf)) { - setConfForRM(rmId, confKey, "0.0.0.0:" + (base + - YarnConfiguration.getRMDefaultPortNumber(confKey, conf)), conf); + setConfForRM(rmId, confKey, "0.0.0.0:" + ServerSocketUtil.getPort(base + + YarnConfiguration.getRMDefaultPortNumber(confKey, conf), 10), conf); } }