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

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


The following commit(s) were added to refs/heads/branch-1.0 by this push:
     new e322dfc  ATLAS-3053: updated notification processing to propagate 
classifications only when specified
e322dfc is described below

commit e322dfca4bcfbc5688f554537e50ced7572cf535
Author: Madhan Neethiraj <mad...@apache.org>
AuthorDate: Wed Feb 13 16:05:38 2019 -0800

    ATLAS-3053: updated notification processing to propagate classifications 
only when specified
    
    (cherry picked from commit fe1c299ce4387138ec82b0824415949daa93fa6f)
---
 .../atlas/repository/store/graph/v2/EntityGraphMapper.java     |  8 +++++++-
 server-api/src/main/java/org/apache/atlas/RequestContext.java  | 10 ++++++++++
 .../apache/atlas/notification/NotificationHookConsumer.java    |  1 +
 3 files changed, 18 insertions(+), 1 deletion(-)

diff --git 
a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java
 
b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java
index a260154..173fe02 100644
--- 
a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java
+++ 
b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java
@@ -1379,6 +1379,8 @@ public class EntityGraphMapper {
 
     public void addClassifications(final EntityMutationContext context, String 
guid, List<AtlasClassification> classifications) throws AtlasBaseException {
         if (CollectionUtils.isNotEmpty(classifications)) {
+            MetricRecorder metric = 
RequestContext.get().startMetricRecord("addClassifications");
+
             final AtlasVertex                           entityVertex          
= context.getVertex(guid);
             final AtlasEntityType                       entityType            
= context.getType(guid);
             List<AtlasVertex>                           entitiesToPropagateTo 
= null;
@@ -1398,7 +1400,9 @@ public class EntityGraphMapper {
                 }
 
                 if (propagateTags == null) {
-                    if(RequestContext.get().isImportInProgress()) {
+                    RequestContext reqContext = RequestContext.get();
+
+                    if(reqContext.isImportInProgress() || 
reqContext.isInNotificationProcessing()) {
                         propagateTags = false;
                         classification.setPropagate(propagateTags);
                     } else {
@@ -1497,6 +1501,8 @@ public class EntityGraphMapper {
                     entityChangeNotifier.onClassificationAddedToEntity(entity, 
addedClassifications);
                 }
             }
+
+            RequestContext.get().endMetricRecord(metric);
         }
     }
 
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 f127424..18a1b7b 100644
--- a/server-api/src/main/java/org/apache/atlas/RequestContext.java
+++ b/server-api/src/main/java/org/apache/atlas/RequestContext.java
@@ -55,6 +55,7 @@ public class RequestContext {
     private int         maxAttempts  = 1;
     private int         attemptCount = 1;
     private boolean     isImportInProgress = false;
+    private boolean     isInNotificationProcessing = false;
 
 
     private RequestContext() {
@@ -164,6 +165,15 @@ public class RequestContext {
         isImportInProgress = importInProgress;
     }
 
+    public boolean isInNotificationProcessing() {
+        return isInNotificationProcessing;
+    }
+
+    public void setInNotificationProcessing(boolean inNotificationProcessing) {
+        isInNotificationProcessing = inNotificationProcessing;
+    }
+
+
     public void recordEntityUpdate(AtlasEntityHeader entity) {
         if (entity != null && entity.getGuid() != null) {
             updatedEntities.put(entity.getGuid(), entity);
diff --git 
a/webapp/src/main/java/org/apache/atlas/notification/NotificationHookConsumer.java
 
b/webapp/src/main/java/org/apache/atlas/notification/NotificationHookConsumer.java
index 1c3b105..2569905 100644
--- 
a/webapp/src/main/java/org/apache/atlas/notification/NotificationHookConsumer.java
+++ 
b/webapp/src/main/java/org/apache/atlas/notification/NotificationHookConsumer.java
@@ -476,6 +476,7 @@ public class NotificationHookConsumer implements Service, 
ActiveStateChangeHandl
                         requestContext.setMaxAttempts(maxRetries);
 
                         requestContext.setUser(messageUser, null);
+                        requestContext.setInNotificationProcessing(true);
 
                         switch (message.getType()) {
                             case ENTITY_CREATE: {

Reply via email to