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

The following examples show how to use org.apache.hadoop.yarn.webapp.util.WebAppUtils#getWebAppBindURL() . 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: WebServer.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Override
protected void serviceStart() throws Exception {
  String bindAddress = WebAppUtils.getWebAppBindURL(getConfig(),
                        YarnConfiguration.NM_BIND_HOST,
                        WebAppUtils.getNMWebAppURLWithoutScheme(getConfig()));
  
  LOG.info("Instantiating NMWebApp at " + bindAddress);
  try {
    this.webApp =
        WebApps
          .$for("node", Context.class, this.nmContext, "ws")
          .at(bindAddress)
          .with(getConfig())
          .withHttpSpnegoPrincipalKey(
            YarnConfiguration.NM_WEBAPP_SPNEGO_USER_NAME_KEY)
          .withHttpSpnegoKeytabKey(
            YarnConfiguration.NM_WEBAPP_SPNEGO_KEYTAB_FILE_KEY)
          .start(this.nmWebApp);
    this.port = this.webApp.httpServer().getConnectorAddress(0).getPort();
  } catch (Exception e) {
    String msg = "NMWebapps failed to start.";
    LOG.error(msg, e);
    throw new YarnRuntimeException(msg, e);
  }
  super.serviceStart();
}
 
Example 2
Source File: WebServer.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Override
protected void serviceStart() throws Exception {
  String bindAddress = WebAppUtils.getWebAppBindURL(getConfig(),
                        YarnConfiguration.NM_BIND_HOST,
                        WebAppUtils.getNMWebAppURLWithoutScheme(getConfig()));
  
  LOG.info("Instantiating NMWebApp at " + bindAddress);
  try {
    this.webApp =
        WebApps
          .$for("node", Context.class, this.nmContext, "ws")
          .at(bindAddress)
          .with(getConfig())
          .withHttpSpnegoPrincipalKey(
            YarnConfiguration.NM_WEBAPP_SPNEGO_USER_NAME_KEY)
          .withHttpSpnegoKeytabKey(
            YarnConfiguration.NM_WEBAPP_SPNEGO_KEYTAB_FILE_KEY)
          .start(this.nmWebApp);
    this.port = this.webApp.httpServer().getConnectorAddress(0).getPort();
  } catch (Exception e) {
    String msg = "NMWebapps failed to start.";
    LOG.error(msg, e);
    throw new YarnRuntimeException(msg, e);
  }
  super.serviceStart();
}
 
Example 3
Source File: ResourceManager.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Override
protected void serviceInit(Configuration conf) throws Exception {
  this.conf = conf;
  this.rmContext = new RMContextImpl();
  
  this.configurationProvider =
      ConfigurationProviderFactory.getConfigurationProvider(conf);
  this.configurationProvider.init(this.conf);
  rmContext.setConfigurationProvider(configurationProvider);

  // load core-site.xml
  InputStream coreSiteXMLInputStream =
      this.configurationProvider.getConfigurationInputStream(this.conf,
          YarnConfiguration.CORE_SITE_CONFIGURATION_FILE);
  if (coreSiteXMLInputStream != null) {
    this.conf.addResource(coreSiteXMLInputStream);
  }

  // Do refreshUserToGroupsMappings with loaded core-site.xml
  Groups.getUserToGroupsMappingServiceWithLoadedConfiguration(this.conf)
      .refresh();

  // Do refreshSuperUserGroupsConfiguration with loaded core-site.xml
  // Or use RM specific configurations to overwrite the common ones first
  // if they exist
  RMServerUtils.processRMProxyUsersConf(conf);
  ProxyUsers.refreshSuperUserGroupsConfiguration(this.conf);

  // load yarn-site.xml
  InputStream yarnSiteXMLInputStream =
      this.configurationProvider.getConfigurationInputStream(this.conf,
          YarnConfiguration.YARN_SITE_CONFIGURATION_FILE);
  if (yarnSiteXMLInputStream != null) {
    this.conf.addResource(yarnSiteXMLInputStream);
  }

  validateConfigs(this.conf);
  
  // Set HA configuration should be done before login
  this.rmContext.setHAEnabled(HAUtil.isHAEnabled(this.conf));
  if (this.rmContext.isHAEnabled()) {
    HAUtil.verifyAndSetConfiguration(this.conf);
  }
  
  // Set UGI and do login
  // If security is enabled, use login user
  // If security is not enabled, use current user
  this.rmLoginUGI = UserGroupInformation.getCurrentUser();
  try {
    doSecureLogin();
  } catch(IOException ie) {
    throw new YarnRuntimeException("Failed to login", ie);
  }

  // register the handlers for all AlwaysOn services using setupDispatcher().
  rmDispatcher = setupDispatcher();
  addIfService(rmDispatcher);
  rmContext.setDispatcher(rmDispatcher);

  adminService = createAdminService();
  addService(adminService);
  rmContext.setRMAdminService(adminService);
  
  rmContext.setYarnConfiguration(conf);
  
  createAndInitActiveServices();

  webAppAddress = WebAppUtils.getWebAppBindURL(this.conf,
                    YarnConfiguration.RM_BIND_HOST,
                    WebAppUtils.getRMWebAppURLWithoutScheme(this.conf));

  super.serviceInit(this.conf);
}
 
