Java Code Examples for org.apache.hadoop.yarn.webapp.util.WebAppUtils#getProxyHostAndPort()

The following examples show how to use org.apache.hadoop.yarn.webapp.util.WebAppUtils#getProxyHostAndPort() . 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: RMAppAttemptImpl.java    From hadoop with Apache License 2.0 6 votes vote down vote up
private String generateProxyUriWithScheme() {
  this.readLock.lock();
  try {
    final String scheme = WebAppUtils.getHttpSchemePrefix(conf);
    String proxy = WebAppUtils.getProxyHostAndPort(conf);
    URI proxyUri = ProxyUriUtils.getUriFromAMUrl(scheme, proxy);
    URI result = ProxyUriUtils.getProxyUri(null, proxyUri,
        applicationAttemptId.getApplicationId());
    return result.toASCIIString();
  } catch (URISyntaxException e) {
    LOG.warn("Could not proxify the uri for "
        + applicationAttemptId.getApplicationId(), e);
    return null;
  } finally {
    this.readLock.unlock();
  }
}
 
Example 2
Source File: RMAppAttemptImpl.java    From big-c with Apache License 2.0 6 votes vote down vote up
private String generateProxyUriWithScheme() {
  this.readLock.lock();
  try {
    final String scheme = WebAppUtils.getHttpSchemePrefix(conf);
    String proxy = WebAppUtils.getProxyHostAndPort(conf);
    URI proxyUri = ProxyUriUtils.getUriFromAMUrl(scheme, proxy);
    URI result = ProxyUriUtils.getProxyUri(null, proxyUri,
        applicationAttemptId.getApplicationId());
    return result.toASCIIString();
  } catch (URISyntaxException e) {
    LOG.warn("Could not proxify the uri for "
        + applicationAttemptId.getApplicationId(), e);
    return null;
  } finally {
    this.readLock.unlock();
  }
}
 
Example 3
Source File: WebAppProxy.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
protected void serviceInit(Configuration conf) throws Exception {
  String auth =  conf.get(CommonConfigurationKeys.HADOOP_SECURITY_AUTHENTICATION);
  if (auth == null || "simple".equals(auth)) {
    isSecurityEnabled = false;
  } else if ("kerberos".equals(auth)) {
    isSecurityEnabled = true;
  } else {
    LOG.warn("Unrecongized attribute value for " +
        CommonConfigurationKeys.HADOOP_SECURITY_AUTHENTICATION +
        " of " + auth);
  }
  String proxy = WebAppUtils.getProxyHostAndPort(conf);
  String[] proxyParts = proxy.split(":");
  proxyHost = proxyParts[0];

  fetcher = new AppReportFetcher(conf);
  bindAddress = conf.get(YarnConfiguration.PROXY_ADDRESS);
  if(bindAddress == null || bindAddress.isEmpty()) {
    throw new YarnRuntimeException(YarnConfiguration.PROXY_ADDRESS + 
        " is not set so the proxy will not run.");
  }
  LOG.info("Instantiating Proxy at " + bindAddress);
  String[] parts = StringUtils.split(bindAddress, ':');
  port = 0;
  if (parts.length == 2) {
    bindAddress = parts[0];
    port = Integer.parseInt(parts[1]);
  }
  acl = new AccessControlList(conf.get(YarnConfiguration.YARN_ADMIN_ACL, 
      YarnConfiguration.DEFAULT_YARN_ADMIN_ACL));
  super.serviceInit(conf);
}
 
Example 4
Source File: TestWebAppProxyServlet.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
protected void serviceStart() throws Exception {
  Configuration conf = getConfig();
  String bindAddress = conf.get(YarnConfiguration.PROXY_ADDRESS);
  bindAddress = StringUtils.split(bindAddress, ':')[0];
  AccessControlList acl = new AccessControlList(
      conf.get(YarnConfiguration.YARN_ADMIN_ACL, 
      YarnConfiguration.DEFAULT_YARN_ADMIN_ACL));
  proxyServer = new HttpServer2.Builder()
      .setName("proxy")
      .addEndpoint(
          URI.create(WebAppUtils.getHttpSchemePrefix(conf) + bindAddress
              + ":0")).setFindPort(true)
      .setConf(conf)
      .setACL(acl)
      .build();
  proxyServer.addServlet(ProxyUriUtils.PROXY_SERVLET_NAME,
      ProxyUriUtils.PROXY_PATH_SPEC, WebAppProxyServlet.class);

  appReportFetcher = new AppReportFetcherForTest(conf);
  proxyServer.setAttribute(FETCHER_ATTRIBUTE,
      appReportFetcher );
  proxyServer.setAttribute(IS_SECURITY_ENABLED_ATTRIBUTE, Boolean.TRUE);
  
  String proxy = WebAppUtils.getProxyHostAndPort(conf);
  String[] proxyParts = proxy.split(":");
  String proxyHost = proxyParts[0];
  
  proxyServer.setAttribute(PROXY_HOST_ATTRIBUTE, proxyHost);
  proxyServer.start();
  LOG.info("Proxy server is started at port {}",
      proxyServer.getConnectorAddress(0).getPort());
}
 
Example 5
Source File: RMAppImpl.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private String getDefaultProxyTrackingUrl() {
  try {
    final String scheme = WebAppUtils.getHttpSchemePrefix(conf);
    String proxy = WebAppUtils.getProxyHostAndPort(conf);
    URI proxyUri = ProxyUriUtils.getUriFromAMUrl(scheme, proxy);
    URI result = ProxyUriUtils.getProxyUri(null, proxyUri, applicationId);
    return result.toASCIIString();
  } catch (URISyntaxException e) {
    LOG.warn("Could not generate default proxy tracking URL for "
        + applicationId);
    return UNAVAILABLE;
  }
}
 
