YARN-2818. Removed the now unnecessary user entity injection from Timeline service given we now have domains. Contributed by Zhijie Shen.

(cherry picked from commit f5b19bed7d)
This commit is contained in:
Vinod Kumar Vavilapalli 2014-11-06 11:48:40 -08:00
parent c0bbb72912
commit 0f9199fb07
3 changed files with 5 additions and 75 deletions

View File

@ -399,6 +399,9 @@ Release 2.6.0 - UNRELEASED
YARN-2770. Added functionality to renew/cancel TimeLineDelegationToken. YARN-2770. Added functionality to renew/cancel TimeLineDelegationToken.
(Zhijie Shen via jianhe) (Zhijie Shen via jianhe)
YARN-2818. Removed the now unnecessary user entity injection from Timeline
service given we now have domains. (Zhijie Shen via vinodkv)
OPTIMIZATIONS OPTIMIZATIONS
BUG FIXES BUG FIXES

View File

@ -109,7 +109,6 @@ public TimelineEntities getEntities(
EnumSet<Field> fields, EnumSet<Field> fields,
UserGroupInformation callerUGI) throws YarnException, IOException { UserGroupInformation callerUGI) throws YarnException, IOException {
TimelineEntities entities = null; TimelineEntities entities = null;
boolean modified = extendFields(fields);
entities = store.getEntities( entities = store.getEntities(
entityType, entityType,
limit, limit,
@ -130,13 +129,6 @@ public TimelineEntities getEntities(
if (!timelineACLsManager.checkAccess( if (!timelineACLsManager.checkAccess(
callerUGI, ApplicationAccessType.VIEW_APP, entity)) { callerUGI, ApplicationAccessType.VIEW_APP, entity)) {
entitiesItr.remove(); entitiesItr.remove();
} else {
// clean up system data
if (modified) {
entity.setPrimaryFilters(null);
} else {
cleanupOwnerInfo(entity);
}
} }
} catch (YarnException e) { } catch (YarnException e) {
LOG.error("Error when verifying access for user " + callerUGI LOG.error("Error when verifying access for user " + callerUGI
@ -166,7 +158,6 @@ public TimelineEntity getEntity(
EnumSet<Field> fields, EnumSet<Field> fields,
UserGroupInformation callerUGI) throws YarnException, IOException { UserGroupInformation callerUGI) throws YarnException, IOException {
TimelineEntity entity = null; TimelineEntity entity = null;
boolean modified = extendFields(fields);
entity = entity =
store.getEntity(entityId, entityType, fields); store.getEntity(entityId, entityType, fields);
if (entity != null) { if (entity != null) {
@ -174,13 +165,6 @@ public TimelineEntity getEntity(
if (!timelineACLsManager.checkAccess( if (!timelineACLsManager.checkAccess(
callerUGI, ApplicationAccessType.VIEW_APP, entity)) { callerUGI, ApplicationAccessType.VIEW_APP, entity)) {
entity = null; entity = null;
} else {
// clean up the system data
if (modified) {
entity.setPrimaryFilters(null);
} else {
cleanupOwnerInfo(entity);
}
} }
} }
return entity; return entity;
@ -283,8 +267,7 @@ public TimelinePutResponse postEntities(
} }
} catch (Exception e) { } catch (Exception e) {
// Skip the entity which already exists and was put by others // Skip the entity which already exists and was put by others
LOG.error("Skip the timeline entity: " + entityID + ", because " LOG.error("Skip the timeline entity: " + entityID, e);
+ e.getMessage());
TimelinePutResponse.TimelinePutError error = TimelinePutResponse.TimelinePutError error =
new TimelinePutResponse.TimelinePutError(); new TimelinePutResponse.TimelinePutError();
error.setEntityId(entityID.getId()); error.setEntityId(entityID.getId());
@ -295,28 +278,6 @@ public TimelinePutResponse postEntities(
continue; continue;
} }
// inject owner information for the access check if this is the first
// time to post the entity, in case it's the admin who is updating
// the timeline data.
try {
if (existingEntity == null) {
injectOwnerInfo(entity, callerUGI.getShortUserName());
}
} catch (YarnException e) {
// Skip the entity which messes up the primary filter and record the
// error
LOG.error("Skip the timeline entity: " + entityID + ", because "
+ e.getMessage());
TimelinePutResponse.TimelinePutError error =
new TimelinePutResponse.TimelinePutError();
error.setEntityId(entityID.getId());
error.setEntityType(entityID.getType());
error.setErrorCode(
TimelinePutResponse.TimelinePutError.SYSTEM_FILTER_CONFLICT);
errors.add(error);
continue;
}
entityIDs.add(entityID); entityIDs.add(entityID);
entitiesToPut.addEntity(entity); entitiesToPut.addEntity(entity);
if (LOG.isDebugEnabled()) { if (LOG.isDebugEnabled()) {
@ -394,34 +355,4 @@ public TimelineDomains getDomains(String owner,
} }
} }
private static boolean extendFields(EnumSet<Field> fieldEnums) {
boolean modified = false;
if (fieldEnums != null && !fieldEnums.contains(Field.PRIMARY_FILTERS)) {
fieldEnums.add(Field.PRIMARY_FILTERS);
modified = true;
}
return modified;
}
private static void injectOwnerInfo(TimelineEntity timelineEntity,
String owner) throws YarnException {
if (timelineEntity.getPrimaryFilters() != null &&
timelineEntity.getPrimaryFilters().containsKey(
TimelineStore.SystemFilter.ENTITY_OWNER.toString())) {
throw new YarnException(
"User should not use the timeline system filter key: "
+ TimelineStore.SystemFilter.ENTITY_OWNER);
}
timelineEntity.addPrimaryFilter(
TimelineStore.SystemFilter.ENTITY_OWNER
.toString(), owner);
}
private static void cleanupOwnerInfo(TimelineEntity timelineEntity) {
if (timelineEntity.getPrimaryFilters() != null) {
timelineEntity.getPrimaryFilters().remove(
TimelineStore.SystemFilter.ENTITY_OWNER.toString());
}
}
} }

View File

@ -443,11 +443,7 @@ public void testPostEntitiesWithPrimaryFilter() throws Exception {
.post(ClientResponse.class, entities); .post(ClientResponse.class, entities);
TimelinePutResponse putResposne = TimelinePutResponse putResposne =
response.getEntity(TimelinePutResponse.class); response.getEntity(TimelinePutResponse.class);
Assert.assertEquals(1, putResposne.getErrors().size()); Assert.assertEquals(0, putResposne.getErrors().size());
List<TimelinePutError> errors = putResposne.getErrors();
Assert.assertEquals(
TimelinePutResponse.TimelinePutError.SYSTEM_FILTER_CONFLICT,
errors.get(0).getErrorCode());
} }
@Test @Test