YARN-1859. Fixed WebAppProxyServlet to correctly handle applications absent on the ResourceManager. Contributed by Zhijie Shen.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1579866 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
bf428cc474
commit
1c49cfbeb7
@ -530,6 +530,9 @@ Release 2.4.0 - UNRELEASED
|
||||
and thus avoid the failure of TestRMFailover#testRMWebAppRedirect. (Zhijie
|
||||
Shen via vinodkv)
|
||||
|
||||
YARN-1859. Fixed WebAppProxyServlet to correctly handle applications absent
|
||||
on the ResourceManager. (Zhijie Shen via vinodkv)
|
||||
|
||||
Release 2.3.1 - UNRELEASED
|
||||
|
||||
INCOMPATIBLE CHANGES
|
||||
|
@ -50,6 +50,7 @@
|
||||
import org.apache.hadoop.yarn.api.records.ApplicationId;
|
||||
import org.apache.hadoop.yarn.api.records.ApplicationReport;
|
||||
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
||||
import org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException;
|
||||
import org.apache.hadoop.yarn.exceptions.YarnException;
|
||||
import org.apache.hadoop.yarn.util.Apps;
|
||||
import org.apache.hadoop.yarn.util.StringHelper;
|
||||
@ -274,7 +275,12 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp)
|
||||
|
||||
boolean checkUser = securityEnabled && (!userWasWarned || !userApproved);
|
||||
|
||||
ApplicationReport applicationReport = getApplicationReport(id);
|
||||
ApplicationReport applicationReport = null;
|
||||
try {
|
||||
applicationReport = getApplicationReport(id);
|
||||
} catch (ApplicationNotFoundException e) {
|
||||
applicationReport = null;
|
||||
}
|
||||
if(applicationReport == null) {
|
||||
LOG.warn(req.getRemoteUser()+" Attempting to access "+id+
|
||||
" that was not found");
|
||||
|
@ -52,6 +52,7 @@
|
||||
import org.apache.hadoop.yarn.api.records.YarnApplicationState;
|
||||
import org.apache.hadoop.yarn.api.records.impl.pb.ApplicationReportPBImpl;
|
||||
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
||||
import org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException;
|
||||
import org.apache.hadoop.yarn.exceptions.YarnException;
|
||||
import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
|
||||
import org.apache.hadoop.yarn.webapp.util.WebAppUtils;
|
||||
@ -149,11 +150,20 @@ public void testWebAppProxyServlet() throws Exception {
|
||||
assertEquals(HttpURLConnection.HTTP_OK, proxyConn.getResponseCode());
|
||||
assertTrue(isResponseCookiePresent(
|
||||
proxyConn, "checked_application_0_0000", "true"));
|
||||
// cannot found application
|
||||
// cannot found application 1: null
|
||||
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"));
|
||||
// cannot found application 2: ApplicationNotFoundException
|
||||
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(
|
||||
@ -340,6 +350,8 @@ public ApplicationReport getApplicationReport(ApplicationId appId)
|
||||
ApplicationReport result = getDefaultApplicationReport(appId);
|
||||
result.setYarnApplicationState(YarnApplicationState.KILLED);
|
||||
return result;
|
||||
} else if (answer == 4) {
|
||||
throw new ApplicationNotFoundException("Application is not found");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user