@Test(timeout=5000) public void testWebAppProxyServlet() throws Exception { Configuration configuration = new Configuration(); configuration.set(YarnConfiguration.PROXY_ADDRESS, "localhost:9090"); configuration.setInt("hadoop.http.max.threads", 5); WebAppProxyServerForTest proxy = new WebAppProxyServerForTest(); proxy.init(configuration); proxy.start(); int proxyPort = proxy.proxy.proxyServer.getConnectorAddress(0).getPort(); AppReportFetcherForTest appReportFetcher = proxy.proxy.appReportFetcher; try { URL wrongUrl = new URL("http: HttpURLConnection proxyConn = (HttpURLConnection) wrongUrl .openConnection(); proxyConn.connect(); assertEquals(HttpURLConnection.HTTP_INTERNAL_ERROR, proxyConn.getResponseCode()); URL url = new URL("http: proxyConn = (HttpURLConnection) url.openConnection(); proxyConn.setRequestProperty("Cookie", "checked_application_0_0000=true"); proxyConn.connect(); assertEquals(HttpURLConnection.HTTP_OK, proxyConn.getResponseCode()); assertTrue(isResponseCookiePresent( proxyConn, "checked_application_0_0000", "true")); appReportFetcher.answer = 1; proxyConn = (HttpURLConnection) url.openConnection(); proxyConn.setRequestProperty("Cookie", "checked_application_0_0000=true"); proxyConn.connect(); assertEquals(HttpURLConnection.HTTP_NOT_FOUND, proxyConn.getResponseCode()); assertFalse(isResponseCookiePresent( proxyConn, "checked_application_0_0000", "true")); appReportFetcher.answer = 4; proxyConn = (HttpURLConnection) url.openConnection(); proxyConn.setRequestProperty("Cookie", "checked_application_0_0000=true"); proxyConn.connect(); assertEquals(HttpURLConnection.HTTP_NOT_FOUND, proxyConn.getResponseCode()); assertFalse(isResponseCookiePresent( proxyConn, "checked_application_0_0000", "true")); appReportFetcher.answer = 2; proxyConn = (HttpURLConnection) url.openConnection(); proxyConn.connect(); assertEquals(HttpURLConnection.HTTP_OK, proxyConn.getResponseCode()); String s = readInputStream(proxyConn.getInputStream()); assertTrue(s .contains("to continue to an Application Master web interface owned by")); assertTrue(s.contains("WARNING: The following page may not be safe!")); appReportFetcher.answer = 3; proxyConn = (HttpURLConnection) url.openConnection(); proxyConn.setRequestProperty("Cookie", "checked_application_0_0000=true"); proxyConn.connect(); assertEquals(HttpURLConnection.HTTP_OK, proxyConn.getResponseCode()); appReportFetcher.answer = 5; URL clientUrl = new URL("http: + "/proxy/application_00_0/test/tez?x=y&h=p"); proxyConn = (HttpURLConnection) clientUrl.openConnection(); proxyConn.connect(); LOG.info("" + proxyConn.getURL()); LOG.info("ProxyConn.getHeaderField(): " + proxyConn.getHeaderField("Location")); assertEquals("http: + "/foo/bar/test/tez?a=b&x=y&h=p#main", proxyConn.getURL().toString()); } finally { proxy.close(); } }
public WebAppProxyServlet() { super(); conf = new YarnConfiguration(); this.trackingUriPlugins = conf.getInstances(YarnConfiguration.YARN_TRACKING_URL_GENERATOR, TrackingUriPlugin.class); this.rmAppPageUrlBase = StringHelper.pjoin( WebAppUtils.getResolvedRMWebAppURLWithScheme(conf), "cluster", "app"); }
WebAppProxyServlet extends HttpServlet { public WebAppProxyServlet() { super(); conf = new YarnConfiguration(); this.trackingUriPlugins = conf.getInstances(YarnConfiguration.YARN_TRACKING_URL_GENERATOR, TrackingUriPlugin.class); this.rmAppPageUrlBase = StringHelper.pjoin( WebAppUtils.getResolvedRMWebAppURLWithScheme(conf), "cluster", "app"); } }
WebAppProxyServlet extends HttpServlet { public WebAppProxyServlet() { super(); conf = new YarnConfiguration(); this.trackingUriPlugins = conf.getInstances(YarnConfiguration.YARN_TRACKING_URL_GENERATOR, TrackingUriPlugin.class); this.rmAppPageUrlBase = StringHelper.pjoin( WebAppUtils.getResolvedRMWebAppURLWithScheme(conf), "cluster", "app"); } WebAppProxyServlet(); }
WebAppProxyServlet extends HttpServlet { public WebAppProxyServlet() { super(); conf = new YarnConfiguration(); this.trackingUriPlugins = conf.getInstances(YarnConfiguration.YARN_TRACKING_URL_GENERATOR, TrackingUriPlugin.class); this.rmAppPageUrlBase = StringHelper.pjoin( WebAppUtils.getResolvedRMWebAppURLWithScheme(conf), "cluster", "app"); } WebAppProxyServlet();  }
WebAppProxyServlet extends HttpServlet { public WebAppProxyServlet() { super(); conf = new YarnConfiguration(); this.trackingUriPlugins = conf.getInstances(YarnConfiguration.YARN_TRACKING_URL_GENERATOR, TrackingUriPlugin.class); this.rmAppPageUrlBase = StringHelper.pjoin( WebAppUtils.getResolvedRMWebAppURLWithScheme(conf), "cluster", "app"); } WebAppProxyServlet();  static final String PROXY_USER_COOKIE_NAME; }