/// <exception cref="System.Exception"/> public virtual void TestAppReportForEmptyTrackingUrl() { configuration.Set(YarnConfiguration.ProxyAddress, "localhost:9090"); // overriding num of web server threads, see HttpServer.HTTP_MAXTHREADS configuration.SetInt("hadoop.http.max.threads", 5); TestWebAppProxyServlet.WebAppProxyServerForTest proxy = new TestWebAppProxyServlet.WebAppProxyServerForTest (this); proxy.Init(configuration); proxy.Start(); int proxyPort = proxy.proxy.proxyServer.GetConnectorAddress(0).Port; TestWebAppProxyServlet.AppReportFetcherForTest appReportFetcher = proxy.proxy.appReportFetcher; try { //set AHS_ENBALED = false to simulate getting the app report from RM configuration.SetBoolean(YarnConfiguration.ApplicationHistoryEnabled, false); ApplicationId app = ApplicationId.NewInstance(0, 0); appReportFetcher.answer = 6; Uri url = new Uri("http://localhost:" + proxyPort + "/proxy/" + app.ToString()); HttpURLConnection proxyConn = (HttpURLConnection)url.OpenConnection(); proxyConn.Connect(); try { proxyConn.GetResponseCode(); } catch (ConnectException) { } // Connection Exception is expected as we have set // appReportFetcher.answer = 6, which does not set anything for // original tracking url field in the app report. string appAddressInRm = WebAppUtils.GetResolvedRMWebAppURLWithScheme(configuration ) + "/cluster" + "/app/" + app.ToString(); NUnit.Framework.Assert.IsTrue("Webapp proxy servlet should have redirected to RM" , proxyConn.GetURL().ToString().Equals(appAddressInRm)); //set AHS_ENBALED = true to simulate getting the app report from AHS configuration.SetBoolean(YarnConfiguration.ApplicationHistoryEnabled, true); proxyConn = (HttpURLConnection)url.OpenConnection(); proxyConn.Connect(); try { proxyConn.GetResponseCode(); } catch (ConnectException) { } // Connection Exception is expected as we have set // appReportFetcher.answer = 6, which does not set anything for // original tracking url field in the app report. string appAddressInAhs = WebAppUtils.GetHttpSchemePrefix(configuration) + WebAppUtils .GetAHSWebAppURLWithoutScheme(configuration) + "/applicationhistory" + "/apps/" + app.ToString(); NUnit.Framework.Assert.IsTrue("Webapp proxy servlet should have redirected to AHS" , proxyConn.GetURL().ToString().Equals(appAddressInAhs)); } finally { proxy.Close(); } }
/// <summary>Default constructor</summary> public WebAppProxyServlet() : base() { conf = new YarnConfiguration(); this.trackingUriPlugins = conf.GetInstances <TrackingUriPlugin>(YarnConfiguration. YarnTrackingUrlGenerator); this.rmAppPageUrlBase = StringHelper.Pjoin(WebAppUtils.GetResolvedRMWebAppURLWithScheme (conf), "cluster", "app"); this.ahsAppPageUrlBase = StringHelper.Pjoin(WebAppUtils.GetHttpSchemePrefix(conf) + WebAppUtils.GetAHSWebAppURLWithoutScheme(conf), "applicationhistory", "apps"); }