YARN-2900. Application (Attempt and Container) Not Found in AHS results
in Internal Server Error (500). Contributed by Zhijie Shen and Mit Desai (cherry picked from commit 06f8e9cabaf3c05cd7d16215cff47265ea773f39) (cherry picked from commit 4fee8b320276bac86278e1ae0a3397592a78aa18) (cherry picked from commit 6c7b625138ce3b262a8c8aa28077074b553638ed)
This commit is contained in:
parent
46b9393cab
commit
1c6a287bf5
@ -147,6 +147,9 @@ Release 2.6.1 - UNRELEASED
|
|||||||
YARN-3700. Made generic history service load a number of latest applications
|
YARN-3700. Made generic history service load a number of latest applications
|
||||||
according to the parameter or the configuration. (Xuan Gong via zjshen)
|
according to the parameter or the configuration. (Xuan Gong via zjshen)
|
||||||
|
|
||||||
|
YARN-2900. Application (Attempt and Container) Not Found in AHS results
|
||||||
|
in InternalServer Error (500). (Zhijie Shen and Mit Desai via xgong)
|
||||||
|
|
||||||
Release 2.6.0 - 2014-11-18
|
Release 2.6.0 - 2014-11-18
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
@ -41,6 +41,9 @@
|
|||||||
import org.apache.hadoop.yarn.api.records.ContainerId;
|
import org.apache.hadoop.yarn.api.records.ContainerId;
|
||||||
import org.apache.hadoop.yarn.api.records.ContainerReport;
|
import org.apache.hadoop.yarn.api.records.ContainerReport;
|
||||||
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
||||||
|
import org.apache.hadoop.yarn.exceptions.ApplicationAttemptNotFoundException;
|
||||||
|
import org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException;
|
||||||
|
import org.apache.hadoop.yarn.exceptions.ContainerNotFoundException;
|
||||||
import org.apache.hadoop.yarn.exceptions.YarnException;
|
import org.apache.hadoop.yarn.exceptions.YarnException;
|
||||||
import org.apache.hadoop.yarn.server.security.ApplicationACLsManager;
|
import org.apache.hadoop.yarn.server.security.ApplicationACLsManager;
|
||||||
import org.apache.hadoop.yarn.server.timeline.TimelineDataManager;
|
import org.apache.hadoop.yarn.server.timeline.TimelineDataManager;
|
||||||
@ -54,12 +57,13 @@ public class TestApplicationHistoryClientService {
|
|||||||
|
|
||||||
private static ApplicationHistoryClientService clientService;
|
private static ApplicationHistoryClientService clientService;
|
||||||
private static TimelineDataManager dataManager;
|
private static TimelineDataManager dataManager;
|
||||||
|
private final static int MAX_APPS = 2;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setup() throws Exception {
|
public static void setup() throws Exception {
|
||||||
Configuration conf = new YarnConfiguration();
|
Configuration conf = new YarnConfiguration();
|
||||||
TimelineStore store =
|
TimelineStore store =
|
||||||
TestApplicationHistoryManagerOnTimelineStore.createStore(2);
|
TestApplicationHistoryManagerOnTimelineStore.createStore(MAX_APPS);
|
||||||
TimelineACLsManager aclsManager = new TimelineACLsManager(conf);
|
TimelineACLsManager aclsManager = new TimelineACLsManager(conf);
|
||||||
dataManager =
|
dataManager =
|
||||||
new TimelineDataManager(store, aclsManager);
|
new TimelineDataManager(store, aclsManager);
|
||||||
@ -71,6 +75,70 @@ public static void setup() throws Exception {
|
|||||||
clientService = new ApplicationHistoryClientService(historyManager);
|
clientService = new ApplicationHistoryClientService(historyManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testApplicationNotFound() throws IOException, YarnException {
|
||||||
|
ApplicationId appId = null;
|
||||||
|
appId = ApplicationId.newInstance(0, MAX_APPS + 1);
|
||||||
|
GetApplicationReportRequest request =
|
||||||
|
GetApplicationReportRequest.newInstance(appId);
|
||||||
|
try {
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
GetApplicationReportResponse response =
|
||||||
|
clientService.getApplicationReport(request);
|
||||||
|
Assert.fail("Exception should have been thrown before we reach here.");
|
||||||
|
} catch (ApplicationNotFoundException e) {
|
||||||
|
//This exception is expected.
|
||||||
|
Assert.assertTrue(e.getMessage().contains(
|
||||||
|
"doesn't exist in the timeline store"));
|
||||||
|
} catch (Exception e) {
|
||||||
|
Assert.fail("Undesired exception caught");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testApplicationAttemptNotFound() throws IOException, YarnException {
|
||||||
|
ApplicationId appId = ApplicationId.newInstance(0, 1);
|
||||||
|
ApplicationAttemptId appAttemptId =
|
||||||
|
ApplicationAttemptId.newInstance(appId, MAX_APPS + 1);
|
||||||
|
GetApplicationAttemptReportRequest request =
|
||||||
|
GetApplicationAttemptReportRequest.newInstance(appAttemptId);
|
||||||
|
try {
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
GetApplicationAttemptReportResponse response =
|
||||||
|
clientService.getApplicationAttemptReport(request);
|
||||||
|
Assert.fail("Exception should have been thrown before we reach here.");
|
||||||
|
} catch (ApplicationAttemptNotFoundException e) {
|
||||||
|
//This Exception is expected
|
||||||
|
System.out.println(e.getMessage());
|
||||||
|
Assert.assertTrue(e.getMessage().contains(
|
||||||
|
"doesn't exist in the timeline store"));
|
||||||
|
} catch (Exception e) {
|
||||||
|
Assert.fail("Undesired exception caught");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testContainerNotFound() throws IOException, YarnException {
|
||||||
|
ApplicationId appId = ApplicationId.newInstance(0, 1);
|
||||||
|
ApplicationAttemptId appAttemptId =
|
||||||
|
ApplicationAttemptId.newInstance(appId, 1);
|
||||||
|
ContainerId containerId = ContainerId.newContainerId(appAttemptId,
|
||||||
|
MAX_APPS + 1);
|
||||||
|
GetContainerReportRequest request =
|
||||||
|
GetContainerReportRequest.newInstance(containerId);
|
||||||
|
try {
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
GetContainerReportResponse response =
|
||||||
|
clientService.getContainerReport(request);
|
||||||
|
} catch (ContainerNotFoundException e) {
|
||||||
|
//This exception is expected
|
||||||
|
Assert.assertTrue(e.getMessage().contains(
|
||||||
|
"doesn't exist in the timeline store"));
|
||||||
|
} catch (Exception e) {
|
||||||
|
Assert.fail("Undesired exception caught");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testApplicationReport() throws IOException, YarnException {
|
public void testApplicationReport() throws IOException, YarnException {
|
||||||
ApplicationId appId = null;
|
ApplicationId appId = null;
|
||||||
|
@ -46,6 +46,9 @@
|
|||||||
import org.apache.hadoop.yarn.api.records.ContainerReport;
|
import org.apache.hadoop.yarn.api.records.ContainerReport;
|
||||||
import org.apache.hadoop.yarn.api.records.FinalApplicationStatus;
|
import org.apache.hadoop.yarn.api.records.FinalApplicationStatus;
|
||||||
import org.apache.hadoop.yarn.api.records.YarnApplicationState;
|
import org.apache.hadoop.yarn.api.records.YarnApplicationState;
|
||||||
|
import org.apache.hadoop.yarn.exceptions.ApplicationAttemptNotFoundException;
|
||||||
|
import org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException;
|
||||||
|
import org.apache.hadoop.yarn.exceptions.ContainerNotFoundException;
|
||||||
import org.apache.hadoop.yarn.server.webapp.dao.AppAttemptInfo;
|
import org.apache.hadoop.yarn.server.webapp.dao.AppAttemptInfo;
|
||||||
import org.apache.hadoop.yarn.server.webapp.dao.AppAttemptsInfo;
|
import org.apache.hadoop.yarn.server.webapp.dao.AppAttemptsInfo;
|
||||||
import org.apache.hadoop.yarn.server.webapp.dao.AppInfo;
|
import org.apache.hadoop.yarn.server.webapp.dao.AppInfo;
|
||||||
@ -475,17 +478,21 @@ protected static UserGroupInformation getUser(HttpServletRequest req) {
|
|||||||
|
|
||||||
private static void rewrapAndThrowException(Exception e) {
|
private static void rewrapAndThrowException(Exception e) {
|
||||||
if (e instanceof UndeclaredThrowableException) {
|
if (e instanceof UndeclaredThrowableException) {
|
||||||
if (e.getCause() instanceof AuthorizationException) {
|
rewrapAndThrowThrowable(e.getCause());
|
||||||
throw new ForbiddenException(e.getCause());
|
|
||||||
} else {
|
|
||||||
throw new WebApplicationException(e.getCause());
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (e instanceof AuthorizationException) {
|
rewrapAndThrowThrowable(e);
|
||||||
throw new ForbiddenException(e);
|
}
|
||||||
} else {
|
}
|
||||||
throw new WebApplicationException(e);
|
|
||||||
}
|
private static void rewrapAndThrowThrowable(Throwable t) {
|
||||||
|
if (t instanceof AuthorizationException) {
|
||||||
|
throw new ForbiddenException(t);
|
||||||
|
} if (t instanceof ApplicationNotFoundException ||
|
||||||
|
t instanceof ApplicationAttemptNotFoundException ||
|
||||||
|
t instanceof ContainerNotFoundException) {
|
||||||
|
throw new NotFoundException(t);
|
||||||
|
} else {
|
||||||
|
throw new WebApplicationException(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user