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

abhay pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ranger.git


The following commit(s) were added to refs/heads/master by this push:
     new 79b0c12  RANGER-2630: Ensure that entity deletes are handled even when 
Atlas sets deleted entity's state as not ACTIVE
79b0c12 is described below

commit 79b0c121a607ba8653f7983ed52ddbe986533fd4
Author: Abhay Kulkarni <ab...@apache.org>
AuthorDate: Wed Oct 23 18:06:40 2019 -0700

    RANGER-2630: Ensure that entity deletes are handled even when Atlas sets 
deleted entity's state as not ACTIVE
---
 .../tagsync/source/atlas/AtlasNotificationMapper.java   | 17 ++++++++++-------
 .../tagsync/source/atlas/EntityNotificationWrapper.java |  4 ++--
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git 
a/tagsync/src/main/java/org/apache/ranger/tagsync/source/atlas/AtlasNotificationMapper.java
 
b/tagsync/src/main/java/org/apache/ranger/tagsync/source/atlas/AtlasNotificationMapper.java
index a4cab28..ed4ba17 100644
--- 
a/tagsync/src/main/java/org/apache/ranger/tagsync/source/atlas/AtlasNotificationMapper.java
+++ 
b/tagsync/src/main/java/org/apache/ranger/tagsync/source/atlas/AtlasNotificationMapper.java
@@ -46,8 +46,7 @@ public class AtlasNotificationMapper {
 
     private static void 
logUnhandledEntityNotification(EntityNotificationWrapper entityNotification) {
 
-        boolean skipLogging = entityNotification.getIsEntityCreateOp() && 
entityNotification.getIsEmptyClassifications()
-                || ! entityNotification.getIsEntityActive();
+        boolean skipLogging = entityNotification.getIsEntityCreateOp() && 
entityNotification.getIsEmptyClassifications();
 
         if (!skipLogging) {
             boolean loggingNeeded = false;
@@ -67,13 +66,15 @@ public class AtlasNotificationMapper {
             }
 
             if (loggingNeeded) {
-                LOG.warn("Did not process entity notification for [" + 
entityTypeName + "]");
+                if (!entityNotification.getIsEntityTypeHandled()) {
+                    LOG.warn("Tag-sync is not enabled to handle notifications 
for Entity-type:[" + entityNotification.getEntityTypeName() + "]");
+                }
+                LOG.warn("Dropped process entity notification for Atlas-Entity 
[" + entityNotification.getRangerAtlasEntity() + "]");
             }
 
         }
     }
 
-    @SuppressWarnings("unchecked")
     public static ServiceTags 
processEntityNotification(EntityNotificationWrapper entityNotification) {
 
         ServiceTags ret = null;
@@ -117,7 +118,7 @@ public class AtlasNotificationMapper {
         if (opType != null) {
             switch (opType) {
                 case ENTITY_CREATE:
-                    ret = ! entityNotification.getIsEmptyClassifications();
+                    ret = entityNotification.getIsEntityActive() && 
!entityNotification.getIsEmptyClassifications();
                     if (!ret) {
                         if (LOG.isDebugEnabled()) {
                             LOG.debug("ENTITY_CREATE notification is ignored, 
as there are no traits associated with the entity. Ranger will get necessary 
information from any subsequent TRAIT_ADDED notification");
@@ -125,7 +126,7 @@ public class AtlasNotificationMapper {
                     }
                     break;
                 case ENTITY_UPDATE:
-                    ret = ! entityNotification.getIsEmptyClassifications();
+                    ret = entityNotification.getIsEntityActive() && 
!entityNotification.getIsEmptyClassifications();
                     if (!ret) {
                         if (LOG.isDebugEnabled()) {
                             LOG.debug("ENTITY_UPDATE notification is ignored, 
as there are no traits associated with the entity.");
@@ -133,10 +134,12 @@ public class AtlasNotificationMapper {
                     }
                     break;
                 case ENTITY_DELETE:
+                    ret = true;
+                    break;
                 case CLASSIFICATION_ADD:
                 case CLASSIFICATION_UPDATE:
                 case CLASSIFICATION_DELETE: {
-                    ret = true;
+                    ret = entityNotification.getIsEntityActive();
                     break;
                 }
                 default:
diff --git 
a/tagsync/src/main/java/org/apache/ranger/tagsync/source/atlas/EntityNotificationWrapper.java
 
b/tagsync/src/main/java/org/apache/ranger/tagsync/source/atlas/EntityNotificationWrapper.java
index 9781aa6..c2445fb 100644
--- 
a/tagsync/src/main/java/org/apache/ranger/tagsync/source/atlas/EntityNotificationWrapper.java
+++ 
b/tagsync/src/main/java/org/apache/ranger/tagsync/source/atlas/EntityNotificationWrapper.java
@@ -90,7 +90,7 @@ public class EntityNotificationWrapper {
                 rangerAtlasEntity      = new RangerAtlasEntity(typeName, guid, 
atlasEntity.getAttributes());
                 entityTypeName         = atlasEntity.getTypeName();
                 isEntityActive         = atlasEntity.getStatus() == 
AtlasEntity.Status.ACTIVE;
-                isEntityTypeHandled    = isEntityActive && 
AtlasResourceMapperUtil.isEntityTypeHandled(entityTypeName);
+                isEntityTypeHandled    = 
AtlasResourceMapperUtil.isEntityTypeHandled(entityTypeName);
                 isEntityDeleteOp       = 
EntityNotificationV2.OperationType.ENTITY_DELETE == 
v2Notification.getOperationType();
                 isEntityCreateOp       = 
EntityNotificationV2.OperationType.ENTITY_CREATE == 
v2Notification.getOperationType();
                 isEmptyClassifications = 
CollectionUtils.isEmpty(atlasEntity.getClassifications());
@@ -163,7 +163,7 @@ public class EntityNotificationWrapper {
                 rangerAtlasEntity      = new RangerAtlasEntity(typeName, guid, 
atlasEntity.getValues());
                 entityTypeName         = atlasEntity.getTypeName();
                 isEntityActive         = atlasEntity.getId().getState() == 
Id.EntityState.ACTIVE;
-                isEntityTypeHandled    = isEntityActive && 
AtlasResourceMapperUtil.isEntityTypeHandled(entityTypeName);
+                isEntityTypeHandled    = 
AtlasResourceMapperUtil.isEntityTypeHandled(entityTypeName);
                 isEntityDeleteOp       = 
EntityNotificationV1.OperationType.ENTITY_DELETE == 
v1Notification.getOperationType();
                 isEntityCreateOp       = 
EntityNotificationV1.OperationType.ENTITY_CREATE == 
v1Notification.getOperationType();
                 isEmptyClassifications = 
CollectionUtils.isEmpty(v1Notification.getAllTraits());

Reply via email to