diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryClientService.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryClientService.java index 2334fde..7f85aa2 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryClientService.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryClientService.java @@ -149,6 +149,13 @@ public GetApplicationAttemptReportResponse getApplicationAttemptReport( GetApplicationAttemptReportResponse response = GetApplicationAttemptReportResponse.newInstance(history .getApplicationAttempt(request.getApplicationAttemptId())); + if (response == null) { + // If there is no such application, throw + // ApplicationNotFoundException and let client to handle. + throw new ApplicationNotFoundException("Application with id '" + + request.getApplicationAttemptId().getApplicationId() + + "' doesn't exist in RM."); + } return response; } catch (IOException e) { throw new ApplicationAttemptNotFoundException(e.getMessage()); @@ -163,6 +170,12 @@ public GetApplicationAttemptsResponse getApplicationAttempts( GetApplicationAttemptsResponse .newInstance(new ArrayList(history .getApplicationAttempts(request.getApplicationId()).values())); + if (response == null) { + // If there is no such application, throw + // ApplicationNotFoundException and let client to handle. + throw new ApplicationNotFoundException("Application with id '" + + request.getApplicationId() + "' doesn't exist in RM."); + } return response; } @@ -174,6 +187,12 @@ public GetApplicationReportResponse getApplicationReport( GetApplicationReportResponse response = GetApplicationReportResponse.newInstance(history .getApplication(applicationId)); + if (response == null) { + // If there is no such application, throw + // ApplicationNotFoundException and let client to handle. + throw new ApplicationNotFoundException("Application with id '" + + applicationId + "' doesn't exist in RM."); + } return response; } catch (IOException e) { throw new ApplicationNotFoundException(e.getMessage()); @@ -208,6 +227,13 @@ public GetContainersResponse getContainers(GetContainersRequest request) GetContainersResponse response = GetContainersResponse.newInstance(new ArrayList( history.getContainers(request.getApplicationAttemptId()).values())); + if (response == null) { + // If there is no such application, throw + // ApplicationNotFoundException and let client to handle. + throw new ApplicationNotFoundException("Application with id '" + + request.getApplicationAttemptId().getApplicationId() + + "' doesn't exist in RM."); + } return response; } diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryManagerOnTimelineStore.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryManagerOnTimelineStore.java index cd429d0..3e6065f 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryManagerOnTimelineStore.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryManagerOnTimelineStore.java @@ -24,6 +24,8 @@ import java.util.List; import java.util.Map; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.security.authorize.AuthorizationException; @@ -47,7 +49,6 @@ import org.apache.hadoop.yarn.api.records.timeline.TimelineEntity; import org.apache.hadoop.yarn.api.records.timeline.TimelineEvent; 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.server.metrics.AppAttemptMetricsConstants; @@ -68,6 +69,9 @@ @VisibleForTesting static final String UNAVAILABLE = "N/A"; + + private static final Log LOG = LogFactory. + getLog(ApplicationHistoryManagerOnTimelineStore.class); private TimelineDataManager timelineDataManager; private ApplicationACLsManager aclsManager; @@ -539,8 +543,9 @@ private ApplicationReportExt getApplication(ApplicationId appId, appId.toString(), EnumSet.allOf(Field.class), UserGroupInformation.getLoginUser()); if (entity == null) { - throw new ApplicationNotFoundException("The entity for application " + + LOG.info("The entity for application " + appId + " doesn't exist in the timeline store"); + return null; } else { return generateApplicationReport(entity, field); }