ResourceManager extends CompositeService implements Recoverable, ResourceManagerMXBean { protected void startWepApp() { Map<String, String> serviceConfig = null; Configuration conf = getConfig(); RMWebAppUtil.setupSecurityAndFilters(conf, getClientRMService().rmDTSecretManager); Map<String, String> params = new HashMap<String, String>(); if (getConfig().getBoolean(YarnConfiguration.YARN_API_SERVICES_ENABLE, false)) { String apiPackages = "org.apache.hadoop.yarn.service.webapp;" + "org.apache.hadoop.yarn.webapp"; params.put("com.sun.jersey.config.property.resourceConfigClass", "com.sun.jersey.api.core.PackagesResourceConfig"); params.put("com.sun.jersey.config.property.packages", apiPackages); } Builder<ResourceManager> builder = WebApps .$for("cluster", ResourceManager.class, this, "ws") .with(conf) .withServlet("API-Service", "/app/*", ServletContainer.class, params, false) .withHttpSpnegoPrincipalKey( YarnConfiguration.RM_WEBAPP_SPNEGO_USER_NAME_KEY) .withHttpSpnegoKeytabKey( YarnConfiguration.RM_WEBAPP_SPNEGO_KEYTAB_FILE_KEY) .withCSRFProtection(YarnConfiguration.RM_CSRF_PREFIX) .withXFSProtection(YarnConfiguration.RM_XFS_PREFIX) .at(webAppAddress); String proxyHostAndPort = rmContext.getProxyHostAndPort(conf); if(WebAppUtils.getResolvedRMWebAppURLWithoutScheme(conf). equals(proxyHostAndPort)) { if (HAUtil.isHAEnabled(conf)) { fetcher = new AppReportFetcher(conf); } else { fetcher = new AppReportFetcher(conf, getClientRMService()); } builder.withServlet(ProxyUriUtils.PROXY_SERVLET_NAME, ProxyUriUtils.PROXY_PATH_SPEC, WebAppProxyServlet.class); builder.withAttribute(WebAppProxy.PROXY_CA, rmContext.getProxyCAManager().getProxyCA()); builder.withAttribute(WebAppProxy.FETCHER_ATTRIBUTE, fetcher); String[] proxyParts = proxyHostAndPort.split(":"); builder.withAttribute(WebAppProxy.PROXY_HOST_ATTRIBUTE, proxyParts[0]); } WebAppContext uiWebAppContext = null; if (getConfig().getBoolean(YarnConfiguration.YARN_WEBAPP_UI2_ENABLE, YarnConfiguration.DEFAULT_YARN_WEBAPP_UI2_ENABLE)) { String onDiskPath = getConfig() .get(YarnConfiguration.YARN_WEBAPP_UI2_WARFILE_PATH); uiWebAppContext = new WebAppContext(); uiWebAppContext.setContextPath(UI2_WEBAPP_NAME); if (null == onDiskPath) { String war = "hadoop-yarn-ui-" + VersionInfo.getVersion() + ".war"; URL url = getClass().getClassLoader().getResource(war); if (null == url) { onDiskPath = getWebAppsPath("ui2"); } else { onDiskPath = url.getFile(); } } if (onDiskPath == null || onDiskPath.isEmpty()) { LOG.error("No war file or webapps found for ui2 !"); } else { if (onDiskPath.endsWith(".war")) { uiWebAppContext.setWar(onDiskPath); LOG.info("Using war file at: " + onDiskPath); } else { uiWebAppContext.setResourceBase(onDiskPath); LOG.info("Using webapps at: " + onDiskPath); } } } builder.withAttribute(IsResourceManagerActiveServlet.RM_ATTRIBUTE, this); builder.withServlet(IsResourceManagerActiveServlet.SERVLET_NAME, IsResourceManagerActiveServlet.PATH_SPEC, IsResourceManagerActiveServlet.class); webApp = builder.start(new RMWebApp(this), uiWebAppContext); } ResourceManager(); RMContext getRMContext(); static long getClusterTimeStamp(); String getRMLoginUser(); ZKCuratorManager createAndStartZKManager(Configuration
      config); ZKCuratorManager getZKManager(); CuratorFramework getCurator(); String getZkRootNodePassword(); static HttpServer2.Builder httpServerTemplateForRM(Configuration conf,
      final InetSocketAddress httpAddr, final InetSocketAddress httpsAddr,
      String name); @Private ClientRMService getClientRMService(); @Private ResourceScheduler getResourceScheduler(); @Private ResourceTrackerService getResourceTrackerService(); @Private ApplicationMasterService getApplicationMasterService(); @Private ApplicationACLsManager getApplicationACLsManager(); @Private QueueACLsManager getQueueACLsManager(); @Private @VisibleForTesting FederationStateStoreService getFederationStateStoreService(); @Override void recover(RMState state); static void main(String argv[]); static InetSocketAddress getBindAddress(Configuration conf); @Override boolean isSecurityEnabled(); static final int SHUTDOWN_HOOK_PRIORITY; static final int EPOCH_BIT_SHIFT; static final String UI2_WEBAPP_NAME; }
@Test(timeout = 50000) public void testFilterOverrides() throws Exception { String filterInitializerConfKey = "hadoop.http.filter.initializers"; String[] filterInitializers = { AuthenticationFilterInitializer.class.getName(), RMAuthenticationFilterInitializer.class.getName(), AuthenticationFilterInitializer.class.getName() + "," + RMAuthenticationFilterInitializer.class.getName(), AuthenticationFilterInitializer.class.getName() + ", " + RMAuthenticationFilterInitializer.class.getName(), AuthenticationFilterInitializer.class.getName() + ", " + this.getClass().getName() }; for (String filterInitializer : filterInitializers) { resourceManager = new ResourceManager() { @Override protected void doSecureLogin() throws IOException { } }; Configuration conf = new YarnConfiguration(); conf.set(filterInitializerConfKey, filterInitializer); conf.set("hadoop.security.authentication", "kerberos"); conf.set("hadoop.http.authentication.type", "kerberos"); try { try { UserGroupInformation.setConfiguration(conf); } catch (Exception e) { LOG.info("Got expected exception"); } resourceManager.init(conf); resourceManager.startWepApp(); } catch (RuntimeException e) { String tmp = resourceManager.getConfig().get(filterInitializerConfKey); if (filterInitializer.contains(this.getClass().getName())) { Assert.assertEquals(RMAuthenticationFilterInitializer.class.getName() + "," + this.getClass().getName(), tmp); } else { Assert.assertEquals( RMAuthenticationFilterInitializer.class.getName(), tmp); } resourceManager.stop(); } } String[] simpleFilterInitializers = { "", StaticUserWebFilter.class.getName() }; for (String filterInitializer : simpleFilterInitializers) { resourceManager = new ResourceManager(); Configuration conf = new YarnConfiguration(); conf.set(filterInitializerConfKey, filterInitializer); try { UserGroupInformation.setConfiguration(conf); resourceManager.init(conf); resourceManager.startWepApp(); } catch (RuntimeException e) { String tmp = resourceManager.getConfig().get(filterInitializerConfKey); if (filterInitializer.equals(StaticUserWebFilter.class.getName())) { Assert.assertEquals(RMAuthenticationFilterInitializer.class.getName() + "," + StaticUserWebFilter.class.getName(), tmp); } else { Assert.assertEquals( RMAuthenticationFilterInitializer.class.getName(), tmp); } resourceManager.stop(); } } }