try { Method webAppBuild = WebApps.Builder.class.getMethod("build", WebApp.class); webApp = (WebApp) webAppBuild.invoke(WebApps.$for("proxy", ApplicationContext.class, applicationContext, null).with(getConfig()), new AMWebApp()); HttpServer2 httpServer = webApp.httpServer(); webApp = WebApps.$for("proxy", ApplicationContext.class, applicationContext, null).with(getConfig()).start(new AMWebApp()); } catch (Exception e) { LOG.error("Error starting application web server!", e);
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(); LOG.debug("current hadoop version don't have the method build of Class " + WebApps.class.toString() + ". For More Detail: " + e); WebApps .$for("jobhistory", HistoryClientService.class, this, "ws") .with(conf) .withHttpSpnegoKeytabKey(
@SuppressWarnings("unchecked") public static <T> Builder<T> $for(String prefix, T app) { return $for(prefix, (Class<T>)app.getClass(), app); }
public static <T> Builder<T> $for(String prefix) { return $for(prefix, null, null); } }
@SuppressWarnings("unchecked") public static <T> Builder<T> $for(String prefix, T app) { return $for(prefix, (Class<T>)app.getClass(), app); }
public static void main(String[] args) { WebApps.$for("test").at(8888).inDevMode().start().joinThread(); } }
@Test public void testServePathsNoName() { WebApp app = WebApps.$for("", this).start(); assertEquals("/", app.getRedirectPath()); String[] expectedPaths = { "/*" }; String[] pathSpecs = app.getServePathSpecs(); assertEquals(1, pathSpecs.length); for(int i = 0; i < expectedPaths.length; i++) { assertTrue(ArrayUtils.contains(pathSpecs, expectedPaths[i])); } app.stop(); }
@Test public void testServePaths() { WebApp app = WebApps.$for("test", this).start(); assertEquals("/test", app.getRedirectPath()); String[] expectedPaths = { "/test", "/test/*" }; String[] pathSpecs = app.getServePathSpecs(); assertEquals(2, pathSpecs.length); for(int i = 0; i < expectedPaths.length; i++) { assertTrue(ArrayUtils.contains(pathSpecs, expectedPaths[i])); } app.stop(); }
@Test(expected=org.apache.hadoop.yarn.webapp.WebAppException.class) public void testCreateWithNonZeroPort() { WebApp app = WebApps.$for(this).at(50000).start(); int port = app.getListenerAddress().getPort(); assertEquals(50000, port); // start another WebApp with same NonZero port WebApp app2 = WebApps.$for(this).at(50000).start(); // An exception occurs (findPort disabled) app.stop(); app2.stop(); }
@Test(expected=org.apache.hadoop.yarn.webapp.WebAppException.class) public void testCreateWithBindAddressNonZeroPort() { WebApp app = WebApps.$for(this).at("0.0.0.0:50000").start(); int port = app.getListenerAddress().getPort(); assertEquals(50000, port); // start another WebApp with same NonZero port WebApp app2 = WebApps.$for(this).at("0.0.0.0:50000").start(); // An exception occurs (findPort disabled) app.stop(); app2.stop(); }
@Test public void testServePaths() { WebApp app = WebApps.$for("test", this).start(); assertEquals("/test", app.getRedirectPath()); String[] expectedPaths = { "/test", "/test/*" }; String[] pathSpecs = app.getServePathSpecs(); assertEquals(2, pathSpecs.length); for(int i = 0; i < expectedPaths.length; i++) { assertTrue(ArrayUtils.contains(pathSpecs, expectedPaths[i])); } app.stop(); }
@Test public void testCreateWithPort() { // see if the ephemeral port is updated WebApp app = WebApps.$for(this).at(0).start(); int port = app.getListenerAddress().getPort(); assertTrue(port > 0); app.stop(); // try to reuse the port app = WebApps.$for(this).at(port).start(); assertEquals(port, app.getListenerAddress().getPort()); app.stop(); }
@Test public void testServePathsNoName() { WebApp app = WebApps.$for("", this).start(); assertEquals("/", app.getRedirectPath()); String[] expectedPaths = { "/*" }; String[] pathSpecs = app.getServePathSpecs(); assertEquals(1, pathSpecs.length); for(int i = 0; i < expectedPaths.length; i++) { assertTrue(ArrayUtils.contains(pathSpecs, expectedPaths[i])); } app.stop(); }
@Test(expected=org.apache.hadoop.yarn.webapp.WebAppException.class) public void testCreateWithNonZeroPort() { WebApp app = WebApps.$for(this).at(50000).start(); int port = app.getListenerAddress().getPort(); assertEquals(50000, port); // start another WebApp with same NonZero port WebApp app2 = WebApps.$for(this).at(50000).start(); // An exception occurs (findPort disabled) app.stop(); app2.stop(); }
@Test(expected=org.apache.hadoop.yarn.webapp.WebAppException.class) public void testCreateWithBindAddressNonZeroPort() { WebApp app = WebApps.$for(this).at("0.0.0.0:50000").start(); int port = app.getListenerAddress().getPort(); assertEquals(50000, port); // start another WebApp with same NonZero port WebApp app2 = WebApps.$for(this).at("0.0.0.0:50000").start(); // An exception occurs (findPort disabled) app.stop(); app2.stop(); }
public static void main(String[] args) throws Exception { // For manual testing WebApps.$for("yarn", new TestRMWebApp()).at(8888).inDevMode(). start(new RMWebApp(mockRm(2500, 8, 8, 8*GiB))).joinThread(); WebApps.$for("yarn", new TestRMWebApp()).at(8888).inDevMode(). start(new RMWebApp(mockFifoRm(10, 1, 4, 8*GiB))).joinThread(); } }
public static void main(String[] args) { WebApps.$for("yarn", AppContext.class, new MockAppContext(0, 8, 88, 4)). at(58888).inDevMode().start(new AMWebApp()).joinThread(); } }
@Test(expected=org.apache.hadoop.yarn.webapp.WebAppException.class) public void testCreateWithBindAddressNonZeroPort() { WebApp app = WebApps.$for(this).at("0.0.0.0:50000").start(); int port = app.getListenerAddress().getPort(); assertEquals(50000, port); // start another WebApp with same NonZero port WebApp app2 = WebApps.$for(this).at("0.0.0.0:50000").start(); // An exception occurs (findPort disabled) app.stop(); app2.stop(); }
@Test public void testCreateWithPort() { // see if the ephemeral port is updated WebApp app = WebApps.$for(this).at(0).start(); int port = app.getListenerAddress().getPort(); assertTrue(port > 0); app.stop(); // try to reuse the port app = WebApps.$for(this).at(port).start(); assertEquals(port, app.getListenerAddress().getPort()); app.stop(); }
@Test public void testCreateWithPort() { // see if the ephemeral port is updated WebApp app = WebApps.$for(this).at(0).start(); int port = app.getListenerAddress().getPort(); assertTrue(port > 0); app.stop(); // try to reuse the port app = WebApps.$for(this).at(port).start(); assertEquals(port, app.getListenerAddress().getPort()); app.stop(); }