From 3a7fd3e4465775a9b25c9f8779ed9aec5ac10b7c Mon Sep 17 00:00:00 2001 From: Prabhu Joseph Date: Mon, 25 Mar 2019 22:11:27 +0530 Subject: [PATCH] YARN-9403 --- .../storage/HBaseTimelineReaderImpl.java | 3 +- .../reader/TimelineEntityReaderFactory.java | 12 +-- .../reader/TimelineReaderContext.java | 31 +++++++- .../reader/TimelineReaderWebServices.java | 90 ++++++++++++++++------ .../reader/TimelineReaderWebServicesUtils.java | 26 ++++--- 5 files changed, 122 insertions(+), 40 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase/hadoop-yarn-server-timelineservice-hbase-client/src/main/java/org/apache/hadoop/yarn/server/timelineservice/storage/HBaseTimelineReaderImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase/hadoop-yarn-server-timelineservice-hbase-client/src/main/java/org/apache/hadoop/yarn/server/timelineservice/storage/HBaseTimelineReaderImpl.java index d00ae4b..29eaf23 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase/hadoop-yarn-server-timelineservice-hbase-client/src/main/java/org/apache/hadoop/yarn/server/timelineservice/storage/HBaseTimelineReaderImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase/hadoop-yarn-server-timelineservice-hbase-client/src/main/java/org/apache/hadoop/yarn/server/timelineservice/storage/HBaseTimelineReaderImpl.java @@ -73,7 +73,8 @@ public void serviceInit(Configuration conf) throws Exception { YarnConfiguration.DEFAULT_RM_CLUSTER_ID); monitorContext = new TimelineReaderContext(clusterId, null, null, null, null, - TimelineEntityType.YARN_FLOW_ACTIVITY.toString(), null, null); + TimelineEntityType.YARN_FLOW_ACTIVITY.toString(), null, null, + null, TimelineEntityType.YARN_FLOW_ACTIVITY); monitorInterval = conf.getLong( YarnConfiguration.TIMELINE_SERVICE_READER_STORAGE_MONITOR_INTERVAL_MS, YarnConfiguration.DEFAULT_TIMELINE_SERVICE_STORAGE_MONITOR_INTERVAL_MS); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase/hadoop-yarn-server-timelineservice-hbase-client/src/main/java/org/apache/hadoop/yarn/server/timelineservice/storage/reader/TimelineEntityReaderFactory.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase/hadoop-yarn-server-timelineservice-hbase-client/src/main/java/org/apache/hadoop/yarn/server/timelineservice/storage/reader/TimelineEntityReaderFactory.java index fa16077..bb81a5c 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase/hadoop-yarn-server-timelineservice-hbase-client/src/main/java/org/apache/hadoop/yarn/server/timelineservice/storage/reader/TimelineEntityReaderFactory.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase/hadoop-yarn-server-timelineservice-hbase-client/src/main/java/org/apache/hadoop/yarn/server/timelineservice/storage/reader/TimelineEntityReaderFactory.java @@ -43,13 +43,13 @@ public static TimelineEntityReader createSingleEntityReader( TimelineReaderContext context, TimelineDataToRetrieve dataToRetrieve) { // currently the types that are handled separate from the generic entity // table are application, flow run, and flow activity entities - if (TimelineEntityType.YARN_APPLICATION.matches(context.getEntityType())) { + if (TimelineEntityType.YARN_APPLICATION == context.getSystemEntityType()) { return new ApplicationEntityReader(context, dataToRetrieve); } else if (TimelineEntityType. - YARN_FLOW_RUN.matches(context.getEntityType())) { + YARN_FLOW_RUN == context.getSystemEntityType()) { return new FlowRunEntityReader(context, dataToRetrieve); } else if (TimelineEntityType. - YARN_FLOW_ACTIVITY.matches(context.getEntityType())) { + YARN_FLOW_ACTIVITY == context.getSystemEntityType()) { return new FlowActivityEntityReader(context, dataToRetrieve); } else { // assume we're dealing with a generic entity read @@ -73,13 +73,13 @@ public static TimelineEntityReader createMultipleEntitiesReader( TimelineDataToRetrieve dataToRetrieve) { // currently the types that are handled separate from the generic entity // table are application, flow run, and flow activity entities - if (TimelineEntityType.YARN_APPLICATION.matches(context.getEntityType())) { + if (TimelineEntityType.YARN_APPLICATION == context.getSystemEntityType()) { return new ApplicationEntityReader(context, filters, dataToRetrieve); } else if (TimelineEntityType. - YARN_FLOW_ACTIVITY.matches(context.getEntityType())) { + YARN_FLOW_ACTIVITY == context.getSystemEntityType()) { return new FlowActivityEntityReader(context, filters, dataToRetrieve); } else if (TimelineEntityType. - YARN_FLOW_RUN.matches(context.getEntityType())) { + YARN_FLOW_RUN == context.getSystemEntityType()) { return new FlowRunEntityReader(context, filters, dataToRetrieve); } else { if (context.getDoAsUser() != null) { diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/reader/TimelineReaderContext.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/reader/TimelineReaderContext.java index 67c3d29..09e5a35 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/reader/TimelineReaderContext.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/reader/TimelineReaderContext.java @@ -21,6 +21,7 @@ import org.apache.hadoop.classification.InterfaceAudience.Private; import org.apache.hadoop.classification.InterfaceStability.Unstable; import org.apache.hadoop.yarn.server.timelineservice.TimelineContext; +import org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntityType; /** * Encapsulates fields necessary to make a query in timeline reader. @@ -33,6 +34,8 @@ private String entityId; private Long entityIdPrefix; private String doAsUser; + private TimelineEntityType systemEntityType; + public TimelineReaderContext(String clusterId, String userId, String flowName, Long flowRunId, String appId, String entityType, String entityId) { super(clusterId, userId, flowName, flowRunId, appId); @@ -55,10 +58,19 @@ public TimelineReaderContext(String clusterId, String userId, String flowName, this.doAsUser = doasUser; } + public TimelineReaderContext(String clusterId, String userId, String flowName, + Long flowRunId, String appId, String entityType, Long entityIdPrefix, + String entityId, String doasUser, TimelineEntityType systemEntityType) { + this(clusterId, userId, flowName, flowRunId, appId, entityType, + entityIdPrefix, entityId, doasUser); + this.systemEntityType = systemEntityType; + } + public TimelineReaderContext(TimelineReaderContext other) { this(other.getClusterId(), other.getUserId(), other.getFlowName(), other.getFlowRunId(), other.getAppId(), other.getEntityType(), - other.getEntityIdPrefix(), other.getEntityId(), other.getDoAsUser()); + other.getEntityIdPrefix(), other.getEntityId(), other.getDoAsUser(), + other.getSystemEntityType()); } @Override @@ -70,6 +82,9 @@ public int hashCode() { result = prime * result + ((entityId == null) ? 0 : entityId.hashCode()); result = prime * result + ((entityType == null) ? 0 : entityType.hashCode()); + result = + prime * result + ((systemEntityType == null) ? 0 : + systemEntityType.hashCode()); return result; } @@ -96,6 +111,13 @@ public boolean equals(Object obj) { } else if (!entityType.equals(other.entityType)) { return false; } + if (systemEntityType == null) { + if (other.systemEntityType != null) { + return false; + } + } else if (systemEntityType != other.systemEntityType) { + return false; + } return true; } @@ -130,4 +152,11 @@ public String getDoAsUser() { public void setDoAsUser(String doAsUser) { this.doAsUser = doAsUser; } + + public TimelineEntityType getSystemEntityType() { return systemEntityType; } + + public void setSystemEntityType(TimelineEntityType systemEntityType) { + this.systemEntityType = systemEntityType; + } + } \ No newline at end of file diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/reader/TimelineReaderWebServices.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/reader/TimelineReaderWebServices.java index 330e1f4..f0a600c 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/reader/TimelineReaderWebServices.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/reader/TimelineReaderWebServices.java @@ -338,6 +338,7 @@ public TimelineAbout about( } context.setEntityType( TimelineReaderWebServicesUtils.parseStr(entityType)); + context.setSystemEntityType(null); entities = timelineReaderManager.getEntities(context, TimelineReaderWebServicesUtils.createTimelineEntityFilters( limit, createdTimeStart, createdTimeEnd, relatesTo, isRelatedTo, @@ -346,7 +347,7 @@ public TimelineAbout about( TimelineReaderWebServicesUtils.createTimelineDataToRetrieve( confsToRetrieve, metricsToRetrieve, fields, metricsLimit, metricsTimeStart, metricsTimeEnd)); - checkAccessForGenericEntities(entities, callerUGI, entityType); + checkAccessForGenericEntities(entities, callerUGI, null); succeeded = true; } catch (Exception e) { handleException(e, url, startTime, @@ -483,7 +484,7 @@ public TimelineAbout about( flowRunId, limit, createdTimeStart, createdTimeEnd, relatesTo, isRelatedTo, infofilters, conffilters, metricfilters, eventfilters, confsToRetrieve, metricsToRetrieve, fields, metricsLimit, - metricsTimeStart, metricsTimeEnd, fromId); + metricsTimeStart, metricsTimeEnd, fromId, null); } /** @@ -603,6 +604,24 @@ public TimelineAbout about( @QueryParam("metricstimestart") String metricsTimeStart, @QueryParam("metricstimeend") String metricsTimeEnd, @QueryParam("fromid") String fromId) { + return getEntities(req, res, null, appId, entityType, userId, flowName, + flowRunId, limit, createdTimeStart, createdTimeEnd, relatesTo, + isRelatedTo, infofilters, conffilters, metricfilters, eventfilters, + confsToRetrieve, metricsToRetrieve, fields, metricsLimit, + metricsTimeStart, metricsTimeEnd, fromId, null); + } + + + public Set getEntities(HttpServletRequest req, + HttpServletResponse res, String clusterId, String appId, + String entityType, String userId, String flowName, + String flowRunId, String limit, String createdTimeStart, + String createdTimeEnd, String relatesTo, String isRelatedTo, + String infofilters, String conffilters, String metricfilters, + String eventfilters, String confsToRetrieve, String metricsToRetrieve, + String fields, String metricsLimit, String metricsTimeStart, + String metricsTimeEnd, String fromId, + TimelineEntityType systemEntityType) { String url = req.getRequestURI() + (req.getQueryString() == null ? "" : QUERY_STRING_SEP + req.getQueryString()); @@ -618,7 +637,7 @@ public TimelineAbout about( try { TimelineReaderContext context = TimelineReaderWebServicesUtils .createTimelineReaderContext(clusterId, userId, flowName, flowRunId, - appId, entityType, null, null); + appId, entityType, null, null, systemEntityType); entities = timelineReaderManager.getEntities(context, TimelineReaderWebServicesUtils .createTimelineEntityFilters(limit, createdTimeStart, @@ -628,7 +647,7 @@ public TimelineAbout about( .createTimelineDataToRetrieve(confsToRetrieve, metricsToRetrieve, fields, metricsLimit, metricsTimeStart, metricsTimeEnd)); - checkAccessForGenericEntities(entities, callerUGI, entityType); + checkAccessForGenericEntities(entities, callerUGI, systemEntityType); succeeded = true; } catch (Exception e) { handleException(e, url, startTime, @@ -720,6 +739,7 @@ public TimelineEntity getEntity( if (context == null) { throw new BadRequestException("Incorrect UID " + uId); } + context.setSystemEntityType(null); entity = timelineReaderManager.getEntity(context, TimelineReaderWebServicesUtils.createTimelineDataToRetrieve( confsToRetrieve, metricsToRetrieve, fields, metricsLimit, @@ -820,7 +840,7 @@ public TimelineEntity getEntity( @QueryParam("entityidprefix") String entityIdPrefix) { return getEntity(req, res, null, appId, entityType, entityId, userId, flowName, flowRunId, confsToRetrieve, metricsToRetrieve, fields, - metricsLimit, metricsTimeStart, metricsTimeEnd, entityIdPrefix); + metricsLimit, metricsTimeStart, metricsTimeEnd, entityIdPrefix, null); } /** @@ -899,6 +919,18 @@ public TimelineEntity getEntity( @QueryParam("metricstimestart") String metricsTimeStart, @QueryParam("metricstimeend") String metricsTimeEnd, @QueryParam("entityidprefix") String entityIdPrefix) { + return getEntity(req, res, clusterId, appId, entityType, entityId, + userId, flowName, flowRunId, confsToRetrieve, metricsToRetrieve, fields, + metricsLimit, metricsTimeStart, metricsTimeEnd, entityIdPrefix, null); + } + + public TimelineEntity getEntity(HttpServletRequest req, + HttpServletResponse res, String clusterId, String appId, + String entityType, String entityId, String userId, String flowName, + String flowRunId, String confsToRetrieve, String metricsToRetrieve, + String fields, String metricsLimit, String metricsTimeStart, + String metricsTimeEnd, String entityIdPrefix, + TimelineEntityType systemEntityType) { String url = req.getRequestURI() + (req.getQueryString() == null ? "" : QUERY_STRING_SEP + req.getQueryString()); @@ -915,7 +947,7 @@ public TimelineEntity getEntity( entity = timelineReaderManager.getEntity( TimelineReaderWebServicesUtils.createTimelineReaderContext( clusterId, userId, flowName, flowRunId, appId, entityType, - entityIdPrefix, entityId), + entityIdPrefix, entityId, systemEntityType), TimelineReaderWebServicesUtils.createTimelineDataToRetrieve( confsToRetrieve, metricsToRetrieve, fields, metricsLimit, metricsTimeStart, metricsTimeEnd)); @@ -939,6 +971,7 @@ public TimelineEntity getEntity( return entity; } + /** * Return a single flow run for given UID which is a delimited string * containing clusterid, userid, flow name and flowrun id. @@ -991,6 +1024,7 @@ public TimelineEntity getFlowRun( // TODO to be removed or modified once ACL story is played checkAccess(timelineReaderManager, callerUGI, context.getUserId()); context.setEntityType(TimelineEntityType.YARN_FLOW_RUN.toString()); + context.setSystemEntityType(TimelineEntityType.YARN_FLOW_RUN); entity = timelineReaderManager.getEntity(context, TimelineReaderWebServicesUtils.createTimelineDataToRetrieve( null, metricsToRetrieve, null, null, null, null)); @@ -1103,7 +1137,8 @@ public TimelineEntity getFlowRun( try { TimelineReaderContext context = TimelineReaderWebServicesUtils .createTimelineReaderContext(clusterId, userId, flowName, flowRunId, - null, TimelineEntityType.YARN_FLOW_RUN.toString(), null, null); + null, TimelineEntityType.YARN_FLOW_RUN.toString(), null, null, + TimelineEntityType.YARN_FLOW_RUN); // TODO to be removed or modified once ACL story is played checkAccess(timelineReaderManager, callerUGI, context.getUserId()); @@ -1205,6 +1240,7 @@ public TimelineEntity getFlowRun( // TODO to be removed or modified once ACL story is played checkAccess(timelineReaderManager, callerUGI, context.getUserId()); context.setEntityType(TimelineEntityType.YARN_FLOW_RUN.toString()); + context.setSystemEntityType(TimelineEntityType.YARN_FLOW_RUN); entities = timelineReaderManager.getEntities(context, TimelineReaderWebServicesUtils.createTimelineEntityFilters( limit, createdTimeStart, createdTimeEnd, null, null, null, @@ -1359,7 +1395,7 @@ public TimelineEntity getFlowRun( TimelineReaderContext timelineReaderContext = TimelineReaderWebServicesUtils .createTimelineReaderContext(clusterId, userId, flowName, null, null, TimelineEntityType.YARN_FLOW_RUN.toString(), null, - null); + null, TimelineEntityType.YARN_FLOW_RUN); // TODO to be removed or modified once ACL story is played checkAccess(timelineReaderManager, callerUGI, timelineReaderContext.getUserId()); @@ -1507,7 +1543,8 @@ public TimelineEntity getFlowRun( entities = timelineReaderManager.getEntities( TimelineReaderWebServicesUtils.createTimelineReaderContext( clusterId, null, null, null, null, - TimelineEntityType.YARN_FLOW_ACTIVITY.toString(), null, null), + TimelineEntityType.YARN_FLOW_ACTIVITY.toString(), null, null, + TimelineEntityType.YARN_FLOW_ACTIVITY), entityFilters, TimelineReaderWebServicesUtils. createTimelineDataToRetrieve(null, null, null, null, null, null)); succeeded = true; @@ -1603,6 +1640,7 @@ public TimelineEntity getApp( throw new BadRequestException("Incorrect UID " + uId); } context.setEntityType(TimelineEntityType.YARN_APPLICATION.toString()); + context.setSystemEntityType(TimelineEntityType.YARN_APPLICATION); entity = timelineReaderManager.getEntity(context, TimelineReaderWebServicesUtils.createTimelineDataToRetrieve( confsToRetrieve, metricsToRetrieve, fields, metricsLimit, @@ -1779,7 +1817,8 @@ public TimelineEntity getApp( entity = timelineReaderManager.getEntity( TimelineReaderWebServicesUtils.createTimelineReaderContext( clusterId, userId, flowName, flowRunId, appId, - TimelineEntityType.YARN_APPLICATION.toString(), null, null), + TimelineEntityType.YARN_APPLICATION.toString(), null, null, + TimelineEntityType.YARN_APPLICATION), TimelineReaderWebServicesUtils.createTimelineDataToRetrieve( confsToRetrieve, metricsToRetrieve, fields, metricsLimit, metricsTimeStart, metricsTimeEnd)); @@ -1922,6 +1961,7 @@ public TimelineEntity getApp( // TODO to be removed or modified once ACL story is played checkAccess(timelineReaderManager, callerUGI, context.getUserId()); context.setEntityType(TimelineEntityType.YARN_APPLICATION.toString()); + context.setSystemEntityType(TimelineEntityType.YARN_APPLICATION); entities = timelineReaderManager.getEntities(context, TimelineReaderWebServicesUtils.createTimelineEntityFilters( limit, createdTimeStart, createdTimeEnd, relatesTo, isRelatedTo, @@ -2055,7 +2095,8 @@ public TimelineEntity getApp( flowRunId, limit, createdTimeStart, createdTimeEnd, relatesTo, isRelatedTo, infofilters, conffilters, metricfilters, eventfilters, confsToRetrieve, metricsToRetrieve, fields, metricsLimit, - metricsTimeStart, metricsTimeEnd, fromId); + metricsTimeStart, metricsTimeEnd, fromId, + TimelineEntityType.YARN_APPLICATION); } /** @@ -2169,7 +2210,8 @@ public TimelineEntity getApp( flowRunId, limit, createdTimeStart, createdTimeEnd, relatesTo, isRelatedTo, infofilters, conffilters, metricfilters, eventfilters, confsToRetrieve, metricsToRetrieve, fields, metricsLimit, - metricsTimeStart, metricsTimeEnd, fromId); + metricsTimeStart, metricsTimeEnd, fromId, + TimelineEntityType.YARN_APPLICATION); } /** @@ -2277,7 +2319,8 @@ public TimelineEntity getApp( null, limit, createdTimeStart, createdTimeEnd, relatesTo, isRelatedTo, infofilters, conffilters, metricfilters, eventfilters, confsToRetrieve, metricsToRetrieve, fields, metricsLimit, - metricsTimeStart, metricsTimeEnd, fromId); + metricsTimeStart, metricsTimeEnd, fromId, + TimelineEntityType.YARN_APPLICATION); } /** @@ -2387,7 +2430,8 @@ public TimelineEntity getApp( null, limit, createdTimeStart, createdTimeEnd, relatesTo, isRelatedTo, infofilters, conffilters, metricfilters, eventfilters, confsToRetrieve, metricsToRetrieve, fields, metricsLimit, - metricsTimeStart, metricsTimeEnd, fromId); + metricsTimeStart, metricsTimeEnd, fromId, + TimelineEntityType.YARN_APPLICATION); } /** @@ -2636,7 +2680,7 @@ public TimelineEntity getApp( flowName, flowRunId, limit, createdTimeStart, createdTimeEnd, relatesTo, isRelatedTo, infofilters, conffilters, metricfilters, eventfilters, confsToRetrieve, metricsToRetrieve, fields, metricsLimit, - metricsTimeStart, metricsTimeEnd, fromId); + metricsTimeStart, metricsTimeEnd, fromId, null); } /** @@ -2801,7 +2845,7 @@ public TimelineEntity getAppAttempt(@Context HttpServletRequest req, return getEntity(req, res, clusterId, appId, TimelineEntityType.YARN_APPLICATION_ATTEMPT.toString(), appAttemptId, userId, flowName, flowRunId, confsToRetrieve, metricsToRetrieve, fields, - metricsLimit, metricsTimeStart, metricsTimeEnd, entityIdPrefix); + metricsLimit, metricsTimeStart, metricsTimeEnd, entityIdPrefix, null); } /** @@ -3068,7 +3112,7 @@ public TimelineEntity getAppAttempt(@Context HttpServletRequest req, flowRunId, limit, createdTimeStart, createdTimeEnd, relatesTo, isRelatedTo, infofilter, conffilters, metricfilters, eventfilters, confsToRetrieve, metricsToRetrieve, fields, metricsLimit, - metricsTimeStart, metricsTimeEnd, fromId); + metricsTimeStart, metricsTimeEnd, fromId, null); } /** @@ -3232,7 +3276,7 @@ public TimelineEntity getContainer(@Context HttpServletRequest req, return getEntity(req, res, clusterId, appId, TimelineEntityType.YARN_CONTAINER.toString(), containerId, userId, flowName, flowRunId, confsToRetrieve, metricsToRetrieve, fields, - metricsLimit, metricsTimeStart, metricsTimeEnd, entityIdPrefix); + metricsLimit, metricsTimeStart, metricsTimeEnd, entityIdPrefix, null); } /** @@ -3328,7 +3372,7 @@ public TimelineEntity getContainer(@Context HttpServletRequest req, results = timelineReaderManager.getEntityTypes( TimelineReaderWebServicesUtils.createTimelineReaderContext( clusterId, userId, flowName, flowRunId, appId, - null, null, null)); + null, null, null, null)); succeeded = true; } catch (Exception e) { handleException(e, url, startTime, "flowrunid"); @@ -3412,7 +3456,7 @@ public TimelineEntity getContainer(@Context HttpServletRequest req, try { TimelineReaderContext context = TimelineReaderWebServicesUtils.createTimelineReaderContext(clusterId, - null, null, null, null, entityType, null, null, userId); + null, null, null, null, entityType, null, null, userId, null); entities = timelineReaderManager.getEntities(context, TimelineReaderWebServicesUtils.createTimelineEntityFilters( limit, createdTimeStart, createdTimeEnd, relatesTo, isRelatedTo, @@ -3488,7 +3532,7 @@ public TimelineEntity getContainer(@Context HttpServletRequest req, try { TimelineReaderContext context = TimelineReaderWebServicesUtils .createTimelineReaderContext(clusterId, null, null, null, null, - entityType, entityIdPrefix, entityId, userId); + entityType, entityIdPrefix, entityId, userId, null); entities = timelineReaderManager.getEntities(context, new TimelineEntityFilters.Builder().build(), TimelineReaderWebServicesUtils.createTimelineDataToRetrieve( @@ -3568,7 +3612,7 @@ private void checkAccessForGenericEntity(TimelineEntity entity, // TODO to be removed or modified once ACL story is played private void checkAccessForGenericEntities(Set entities, - UserGroupInformation callerUGI, String entityType) throws Exception { + UserGroupInformation callerUGI, TimelineEntityType systemEntityType) throws Exception { if (entities != null && entities.size() > 0 && isDisplayEntityPerUserFilterEnabled( getTimelineReaderManager().getConfig())) { @@ -3576,7 +3620,7 @@ private void checkAccessForGenericEntities(Set entities, TimelineEntity entity = entities.iterator().next(); String uid = (String) entity.getInfo().get(TimelineReaderUtils.FROMID_KEY); - if (TimelineEntityType.YARN_APPLICATION.matches(entityType)) { + if (TimelineEntityType.YARN_APPLICATION == systemEntityType) { timelineReaderContext = TimelineFromIdConverter.APPLICATION_FROMID.decodeUID(uid); } else { diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/reader/TimelineReaderWebServicesUtils.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/reader/TimelineReaderWebServicesUtils.java index bea81c7..529e4ba 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/reader/TimelineReaderWebServicesUtils.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/reader/TimelineReaderWebServicesUtils.java @@ -26,6 +26,7 @@ import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; import org.apache.hadoop.security.UserGroupInformation; +import org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntityType; import org.apache.hadoop.yarn.server.timelineservice.reader.filter.TimelineFilterList; import org.apache.hadoop.yarn.server.timelineservice.storage.TimelineReader.Field; @@ -47,24 +48,31 @@ private TimelineReaderWebServicesUtils() { * @param appId App Id. * @param entityType Entity Type. * @param entityId Entity Id. + * @param systemEntityType System TimelineEntityType. * @return a {@link TimelineReaderContext} object. */ static TimelineReaderContext createTimelineReaderContext(String clusterId, String userId, String flowName, String flowRunId, String appId, - String entityType, String entityIdPrefix, String entityId) { - return new TimelineReaderContext(parseStr(clusterId), parseStr(userId), - parseStr(flowName), parseLongStr(flowRunId), parseStr(appId), - parseStr(entityType), parseLongStr(entityIdPrefix), parseStr(entityId)); + String entityType, String entityIdPrefix, String entityId, + TimelineEntityType systemEntityType) { + TimelineReaderContext context = new TimelineReaderContext( + parseStr(clusterId), parseStr(userId), parseStr(flowName), + parseLongStr(flowRunId), parseStr(appId), parseStr(entityType), + parseLongStr(entityIdPrefix), parseStr(entityId)); + context.setSystemEntityType(systemEntityType); + return context; } static TimelineReaderContext createTimelineReaderContext(String clusterId, String userId, String flowName, String flowRunId, String appId, String entityType, String entityIdPrefix, String entityId, - String doAsUser) { - return new TimelineReaderContext(parseStr(clusterId), parseStr(userId), - parseStr(flowName), parseLongStr(flowRunId), parseStr(appId), - parseStr(entityType), parseLongStr(entityIdPrefix), parseStr(entityId), - parseStr(doAsUser)); + String doAsUser, TimelineEntityType systemEntityType) { + TimelineReaderContext context = new TimelineReaderContext( + parseStr(clusterId), parseStr(userId), parseStr(flowName), + parseLongStr(flowRunId), parseStr(appId), parseStr(entityType), + parseLongStr(entityIdPrefix), parseStr(entityId), parseStr(doAsUser)); + context.setSystemEntityType(systemEntityType); + return context; } /** -- 2.7.4 (Apple Git-66)