This is an automated email from the ASF dual-hosted git repository.

sarath pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/atlas.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
     new 61cd5f8  ATLAS-3360: Duplicate audits in atlas when HMS and hive hook 
is enabled #2 - Add entitiesToSkipUpdate in RequestContext
61cd5f8 is described below

commit 61cd5f8c594c4dea68612af0cc82165fec946679
Author: Saqeeb Shaikh <[email protected]>
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 <[email protected]>
    (cherry picked from commit 53e8825096394572aa41c9b40a4ccdd2a4e981ea)
---
 .../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);

Reply via email to