Repository: incubator-ranger
Updated Branches:
  refs/heads/master d9a661cfe -> cd2e73030


RANGER-1125: Ranger tagsync updated to process only entities in ACTIVE state

Signed-off-by: Madhan Neethiraj <[email protected]>


Project: http://git-wip-us.apache.org/repos/asf/incubator-ranger/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ranger/commit/cd2e7303
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ranger/tree/cd2e7303
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ranger/diff/cd2e7303

Branch: refs/heads/master
Commit: cd2e73030f5749330f1b432dd63d3d8dc6d55cbc
Parents: d9a661c
Author: Abhay Kulkarni <[email protected]>
Authored: Mon Jul 25 17:04:17 2016 -0700
Committer: Madhan Neethiraj <[email protected]>
Committed: Wed Jul 27 07:55:26 2016 -0700

----------------------------------------------------------------------
 .../source/atlas/AtlasEntityWithTraits.java     |  4 +++-
 .../source/atlas/AtlasNotificationMapper.java   | 21 ++++++++++++++++----
 2 files changed, 20 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/cd2e7303/tagsync/src/main/java/org/apache/ranger/tagsync/source/atlas/AtlasEntityWithTraits.java
----------------------------------------------------------------------
diff --git 
a/tagsync/src/main/java/org/apache/ranger/tagsync/source/atlas/AtlasEntityWithTraits.java
 
b/tagsync/src/main/java/org/apache/ranger/tagsync/source/atlas/AtlasEntityWithTraits.java
index e6a4b36..77dee01 100644
--- 
a/tagsync/src/main/java/org/apache/ranger/tagsync/source/atlas/AtlasEntityWithTraits.java
+++ 
b/tagsync/src/main/java/org/apache/ranger/tagsync/source/atlas/AtlasEntityWithTraits.java
@@ -59,7 +59,9 @@ public class AtlasEntityWithTraits {
                sb.append("AtlasEntityWithTraits={ ");
 
                sb.append("Entity-Id: " + entity.getId()._getId()).append(", ")
-                               .append("Entity-Type: " + 
entity.getTypeName()).append(", ");
+                               .append("Entity-Type: " + 
entity.getTypeName()).append(", ")
+                               .append("Entity-Version: " + 
entity.getId().getVersion()).append(", ")
+                               .append("Entity-State: " + 
entity.getId().getStateAsString()).append(", ");
 
                sb.append("Entity-Values={ ");
                try {

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/cd2e7303/tagsync/src/main/java/org/apache/ranger/tagsync/source/atlas/AtlasNotificationMapper.java
----------------------------------------------------------------------
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 793ac28..a6a1b02 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
@@ -23,6 +23,7 @@ import org.apache.atlas.AtlasException;
 import org.apache.atlas.notification.entity.EntityNotification;
 import org.apache.atlas.typesystem.IReferenceableInstance;
 import org.apache.atlas.typesystem.IStruct;
+import org.apache.atlas.typesystem.persistence.Id;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.collections.MapUtils;
 import org.apache.commons.lang.StringUtils;
@@ -84,12 +85,17 @@ public class AtlasNotificationMapper {
                                IReferenceableInstance entity = 
entityNotification.getEntity();
 
                                if (entity != null && 
AtlasResourceMapperUtil.isEntityTypeHandled(entity.getTypeName())) {
-                                       AtlasEntityWithTraits entityWithTraits 
= new AtlasEntityWithTraits(entityNotification.getEntity(), 
entityNotification.getAllTraits());
+                                       AtlasEntityWithTraits entityWithTraits 
= new AtlasEntityWithTraits(entity, entityNotification.getAllTraits());
                                        if 
(entityNotification.getOperationType() == 
EntityNotification.OperationType.ENTITY_DELETE) {
-                                               // Special case for 
ENTITY_DELETE notifications
                                                ret = 
buildServiceTagsForEntityDeleteNotification(entityWithTraits);
                                        } else {
-                                               ret = 
buildServiceTags(entityWithTraits, null);
+                                               if (entity.getId().getState() 
== Id.EntityState.ACTIVE) {
+                                                       ret = 
buildServiceTags(entityWithTraits, null);
+                                               } else {
+                                                       if 
(LOG.isDebugEnabled()) {
+                                                               
LOG.debug("Ignoring entityNotification for entity that is not ACTIVE: " + 
entityWithTraits);
+                                                       }
+                                               }
                                        }
                                } else {
                                        
logUnhandledEntityNotification(entityNotification);
@@ -169,7 +175,14 @@ public class AtlasNotificationMapper {
                Map<String, ServiceTags> ret = new HashMap<String, 
ServiceTags>();
 
                for (AtlasEntityWithTraits element : entitiesWithTraits) {
-                       buildServiceTags(element, ret);
+                       IReferenceableInstance entity = element.getEntity();
+                       if (entity != null && entity.getId().getState() == 
Id.EntityState.ACTIVE) {
+                               buildServiceTags(element, ret);
+                       } else {
+                               if (LOG.isDebugEnabled()) {
+                                       LOG.debug("Ignoring entity because its 
State is not ACTIVE: " + element);
+                               }
+                       }
                }
 
                // Remove duplicate tag definitions

Reply via email to