org.apache.hadoop.yarn.util.RMHAUtils Java Examples

The following examples show how to use org.apache.hadoop.yarn.util.RMHAUtils. 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: AmIpFilter.java    From hadoop with Apache License 2.0 6 votes vote down vote up
protected String findRedirectUrl() throws ServletException {
  String addr;
  if (proxyUriBases.size() == 1) {  // external proxy or not RM HA
    addr = proxyUriBases.values().iterator().next();
  } else {                          // RM HA
    YarnConfiguration conf = new YarnConfiguration();
    String activeRMId = RMHAUtils.findActiveRMHAId(conf);
    String addressPropertyPrefix = YarnConfiguration.useHttps(conf)
        ? YarnConfiguration.RM_WEBAPP_HTTPS_ADDRESS
        : YarnConfiguration.RM_WEBAPP_ADDRESS;
    String host = conf.get(
        HAUtil.addSuffix(addressPropertyPrefix, activeRMId));
    addr = proxyUriBases.get(host);
  }
  if (addr == null) {
    throw new ServletException(
        "Could not determine the proxy server for redirection");
  }
  return addr;
}
 
Example #2
Source File: RMWebApp.java    From hadoop with Apache License 2.0 6 votes vote down vote up
private String buildRedirectPath() {
  // make a copy of the original configuration so not to mutate it. Also use
  // an YarnConfiguration to force loading of yarn-site.xml.
  YarnConfiguration yarnConf = new YarnConfiguration(rm.getConfig());
  String activeRMHAId = RMHAUtils.findActiveRMHAId(yarnConf);
  String path = "";
  if (activeRMHAId != null) {
    yarnConf.set(YarnConfiguration.RM_HA_ID, activeRMHAId);

    InetSocketAddress sock = YarnConfiguration.useHttps(yarnConf)
        ? yarnConf.getSocketAddr(YarnConfiguration.RM_WEBAPP_HTTPS_ADDRESS,
            YarnConfiguration.DEFAULT_RM_WEBAPP_HTTPS_ADDRESS,
            YarnConfiguration.DEFAULT_RM_WEBAPP_HTTPS_PORT)
        : yarnConf.getSocketAddr(YarnConfiguration.RM_WEBAPP_ADDRESS,
            YarnConfiguration.DEFAULT_RM_WEBAPP_ADDRESS,
            YarnConfiguration.DEFAULT_RM_WEBAPP_PORT);

    path = sock.getHostName() + ":" + Integer.toString(sock.getPort());
    path = YarnConfiguration.useHttps(yarnConf)
        ? "https://" + path
        : "http://" + path;
  }
  return path;
}
 
Example #3
Source File: AmIpFilter.java    From big-c with Apache License 2.0 6 votes vote down vote up
protected String findRedirectUrl() throws ServletException {
  String addr;
  if (proxyUriBases.size() == 1) {  // external proxy or not RM HA
    addr = proxyUriBases.values().iterator().next();
  } else {                          // RM HA
    YarnConfiguration conf = new YarnConfiguration();
    String activeRMId = RMHAUtils.findActiveRMHAId(conf);
    String addressPropertyPrefix = YarnConfiguration.useHttps(conf)
        ? YarnConfiguration.RM_WEBAPP_HTTPS_ADDRESS
        : YarnConfiguration.RM_WEBAPP_ADDRESS;
    String host = conf.get(
        HAUtil.addSuffix(addressPropertyPrefix, activeRMId));
    addr = proxyUriBases.get(host);
  }
  if (addr == null) {
    throw new ServletException(
        "Could not determine the proxy server for redirection");
  }
  return addr;
}
 
Example #4
Source File: RMWebApp.java    From big-c with Apache License 2.0 6 votes vote down vote up
private String buildRedirectPath() {
  // make a copy of the original configuration so not to mutate it. Also use
  // an YarnConfiguration to force loading of yarn-site.xml.
  YarnConfiguration yarnConf = new YarnConfiguration(rm.getConfig());
  String activeRMHAId = RMHAUtils.findActiveRMHAId(yarnConf);
  String path = "";
  if (activeRMHAId != null) {
    yarnConf.set(YarnConfiguration.RM_HA_ID, activeRMHAId);

    InetSocketAddress sock = YarnConfiguration.useHttps(yarnConf)
        ? yarnConf.getSocketAddr(YarnConfiguration.RM_WEBAPP_HTTPS_ADDRESS,
            YarnConfiguration.DEFAULT_RM_WEBAPP_HTTPS_ADDRESS,
            YarnConfiguration.DEFAULT_RM_WEBAPP_HTTPS_PORT)
        : yarnConf.getSocketAddr(YarnConfiguration.RM_WEBAPP_ADDRESS,
            YarnConfiguration.DEFAULT_RM_WEBAPP_ADDRESS,
            YarnConfiguration.DEFAULT_RM_WEBAPP_PORT);

    path = sock.getHostName() + ":" + Integer.toString(sock.getPort());
    path = YarnConfiguration.useHttps(yarnConf)
        ? "https://" + path
        : "http://" + path;
  }
  return path;
}
 
Example #5
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 #6
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;
}
 
Example #7
Source File: YarnClientProxy.java    From PoseidonX with Apache License 2.0 2 votes vote down vote up
/**
 * 获得当前active的rmid
 * @return
 */
public static String findActiveRMHAId()  {
    return RMHAUtils.findActiveRMHAId(conf);
}