Example 6
Source File: TestRMAppAttemptTransitions.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private String getProxyUrl(RMAppAttempt appAttempt) {
  String url = null;
  final String scheme = WebAppUtils.getHttpSchemePrefix(conf);
  try {
    String proxy = WebAppUtils.getProxyHostAndPort(conf);
    URI proxyUri = ProxyUriUtils.getUriFromAMUrl(scheme, proxy);
    URI result = ProxyUriUtils.getProxyUri(null, proxyUri, appAttempt
        .getAppAttemptId().getApplicationId());
    url = result.toASCIIString();
  } catch (URISyntaxException ex) {
    Assert.fail();
  }
  return url;
}
 
Example 7
Source File: WebAppProxy.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
protected void serviceInit(Configuration conf) throws Exception {
  String auth =  conf.get(CommonConfigurationKeys.HADOOP_SECURITY_AUTHENTICATION);
  if (auth == null || "simple".equals(auth)) {
    isSecurityEnabled = false;
  } else if ("kerberos".equals(auth)) {
    isSecurityEnabled = true;
  } else {
    LOG.warn("Unrecongized attribute value for " +
        CommonConfigurationKeys.HADOOP_SECURITY_AUTHENTICATION +
        " of " + auth);
  }
  String proxy = WebAppUtils.getProxyHostAndPort(conf);
  String[] proxyParts = proxy.split(":");
  proxyHost = proxyParts[0];

  fetcher = new AppReportFetcher(conf);
  bindAddress = conf.get(YarnConfiguration.PROXY_ADDRESS);
  if(bindAddress == null || bindAddress.isEmpty()) {
    throw new YarnRuntimeException(YarnConfiguration.PROXY_ADDRESS + 
        " is not set so the proxy will not run.");
  }
  LOG.info("Instantiating Proxy at " + bindAddress);
  String[] parts = StringUtils.split(bindAddress, ':');
  port = 0;
  if (parts.length == 2) {
    bindAddress = parts[0];
    port = Integer.parseInt(parts[1]);
  }
  acl = new AccessControlList(conf.get(YarnConfiguration.YARN_ADMIN_ACL, 
      YarnConfiguration.DEFAULT_YARN_ADMIN_ACL));
  super.serviceInit(conf);
}
 
Example 8
Source File: TestWebAppProxyServlet.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
protected void serviceStart() throws Exception {
  Configuration conf = getConfig();
  String bindAddress = conf.get(YarnConfiguration.PROXY_ADDRESS);
  bindAddress = StringUtils.split(bindAddress, ':')[0];
  AccessControlList acl = new AccessControlList(
      conf.get(YarnConfiguration.YARN_ADMIN_ACL, 
      YarnConfiguration.DEFAULT_YARN_ADMIN_ACL));
  proxyServer = new HttpServer2.Builder()
      .setName("proxy")
      .addEndpoint(
          URI.create(WebAppUtils.getHttpSchemePrefix(conf) + bindAddress
              + ":0")).setFindPort(true)
      .setConf(conf)
      .setACL(acl)
      .build();
  proxyServer.addServlet(ProxyUriUtils.PROXY_SERVLET_NAME,
      ProxyUriUtils.PROXY_PATH_SPEC, WebAppProxyServlet.class);

  appReportFetcher = new AppReportFetcherForTest(conf);
  proxyServer.setAttribute(FETCHER_ATTRIBUTE,
      appReportFetcher );
  proxyServer.setAttribute(IS_SECURITY_ENABLED_ATTRIBUTE, Boolean.TRUE);
  
  String proxy = WebAppUtils.getProxyHostAndPort(conf);
  String[] proxyParts = proxy.split(":");
  String proxyHost = proxyParts[0];
  
  proxyServer.setAttribute(PROXY_HOST_ATTRIBUTE, proxyHost);
  proxyServer.start();
  LOG.info("Proxy server is started at port {}",
      proxyServer.getConnectorAddress(0).getPort());
}
 
Example 9
Source File: RMAppImpl.java    From big-c with Apache License 2.0 5 votes vote down vote up
private String getDefaultProxyTrackingUrl() {
  try {
    final String scheme = WebAppUtils.getHttpSchemePrefix(conf);
    String proxy = WebAppUtils.getProxyHostAndPort(conf);
    URI proxyUri = ProxyUriUtils.getUriFromAMUrl(scheme, proxy);
    URI result = ProxyUriUtils.getProxyUri(null, proxyUri, applicationId);
    return result.toASCIIString();
  } catch (URISyntaxException e) {
    LOG.warn("Could not generate default proxy tracking URL for "
        + applicationId);
    return UNAVAILABLE;
  }
}
 
Example 10
Source File: TestRMAppAttemptTransitions.java    From big-c with Apache License 2.0 5 votes vote down vote up
private String getProxyUrl(RMAppAttempt appAttempt) {
  String url = null;
  final String scheme = WebAppUtils.getHttpSchemePrefix(conf);
  try {
    String proxy = WebAppUtils.getProxyHostAndPort(conf);
    URI proxyUri = ProxyUriUtils.getUriFromAMUrl(scheme, proxy);
    URI result = ProxyUriUtils.getProxyUri(null, proxyUri, appAttempt
        .getAppAttemptId().getApplicationId());
    url = result.toASCIIString();
  } catch (URISyntaxException ex) {
    Assert.fail();
  }
  return url;
}