Java Code Examples for org.apache.hadoop.yarn.util.RMHAUtils#getRMHAWebappAddresses()

The following examples show how to use org.apache.hadoop.yarn.util.RMHAUtils#getRMHAWebappAddresses() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebAppUtils.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public static List<String> getProxyHostsAndPortsForAmFilter(
    Configuration conf) {
  List<String> addrs = new ArrayList<String>();
  String proxyAddr = conf.get(YarnConfiguration.PROXY_ADDRESS);
  // If PROXY_ADDRESS isn't set, fallback to RM_WEBAPP(_HTTPS)_ADDRESS
  // There could be multiple if using RM HA
  if (proxyAddr == null || proxyAddr.isEmpty()) {
    // If RM HA is enabled, try getting those addresses
    if (HAUtil.isHAEnabled(conf)) {
      List<String> haAddrs =
          RMHAUtils.getRMHAWebappAddresses(new YarnConfiguration(conf));
      for (String addr : haAddrs) {
        try {
          InetSocketAddress socketAddr = NetUtils.createSocketAddr(addr);
          addrs.add(getResolvedAddress(socketAddr));
        } catch(IllegalArgumentException e) {
          // skip if can't resolve
        }
      }
    }
    // If couldn't resolve any of the addresses or not using RM HA, fallback
    if (addrs.isEmpty()) {
      addrs.add(getResolvedRMWebAppURLWithoutScheme(conf));
    }
  } else {
    addrs.add(proxyAddr);
  }
  return addrs;
}
 
Example 2
Source File: WebAppUtils.java    From big-c with Apache License 2.0 5 votes vote down vote up
public static List<String> getProxyHostsAndPortsForAmFilter(
    Configuration conf) {
  List<String> addrs = new ArrayList<String>();
  String proxyAddr = conf.get(YarnConfiguration.PROXY_ADDRESS);
  // If PROXY_ADDRESS isn't set, fallback to RM_WEBAPP(_HTTPS)_ADDRESS
  // There could be multiple if using RM HA
  if (proxyAddr == null || proxyAddr.isEmpty()) {
    // If RM HA is enabled, try getting those addresses
    if (HAUtil.isHAEnabled(conf)) {
      List<String> haAddrs =
          RMHAUtils.getRMHAWebappAddresses(new YarnConfiguration(conf));
      for (String addr : haAddrs) {
        try {
          InetSocketAddress socketAddr = NetUtils.createSocketAddr(addr);
          addrs.add(getResolvedAddress(socketAddr));
        } catch(IllegalArgumentException e) {
          // skip if can't resolve
        }
      }
    }
    // If couldn't resolve any of the addresses or not using RM HA, fallback
    if (addrs.isEmpty()) {
      addrs.add(getResolvedRMWebAppURLWithoutScheme(conf));
    }
  } else {
    addrs.add(proxyAddr);
  }
  return addrs;
}