YARN-1859. Fixed WebAppProxyServlet to correctly handle applications absent on the ResourceManager. Contributed by Zhijie Shen.
svn merge --ignore-ancestry -c 1579866 ../../trunk/ git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1579867 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2f8d99f642
commit
c7b39f75ba
|
@ -515,6 +515,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.io.IOUtils;
|
|||
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 @@ public class WebAppProxyServlet extends HttpServlet {
|
|||
|
||||
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.ApplicationReport;
|
|||
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 class TestWebAppProxyServlet {
|
|||
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 class TestWebAppProxyServlet {
|
|||
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