YARN-6643. TestRMFailover fails rarely due to port conflict. Contributed by Robert Kanter

(cherry picked from commit 3fd6a2da4e)
This commit is contained in:
Jason Lowe 2017-05-25 16:07:52 -05:00
parent 7bad748091
commit 4c44ff69df
1 changed files with 6 additions and 3 deletions

View File

@ -18,16 +18,19 @@
package org.apache.hadoop.yarn.server.resourcemanager; package org.apache.hadoop.yarn.server.resourcemanager;
import org.apache.hadoop.conf.Configuration; 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.HAUtil;
import org.apache.hadoop.yarn.conf.YarnConfiguration; import org.apache.hadoop.yarn.conf.YarnConfiguration;
import java.io.IOException;
public class HATestUtil { public class HATestUtil {
public static void setRpcAddressForRM(String rmId, int base, public static void setRpcAddressForRM(String rmId, int base,
Configuration conf) { Configuration conf) throws IOException {
for (String confKey : YarnConfiguration.getServiceAddressConfKeys(conf)) { for (String confKey : YarnConfiguration.getServiceAddressConfKeys(conf)) {
setConfForRM(rmId, confKey, "0.0.0.0:" + (base + setConfForRM(rmId, confKey, "0.0.0.0:" + ServerSocketUtil.getPort(base +
YarnConfiguration.getRMDefaultPortNumber(confKey, conf)), conf); YarnConfiguration.getRMDefaultPortNumber(confKey, conf), 10), conf);
} }
} }