@Override protected void serviceStop() throws Exception { if (server != null) { server.stop(); } if (webApp != null) { webApp.stop(); } super.serviceStop(); }
Method webAppBuild = WebApps.Builder.class.getMethod("build", WebApp.class); 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(); WebAppContext appWebAppContext = new WebAppContext(); try { httpServer.start(); LOG.info("Web app " + webApp.name() + " started at " + httpServer.getConnectorAddress(0).getPort()); } catch (IOException e) { connectHost + ":" + webApp.getListenerAddress().getPort());
public int getHttpPort() { return webApp.port(); } }
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(); try { httpServer.start(); LOG.info("Web app " + webApp.name() + " started at " + httpServer.getConnectorAddress(0).getPort()); } catch (IOException e) {
@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 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(); }
private InetSocketAddress getListenerAddress() { return this.webApp.httpServer().getConnectorAddress(0); }
public static void main(String[] args) { WebApps.$for(new HelloWorld()).at(8888).inDevMode().start().joinThread(); } }
@GET @Path("/containers") @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ContainersInfo getNodeContainers(@javax.ws.rs.core.Context HttpServletRequest hsr) { init(); ContainersInfo allContainers = new ContainersInfo(); for (Entry<ContainerId, Container> entry : this.nmContext.getContainers() .entrySet()) { if (entry.getValue() == null) { // just skip it continue; } ContainerInfo info = new ContainerInfo(this.nmContext, entry.getValue(), uriInfo.getBaseUri().toString(), webapp.name(), hsr.getRemoteUser()); allContainers.add(info); } return allContainers; }
.with(conf) .start(this.tezAMWebApp); InetSocketAddress address = webApp.getListenerAddress(); if (address != null) { InetSocketAddress bindAddress = NetUtils.createSocketAddrForHost(
String redirectPath = webApp.getRedirectPath(); if (redirectPath != null && !redirectPath.isEmpty()) { res.sendRedirect(redirectPath); rc.prefix = webApp.name(); Router.Dest dest = null; try {
Configuration config = SecurityUtils.configureWebAppSecurity(getConfig(), dag.getValue(Context.DAGContext.SSL_CONFIG)); WebApp webApp = WebApps.$for("stram", StramAppContext.class, appContext, "ws").with(config).start(new StramWebApp(this.dnmgr)); LOG.info("Started web service at port: " + webApp.port()); connectAddress = NetUtils.getConnectAddress(webApp.getListenerAddress()); String hostname = connectAddress.getAddress().getCanonicalHostName(); if (hostname.equals(connectAddress.getAddress().getHostAddress())) { appMasterTrackingUrl = hostname + ":" + webApp.port(); if (ConfigUtils.isSSLEnabled(config)) { appMasterTrackingUrl = "https://" + appMasterTrackingUrl;
@Override public String getRedirectPath() { if (standby) { return buildRedirectPath(); } else return super.getRedirectPath(); }
@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(); }
private InetSocketAddress getListenerAddress() { return this.webApp.httpServer().getConnectorAddress(0); }
public static void main(String[] args) throws Exception { WebApps.$for(new MyApp()).at(8888).inDevMode().start().joinThread(); } }
@GET @Path("/containers") @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ContainersInfo getNodeContainers() { init(); ContainersInfo allContainers = new ContainersInfo(); for (Entry<ContainerId, Container> entry : this.nmContext.getContainers() .entrySet()) { if (entry.getValue() == null) { // just skip it continue; } ContainerInfo info = new ContainerInfo(this.nmContext, entry.getValue(), uriInfo.getBaseUri().toString(), webapp.name()); allContainers.add(info); } return allContainers; }