Commit 53e88250 by Saqeeb Shaikh Committed by Sarath Subramanian

ATLAS-3360: Duplicate audits in atlas when HMS and hive hook is enabled #2 - Add…

ATLAS-3360: Duplicate audits in atlas when HMS and hive hook is enabled #2 - Add entitiesToSkipUpdate in RequestContext Signed-off-by: 's avatarSarath Subramanian <sarath@apache.org>
parent 91134031
...@@ -838,17 +838,13 @@ public class AtlasEntityStoreV2 implements AtlasEntityStore { ...@@ -838,17 +838,13 @@ public class AtlasEntityStoreV2 implements AtlasEntityStore {
} }
entitiesToSkipUpdate.add(entity); entitiesToSkipUpdate.add(entity);
RequestContext.get().recordEntityToSkip(entity.getGuid());
} }
} }
if (entitiesToSkipUpdate != null) { if (entitiesToSkipUpdate != null) {
// remove entitiesToSkipUpdate from EntityMutationContext // remove entitiesToSkipUpdate from EntityMutationContext
context.getUpdatedEntities().removeAll(entitiesToSkipUpdate); context.getUpdatedEntities().removeAll(entitiesToSkipUpdate);
// remove entitiesToSkipUpdate from RequestContext
for (AtlasEntity entity : entitiesToSkipUpdate) {
RequestContext.get().removeEntityUpdate(entity);
}
} }
// Check if authorized to update entities // Check if authorized to update entities
......
...@@ -54,6 +54,7 @@ public class RequestContext { ...@@ -54,6 +54,7 @@ public class RequestContext {
private final Map<String, List<AtlasClassification>> removedPropagations = new HashMap<>(); private final Map<String, List<AtlasClassification>> removedPropagations = new HashMap<>();
private final AtlasPerfMetrics metrics = isMetricsEnabled ? new AtlasPerfMetrics() : null; private final AtlasPerfMetrics metrics = isMetricsEnabled ? new AtlasPerfMetrics() : null;
private List<EntityGuidPair> entityGuidInRequest = null; private List<EntityGuidPair> entityGuidInRequest = null;
private final Set<String> entitiesToSkipUpdate = new HashSet<>();
private String user; private String user;
private Set<String> userGroups; private Set<String> userGroups;
...@@ -108,6 +109,7 @@ public class RequestContext { ...@@ -108,6 +109,7 @@ public class RequestContext {
this.entityExtInfoCache.clear(); this.entityExtInfoCache.clear();
this.addedPropagations.clear(); this.addedPropagations.clear();
this.removedPropagations.clear(); this.removedPropagations.clear();
this.entitiesToSkipUpdate.clear();
if (metrics != null && !metrics.isEmpty()) { if (metrics != null && !metrics.isEmpty()) {
METRICS.debug(metrics.toString()); METRICS.debug(metrics.toString());
...@@ -199,17 +201,18 @@ public class RequestContext { ...@@ -199,17 +201,18 @@ public class RequestContext {
} }
public void recordEntityUpdate(AtlasEntityHeader entity) { public void recordEntityUpdate(AtlasEntityHeader entity) {
if (entity != null && entity.getGuid() != null) { if (entity != null && entity.getGuid() != null && ! entitiesToSkipUpdate.contains(entity.getGuid())) {
updatedEntities.put(entity.getGuid(), entity); updatedEntities.put(entity.getGuid(), entity);
} }
} }
public void removeEntityUpdate(AtlasEntity entity) { public void recordEntityToSkip(String guid) {
if (entity != null && entity.getGuid() != null) { if(! StringUtils.isEmpty(guid)) {
updatedEntities.remove(entity.getGuid()); entitiesToSkipUpdate.add(guid);
} }
} }
public void recordEntityDelete(AtlasEntityHeader entity) { public void recordEntityDelete(AtlasEntityHeader entity) {
if (entity != null && entity.getGuid() != null) { if (entity != null && entity.getGuid() != null) {
deletedEntities.put(entity.getGuid(), entity); deletedEntities.put(entity.getGuid(), entity);
......
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