Example 4
Source File: ApplicationHistoryServer.java    From hadoop with Apache License 2.0 4 votes vote down vote up
private void startWebApp() {
  Configuration conf = getConfig();
  TimelineAuthenticationFilter.setTimelineDelegationTokenSecretManager(
      secretManagerService.getTimelineDelegationTokenSecretManager());
  // Always load pseudo authentication filter to parse "user.name" in an URL
  // to identify a HTTP request's user in insecure mode.
  // When Kerberos authentication type is set (i.e., secure mode is turned on),
  // the customized filter will be loaded by the timeline server to do Kerberos
  // + DT authentication.
  String initializers = conf.get("hadoop.http.filter.initializers");
  boolean modifiedInitializers = false;

  initializers =
      initializers == null || initializers.length() == 0 ? "" : initializers;

  if (!initializers.contains(CrossOriginFilterInitializer.class.getName())) {
    if(conf.getBoolean(YarnConfiguration
        .TIMELINE_SERVICE_HTTP_CROSS_ORIGIN_ENABLED, YarnConfiguration
            .TIMELINE_SERVICE_HTTP_CROSS_ORIGIN_ENABLED_DEFAULT)) {
      initializers = CrossOriginFilterInitializer.class.getName() + ","
          + initializers;
      modifiedInitializers = true;
    }
  }

  if (!initializers.contains(TimelineAuthenticationFilterInitializer.class
    .getName())) {
    initializers =
        TimelineAuthenticationFilterInitializer.class.getName() + ","
            + initializers;
    modifiedInitializers = true;
  }

  String[] parts = initializers.split(",");
  ArrayList<String> target = new ArrayList<String>();
  for (String filterInitializer : parts) {
    filterInitializer = filterInitializer.trim();
    if (filterInitializer.equals(AuthenticationFilterInitializer.class
      .getName())) {
      modifiedInitializers = true;
      continue;
    }
    target.add(filterInitializer);
  }
  String actualInitializers =
      org.apache.commons.lang.StringUtils.join(target, ",");
  if (modifiedInitializers) {
    conf.set("hadoop.http.filter.initializers", actualInitializers);
  }
  String bindAddress = WebAppUtils.getWebAppBindURL(conf,
                        YarnConfiguration.TIMELINE_SERVICE_BIND_HOST,
                        WebAppUtils.getAHSWebAppURLWithoutScheme(conf));
  LOG.info("Instantiating AHSWebApp at " + bindAddress);
  try {
    webApp =
        WebApps
          .$for("applicationhistory", ApplicationHistoryClientService.class,
              ahsClientService, "ws")
          .with(conf).at(bindAddress).start(
              new AHSWebApp(timelineDataManager, ahsClientService));
  } catch (Exception e) {
    String msg = "AHSWebApp failed to start.";
    LOG.error(msg, e);
    throw new YarnRuntimeException(msg, e);
  }
}
 
Example 5
Source File: ResourceManager.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Override
protected void serviceInit(Configuration conf) throws Exception {
  this.conf = conf;
  this.rmContext = new RMContextImpl();
  
  this.configurationProvider =
      ConfigurationProviderFactory.getConfigurationProvider(conf);
  this.configurationProvider.init(this.conf);
  rmContext.setConfigurationProvider(configurationProvider);

  // load core-site.xml
  InputStream coreSiteXMLInputStream =
      this.configurationProvider.getConfigurationInputStream(this.conf,
          YarnConfiguration.CORE_SITE_CONFIGURATION_FILE);
  if (coreSiteXMLInputStream != null) {
    this.conf.addResource(coreSiteXMLInputStream);
  }

  // Do refreshUserToGroupsMappings with loaded core-site.xml
  Groups.getUserToGroupsMappingServiceWithLoadedConfiguration(this.conf)
      .refresh();

  // Do refreshSuperUserGroupsConfiguration with loaded core-site.xml
  // Or use RM specific configurations to overwrite the common ones first
  // if they exist
  RMServerUtils.processRMProxyUsersConf(conf);
  ProxyUsers.refreshSuperUserGroupsConfiguration(this.conf);

  // load yarn-site.xml
  InputStream yarnSiteXMLInputStream =
      this.configurationProvider.getConfigurationInputStream(this.conf,
          YarnConfiguration.YARN_SITE_CONFIGURATION_FILE);
  if (yarnSiteXMLInputStream != null) {
    this.conf.addResource(yarnSiteXMLInputStream);
  }

  validateConfigs(this.conf);
  
  // Set HA configuration should be done before login
  this.rmContext.setHAEnabled(HAUtil.isHAEnabled(this.conf));
  if (this.rmContext.isHAEnabled()) {
    HAUtil.verifyAndSetConfiguration(this.conf);
  }
  
  // Set UGI and do login
  // If security is enabled, use login user
  // If security is not enabled, use current user
  this.rmLoginUGI = UserGroupInformation.getCurrentUser();
  try {
    doSecureLogin();
  } catch(IOException ie) {
    throw new YarnRuntimeException("Failed to login", ie);
  }

  // register the handlers for all AlwaysOn services using setupDispatcher().
  rmDispatcher = setupDispatcher();
  addIfService(rmDispatcher);
  rmContext.setDispatcher(rmDispatcher);

  adminService = createAdminService();
  addService(adminService);
  rmContext.setRMAdminService(adminService);
  
  rmContext.setYarnConfiguration(conf);
  
  createAndInitActiveServices();

  webAppAddress = WebAppUtils.getWebAppBindURL(this.conf,
                    YarnConfiguration.RM_BIND_HOST,
                    WebAppUtils.getRMWebAppURLWithoutScheme(this.conf));

  super.serviceInit(this.conf);
}
 
Example 6
Source File: ApplicationHistoryServer.java    From big-c with Apache License 2.0 4 votes vote down vote up
private void startWebApp() {
  Configuration conf = getConfig();
  TimelineAuthenticationFilter.setTimelineDelegationTokenSecretManager(
      secretManagerService.getTimelineDelegationTokenSecretManager());
  // Always load pseudo authentication filter to parse "user.name" in an URL
  // to identify a HTTP request's user in insecure mode.
  // When Kerberos authentication type is set (i.e., secure mode is turned on),
  // the customized filter will be loaded by the timeline server to do Kerberos
  // + DT authentication.
  String initializers = conf.get("hadoop.http.filter.initializers");
  boolean modifiedInitializers = false;

  initializers =
      initializers == null || initializers.length() == 0 ? "" : initializers;

  if (!initializers.contains(CrossOriginFilterInitializer.class.getName())) {
    if(conf.getBoolean(YarnConfiguration
        .TIMELINE_SERVICE_HTTP_CROSS_ORIGIN_ENABLED, YarnConfiguration
            .TIMELINE_SERVICE_HTTP_CROSS_ORIGIN_ENABLED_DEFAULT)) {
      initializers = CrossOriginFilterInitializer.class.getName() + ","
          + initializers;
      modifiedInitializers = true;
    }
  }

  if (!initializers.contains(TimelineAuthenticationFilterInitializer.class
    .getName())) {
    initializers =
        TimelineAuthenticationFilterInitializer.class.getName() + ","
            + initializers;
    modifiedInitializers = true;
  }

  String[] parts = initializers.split(",");
  ArrayList<String> target = new ArrayList<String>();
  for (String filterInitializer : parts) {
    filterInitializer = filterInitializer.trim();
    if (filterInitializer.equals(AuthenticationFilterInitializer.class
      .getName())) {
      modifiedInitializers = true;
      continue;
    }
    target.add(filterInitializer);
  }
  String actualInitializers =
      org.apache.commons.lang.StringUtils.join(target, ",");
  if (modifiedInitializers) {
    conf.set("hadoop.http.filter.initializers", actualInitializers);
  }
  String bindAddress = WebAppUtils.getWebAppBindURL(conf,
                        YarnConfiguration.TIMELINE_SERVICE_BIND_HOST,
                        WebAppUtils.getAHSWebAppURLWithoutScheme(conf));
  LOG.info("Instantiating AHSWebApp at " + bindAddress);
  try {
    webApp =
        WebApps
          .$for("applicationhistory", ApplicationHistoryClientService.class,
              ahsClientService, "ws")
          .with(conf).at(bindAddress).start(
              new AHSWebApp(timelineDataManager, ahsClientService));
  } catch (Exception e) {
    String msg = "AHSWebApp failed to start.";
    LOG.error(msg, e);
    throw new YarnRuntimeException(msg, e);
  }
}