webAppBuild.invoke(WebApps.$for("jobhistory", HistoryClientService.class, this, "ws").with(conf).withHttpSpnegoKeytabKey(XLearningConfiguration.XLEARNING_WEBAPP_SPNEGO_KEYTAB_FILE_KEY).withHttpSpnegoPrincipalKey(XLearningConfiguration.XLEARNING_WEBAPP_SPNEGO_USER_NAME_KEY).at(NetUtils.getHostPortString(bindAddress)), webApp); HttpServer2 httpServer = webApp.httpServer(); WebAppContext webAppContext = httpServer.getWebAppContext(); WebApps .$for("jobhistory", HistoryClientService.class, this, "ws") .with(conf) .withHttpSpnegoKeytabKey( XLearningConfiguration.XLEARNING_WEBAPP_SPNEGO_KEYTAB_FILE_KEY) .withHttpSpnegoPrincipalKey( XLearningConfiguration.XLEARNING_WEBAPP_SPNEGO_USER_NAME_KEY) .at(NetUtils.getHostPortString(bindAddress)).start(webApp); } catch (WebAppException e){ throw new WebAppException("Error starting http server", e);
.$for("cluster", ApplicationMasterService.class, masterService, "ws") .with(conf) .withHttpSpnegoPrincipalKey( YarnConfiguration.RM_WEBAPP_SPNEGO_USER_NAME_KEY) .withHttpSpnegoKeytabKey( YarnConfiguration.RM_WEBAPP_SPNEGO_KEYTAB_FILE_KEY) .at(webAppAddress); String proxyHostAndPort = WebAppUtils.getProxyHostAndPort(conf); if(WebAppUtils.getResolvedRMWebAppURLWithoutScheme(conf). fetcher = new AppReportFetcher(conf, getClientRMService()); builder.withServlet(ProxyUriUtils.PROXY_SERVLET_NAME, ProxyUriUtils.PROXY_PATH_SPEC, WebAppProxyServlet.class); builder.withAttribute(WebAppProxy.FETCHER_ATTRIBUTE, fetcher); String[] proxyParts = proxyHostAndPort.split(":"); builder.withAttribute(WebAppProxy.PROXY_HOST_ATTRIBUTE, proxyParts[0]); webApp = builder.start(new RMWebApp(this));
.$for("applicationhistory", ApplicationHistoryClientService.class, ahsClientService, "ws") .with(conf).withAttribute(YarnConfiguration.TIMELINE_SERVICE_WEBAPP_ADDRESS, conf.get(YarnConfiguration.TIMELINE_SERVICE_WEBAPP_ADDRESS)).at(bindAddress).build(ahsWebApp); HttpServer2 httpServer = webApp.httpServer();
.$for("applicationhistory", ApplicationHistoryClientService.class, ahsClientService, "ws") .with(conf).withAttribute(YarnConfiguration.TIMELINE_SERVICE_WEBAPP_ADDRESS, conf.get(YarnConfiguration.TIMELINE_SERVICE_WEBAPP_ADDRESS)).at(bindAddress).build(ahsWebApp); HttpServer2 httpServer = webApp.httpServer();
.$for("cluster", ApplicationMasterService.class, masterService, "ws") .with(conf) .withHttpSpnegoPrincipalKey( YarnConfiguration.RM_WEBAPP_SPNEGO_USER_NAME_KEY) .withHttpSpnegoKeytabKey( YarnConfiguration.RM_WEBAPP_SPNEGO_KEYTAB_FILE_KEY) .at(webAppAddress); String proxyHostAndPort = WebAppUtils.getProxyHostAndPort(conf); if(WebAppUtils.getResolvedRMWebAppURLWithoutScheme(conf). fetcher = new AppReportFetcher(conf, getClientRMService()); builder.withServlet(ProxyUriUtils.PROXY_SERVLET_NAME, ProxyUriUtils.PROXY_PATH_SPEC, WebAppProxyServlet.class); builder.withAttribute(WebAppProxy.FETCHER_ATTRIBUTE, fetcher); String[] proxyParts = proxyHostAndPort.split(":"); builder.withAttribute(WebAppProxy.PROXY_HOST_ATTRIBUTE, proxyParts[0]); webApp = builder.start(new RMWebApp(this));
.$for("applicationhistory", ApplicationHistoryClientService.class, ahsClientService, "ws") .with(conf) .withAttribute(YarnConfiguration.TIMELINE_SERVICE_WEBAPP_ADDRESS, conf.get(YarnConfiguration.TIMELINE_SERVICE_WEBAPP_ADDRESS)) .withCSRFProtection(YarnConfiguration.TIMELINE_CSRF_PREFIX) .withXFSProtection(YarnConfiguration.TIMELINE_XFS_PREFIX) .at(bindAddress).build(ahsWebApp); HttpServer2 httpServer = webApp.httpServer();
.$for("cluster", ApplicationMasterService.class, masterService, "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). builder.withServlet(ProxyUriUtils.PROXY_SERVLET_NAME, ProxyUriUtils.PROXY_PATH_SPEC, WebAppProxyServlet.class); builder.withAttribute(WebAppProxy.FETCHER_ATTRIBUTE, fetcher); String[] proxyParts = proxyHostAndPort.split(":"); builder.withAttribute(WebAppProxy.PROXY_HOST_ATTRIBUTE, proxyParts[0]); builder.withAttribute(IsResourceManagerActiveServlet.RM_ATTRIBUTE, this); builder.withServlet(IsResourceManagerActiveServlet.SERVLET_NAME, IsResourceManagerActiveServlet.PATH_SPEC, IsResourceManagerActiveServlet.class); webApp = builder.start(new RMWebApp(this), uiWebAppContext);
WebApps .$for("node", Context.class, this.nmContext, "ws") .at(bindAddress) .with(conf) .withHttpSpnegoPrincipalKey( YarnConfiguration.NM_WEBAPP_SPNEGO_USER_NAME_KEY) .withHttpSpnegoKeytabKey( YarnConfiguration.NM_WEBAPP_SPNEGO_KEYTAB_FILE_KEY) .withCSRFProtection(YarnConfiguration.NM_CSRF_PREFIX) .withXFSProtection(YarnConfiguration.NM_XFS_PREFIX) .start(this.nmWebApp); this.port = this.webApp.httpServer().getConnectorAddress(0).getPort(); } catch (Exception e) {
webAppApi, RestPaths.WS_CONTEXT) .withHttpPolicy(getConfig(), policy) .at("0.0.0.0", port, true) .inDevMode() .start(webApp);
webAppApi, RestPaths.WS_CONTEXT) .withHttpPolicy(getConfig(), policy) .at("0.0.0.0", port, true) .inDevMode() .start(webApp);
.withHttpPolicy(conf, Policy.HTTP_ONLY) .withPortRange(conf, MRJobConfig.MR_AM_WEBAPP_PORT_RANGE) .start(new AMWebApp()); } catch (Exception e) { LOG.error("Webapps failed to start. Ignoring for now:", e);
.withHttpPolicy(conf, Policy.HTTP_ONLY).start(new AMWebApp()); } catch (Exception e) { LOG.error("Webapps failed to start. Ignoring for now:", e);
@Test public void testPortRanges() throws Exception { WebApp app = WebApps.$for("test", this).start(); String baseUrl = baseUrl(app); WebApp app1 = null; int port = ServerSocketUtil.waitForPort(48000, 60); assertEquals("foo", getContent(baseUrl +"test/foo").trim()); app1 = WebApps.$for("test", this).at(port).start(); assertEquals(port, app1.getListenerAddress().getPort()); app2 = WebApps.$for("test", this).at("0.0.0.0", port, true).start(); assertTrue(app2.getListenerAddress().getPort() > port); Configuration conf = new Configuration(); port = ServerSocketUtil.waitForPort(47000, 60); app3 = WebApps.$for("test", this).at(port).withPortRange(conf, "abc"). start(); assertEquals(port, app3.getListenerAddress().getPort()); ServerSocketUtil.waitForPort(46000, 60); conf.set("abc", "46000-46500"); app4 = WebApps.$for("test", this).at(port).withPortRange(conf, "abc"). start(); assertEquals(46000, app4.getListenerAddress().getPort()); app5 = WebApps.$for("test", this).withPortRange(conf, "abc").start(); assertTrue(app5.getListenerAddress().getPort() > 46000); } finally {
.withHttpPolicy(conf, Policy.HTTP_ONLY).start(new AMWebApp()); } catch (Exception e) { LOG.error("Webapps failed to start. Ignoring for now:", e);
@Test public void testCustomRoutes() throws Exception { WebApp app = WebApps.$for("test", TestWebApp.class, this, "ws").start(new WebApp() { @Override public void setup() { bind(MyTestJAXBContextResolver.class); bind(MyTestWebService.class); route("/:foo", FooController.class); route("/bar/foo", FooController.class, "bar"); route("/foo/:foo", DefaultController.class); route("/foo/bar/:foo", DefaultController.class, "index"); } }); String baseUrl = baseUrl(app); try { assertEquals("foo", getContent(baseUrl).trim()); assertEquals("foo", getContent(baseUrl +"test").trim()); assertEquals("foo1", getContent(baseUrl +"test/1").trim()); assertEquals("bar", getContent(baseUrl +"test/bar/foo").trim()); assertEquals("default", getContent(baseUrl +"test/foo/bar").trim()); assertEquals("default1", getContent(baseUrl +"test/foo/1").trim()); assertEquals("default2", getContent(baseUrl +"test/foo/bar/2").trim()); assertEquals(404, getResponseCode(baseUrl +"test/goo")); assertEquals(200, getResponseCode(baseUrl +"ws/v1/test")); assertTrue(getContent(baseUrl +"ws/v1/test").contains("myInfo")); } finally { app.stop(); } }
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) {
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) {