You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by sa...@apache.org on 2019/09/22 05:28:30 UTC
[atlas] branch master updated: ATLAS-3360: Duplicate audits in
atlas when HMS and hive hook is enabled #2 - Add entitiesToSkipUpdate in
RequestContext
This is an automated email from the ASF dual-hosted git repository.
sarath pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/atlas.git
The following commit(s) were added to refs/heads/master by this push:
new 53e8825 ATLAS-3360: Duplicate audits in atlas when HMS and hive hook is enabled #2 - Add entitiesToSkipUpdate in RequestContext
53e8825 is described below
commit 53e8825096394572aa41c9b40a4ccdd2a4e981ea
Author: Saqeeb Shaikh <sa...@freestoneinfotech.com>
AuthorDate: Sat Sep 21 22:26:26 2019 -0700
ATLAS-3360: Duplicate audits in atlas when HMS and hive hook is enabled #2 - Add entitiesToSkipUpdate in RequestContext
Signed-off-by: Sarath Subramanian <sa...@apache.org>
---
.../store/graph/v2/AtlasEntityStoreV2.java | 6 +----
.../main/java/org/apache/atlas/RequestContext.java | 29 ++++++++++++----------
2 files changed, 17 insertions(+), 18 deletions(-)
diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasEntityStoreV2.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasEntityStoreV2.java
index c697026..0d3d82a 100644
--- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasEntityStoreV2.java
+++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasEntityStoreV2.java
@@ -838,17 +838,13 @@ public class AtlasEntityStoreV2 implements AtlasEntityStore {
}
entitiesToSkipUpdate.add(entity);
+ RequestContext.get().recordEntityToSkip(entity.getGuid());
}
}
if (entitiesToSkipUpdate != null) {
// remove entitiesToSkipUpdate from EntityMutationContext
context.getUpdatedEntities().removeAll(entitiesToSkipUpdate);
-
- // remove entitiesToSkipUpdate from RequestContext
- for (AtlasEntity entity : entitiesToSkipUpdate) {
- RequestContext.get().removeEntityUpdate(entity);
- }
}
// Check if authorized to update entities
diff --git a/server-api/src/main/java/org/apache/atlas/RequestContext.java b/server-api/src/main/java/org/apache/atlas/RequestContext.java
index 79eea1c..009a664 100644
--- a/server-api/src/main/java/org/apache/atlas/RequestContext.java
+++ b/server-api/src/main/java/org/apache/atlas/RequestContext.java
@@ -45,15 +45,16 @@ public class RequestContext {
private static final Set<RequestContext> ACTIVE_REQUESTS = new HashSet<>();
private static final boolean isMetricsEnabled = METRICS.isDebugEnabled();
- private final long requestTime = System.currentTimeMillis();
- private final Map<String, AtlasEntityHeader> updatedEntities = new HashMap<>();
- private final Map<String, AtlasEntityHeader> deletedEntities = new HashMap<>();
- private final Map<String, AtlasEntity> entityCache = new HashMap<>();
- private final Map<String, AtlasEntityWithExtInfo> entityExtInfoCache = new HashMap<>();
- private final Map<String, List<AtlasClassification>> addedPropagations = new HashMap<>();
- private final Map<String, List<AtlasClassification>> removedPropagations = new HashMap<>();
- private final AtlasPerfMetrics metrics = isMetricsEnabled ? new AtlasPerfMetrics() : null;
- private List<EntityGuidPair> entityGuidInRequest = null;
+ private final long requestTime = System.currentTimeMillis();
+ private final Map<String, AtlasEntityHeader> updatedEntities = new HashMap<>();
+ private final Map<String, AtlasEntityHeader> deletedEntities = new HashMap<>();
+ private final Map<String, AtlasEntity> entityCache = new HashMap<>();
+ private final Map<String, AtlasEntityWithExtInfo> entityExtInfoCache = new HashMap<>();
+ private final Map<String, List<AtlasClassification>> addedPropagations = new HashMap<>();
+ private final Map<String, List<AtlasClassification>> removedPropagations = new HashMap<>();
+ private final AtlasPerfMetrics metrics = isMetricsEnabled ? new AtlasPerfMetrics() : null;
+ private List<EntityGuidPair> entityGuidInRequest = null;
+ private final Set<String> entitiesToSkipUpdate = new HashSet<>();
private String user;
private Set<String> userGroups;
@@ -108,6 +109,7 @@ public class RequestContext {
this.entityExtInfoCache.clear();
this.addedPropagations.clear();
this.removedPropagations.clear();
+ this.entitiesToSkipUpdate.clear();
if (metrics != null && !metrics.isEmpty()) {
METRICS.debug(metrics.toString());
@@ -199,17 +201,18 @@ public class RequestContext {
}
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);
}
}
- public void removeEntityUpdate(AtlasEntity entity) {
- if (entity != null && entity.getGuid() != null) {
- updatedEntities.remove(entity.getGuid());
+ public void recordEntityToSkip(String guid) {
+ if(! StringUtils.isEmpty(guid)) {
+ entitiesToSkipUpdate.add(guid);
}
}
+
public void recordEntityDelete(AtlasEntityHeader entity) {
if (entity != null && entity.getGuid() != null) {
deletedEntities.put(entity.getGuid(), entity);