diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/src/main/java/org/apache/hadoop/yarn/server/webproxy/WebAppProxyServlet.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/src/main/java/org/apache/hadoop/yarn/server/webproxy/WebAppProxyServlet.java index 408fda7..0ec9067 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/src/main/java/org/apache/hadoop/yarn/server/webproxy/WebAppProxyServlet.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/src/main/java/org/apache/hadoop/yarn/server/webproxy/WebAppProxyServlet.java @@ -324,18 +324,12 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) req.getQueryString(), true), runningUser, id); return; } - URI toFetch = new URI(trackingUri.getScheme(), - trackingUri.getAuthority(), - StringHelper.ujoin(trackingUri.getPath(), rest), req.getQueryString(), - null); - - LOG.info(req.getRemoteUser()+" is accessing unchecked "+toFetch+ - " which is the app master GUI of "+appId+" owned by "+runningUser); - + URI toFetch; switch(applicationReport.getYarnApplicationState()) { case KILLED: case FINISHED: case FAILED: + toFetch = logAndGetFetchURI(req, appId, "", trackingUri, runningUser); resp.sendRedirect(resp.encodeRedirectURL(toFetch.toString())); return; } @@ -343,6 +337,7 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) if(userWasWarned && userApproved) { c = makeCheckCookie(id, true); } + toFetch = logAndGetFetchURI(req, appId, rest, trackingUri, runningUser); proxyLink(req, resp, toFetch, c, getProxyHost()); } catch(URISyntaxException e) { @@ -352,6 +347,19 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) } } + private URI logAndGetFetchURI(HttpServletRequest req, String appId, + String rest, URI trackingUri, String runningUser) + throws URISyntaxException { + URI toFetch = new URI(trackingUri.getScheme(), + trackingUri.getAuthority(), + StringHelper.ujoin(trackingUri.getPath(), rest), req.getQueryString(), + null); + + LOG.info(req.getRemoteUser()+" is accessing unchecked "+toFetch+ + " which is the app master GUI of "+appId+" owned by "+runningUser); + return toFetch; + } + private void readObject(ObjectInputStream input) throws IOException, ClassNotFoundException { input.defaultReadObject(); diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/src/test/java/org/apache/hadoop/yarn/server/webproxy/TestWebAppProxyServlet.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/src/test/java/org/apache/hadoop/yarn/server/webproxy/TestWebAppProxyServlet.java index 1be0115..d6227a5 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/src/test/java/org/apache/hadoop/yarn/server/webproxy/TestWebAppProxyServlet.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/src/test/java/org/apache/hadoop/yarn/server/webproxy/TestWebAppProxyServlet.java @@ -183,6 +183,15 @@ public void testWebAppProxyServlet() throws Exception { proxyConn.setRequestProperty("Cookie", "checked_application_0_0000=true"); proxyConn.connect(); assertEquals(HttpURLConnection.HTTP_OK, proxyConn.getResponseCode()); + //case if the application has finished + appReportFetcher.answer = 5; + url = new URL("http://localhost:" + proxyPort + "/proxy/application_00_0/job/job_00_0"); + proxyConn = (HttpURLConnection) url.openConnection(); + proxyConn.setRequestProperty("Cookie", "checked_application_0_0000=true"); + proxyConn.connect(); + assertEquals(HttpURLConnection.HTTP_OK, proxyConn.getResponseCode()); + assertEquals("http://localhost:" + originalPort + "/foo/bar/", proxyConn + .getURL().toString()); } finally { proxy.close(); } @@ -352,6 +361,10 @@ public ApplicationReport getApplicationReport(ApplicationId appId) return result; } else if (answer == 4) { throw new ApplicationNotFoundException("Application is not found"); + } else if (answer == 5) { + ApplicationReport result = getDefaultApplicationReport(appId); + result.setYarnApplicationState(YarnApplicationState.FINISHED); + return result; } return null; }