Commit 1d2aad52 by Madhan Neethiraj

ATLAS-3297: cache added/update entities in request-context, for use in entity-change listeners

parent 4ce1e370
...@@ -195,7 +195,8 @@ public class EntityGraphMapper { ...@@ -195,7 +195,8 @@ public class EntityGraphMapper {
public EntityMutationResponse mapAttributesAndClassifications(EntityMutationContext context, final boolean isPartialUpdate, final boolean replaceClassifications) throws AtlasBaseException { public EntityMutationResponse mapAttributesAndClassifications(EntityMutationContext context, final boolean isPartialUpdate, final boolean replaceClassifications) throws AtlasBaseException {
MetricRecorder metric = RequestContext.get().startMetricRecord("mapAttributesAndClassifications"); MetricRecorder metric = RequestContext.get().startMetricRecord("mapAttributesAndClassifications");
EntityMutationResponse resp = new EntityMutationResponse(); EntityMutationResponse resp = new EntityMutationResponse();
RequestContext reqContext = RequestContext.get();
Collection<AtlasEntity> createdEntities = context.getCreatedEntities(); Collection<AtlasEntity> createdEntities = context.getCreatedEntities();
Collection<AtlasEntity> updatedEntities = context.getUpdatedEntities(); Collection<AtlasEntity> updatedEntities = context.getUpdatedEntities();
...@@ -212,6 +213,8 @@ public class EntityGraphMapper { ...@@ -212,6 +213,8 @@ public class EntityGraphMapper {
resp.addEntity(CREATE, constructHeader(createdEntity, entityType, vertex)); resp.addEntity(CREATE, constructHeader(createdEntity, entityType, vertex));
addClassifications(context, guid, createdEntity.getClassifications()); addClassifications(context, guid, createdEntity.getClassifications());
reqContext.cache(createdEntity);
} }
} }
...@@ -231,10 +234,12 @@ public class EntityGraphMapper { ...@@ -231,10 +234,12 @@ public class EntityGraphMapper {
resp.addEntity(UPDATE, constructHeader(updatedEntity, entityType, vertex)); resp.addEntity(UPDATE, constructHeader(updatedEntity, entityType, vertex));
} }
if ( replaceClassifications ) { if (replaceClassifications) {
deleteClassifications(guid); deleteClassifications(guid);
addClassifications(context, guid, updatedEntity.getClassifications()); addClassifications(context, guid, updatedEntity.getClassifications());
} }
reqContext.cache(updatedEntity);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment