Repository: incubator-atlas
Updated Branches:
  refs/heads/master 9ba2ff0d0 -> e841619c3


ATLAS-1627: fix for missed update to full-text index attribute on entity-update


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

Branch: refs/heads/master
Commit: e841619c384b5358c96b3362ffcb042dededfd40
Parents: 9ba2ff0
Author: Madhan Neethiraj <[email protected]>
Authored: Fri Mar 3 02:00:56 2017 -0800
Committer: Madhan Neethiraj <[email protected]>
Committed: Fri Mar 3 08:49:16 2017 -0800

----------------------------------------------------------------------
 .../graph/v1/AtlasEntityChangeNotifier.java     | 48 +++++++++-----------
 .../store/graph/v1/EntityGraphRetriever.java    | 38 +++++++++-------
 2 files changed, 43 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/e841619c/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityChangeNotifier.java
----------------------------------------------------------------------
diff --git 
a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityChangeNotifier.java
 
b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityChangeNotifier.java
index 5243f36..41674fe 100644
--- 
a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityChangeNotifier.java
+++ 
b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityChangeNotifier.java
@@ -72,32 +72,16 @@ public class AtlasEntityChangeNotifier {
         List<AtlasEntityHeader> partiallyUpdatedEntities = 
entityMutationResponse.getPartialUpdatedEntities();
         List<AtlasEntityHeader> deletedEntities          = 
entityMutationResponse.getDeletedEntities();
 
-        if (CollectionUtils.isNotEmpty(createdEntities)) {
-            List<ITypedReferenceableInstance> typedRefInst = 
toITypedReferenceable(createdEntities);
-
-            doFullTextMapping(createdEntities);
-            notifyListeners(typedRefInst, EntityOperation.CREATE);
-        }
-
-        if (CollectionUtils.isNotEmpty(updatedEntities)) {
-            List<ITypedReferenceableInstance> typedRefInst = 
toITypedReferenceable(updatedEntities);
-
-            doFullTextMapping(updatedEntities);
-            notifyListeners(typedRefInst, EntityOperation.UPDATE);
-        }
-
-        if (CollectionUtils.isNotEmpty(partiallyUpdatedEntities)) {
-            List<ITypedReferenceableInstance> typedRefInst = 
toITypedReferenceable(partiallyUpdatedEntities);
-
-            doFullTextMapping(partiallyUpdatedEntities);
-            notifyListeners(typedRefInst, EntityOperation.PARTIAL_UPDATE);
-        }
-
-        if (CollectionUtils.isNotEmpty(deletedEntities)) {
-            List<ITypedReferenceableInstance> typedRefInst = 
toITypedReferenceable(deletedEntities);
-
-            notifyListeners(typedRefInst, EntityOperation.DELETE);
-        }
+        // complete full text mapping before calling toITypedReferenceable(), 
from notifyListners(), to
+        // include all vertex updates in the current graph-transaction
+        doFullTextMapping(createdEntities);
+        doFullTextMapping(updatedEntities);
+        doFullTextMapping(partiallyUpdatedEntities);
+
+        notifyListeners(createdEntities, EntityOperation.CREATE);
+        notifyListeners(updatedEntities, EntityOperation.UPDATE);
+        notifyListeners(partiallyUpdatedEntities, 
EntityOperation.PARTIAL_UPDATE);
+        notifyListeners(deletedEntities, EntityOperation.DELETE);
     }
 
     public void onClassificationAddedToEntity(String entityId, 
List<AtlasClassification> classifications) throws AtlasBaseException {
@@ -133,7 +117,13 @@ public class AtlasEntityChangeNotifier {
         }
     }
 
-    private void notifyListeners(List<ITypedReferenceableInstance> 
typedRefInsts, EntityOperation operation) throws AtlasBaseException {
+    private void notifyListeners(List<AtlasEntityHeader> entityHeaders, 
EntityOperation operation) throws AtlasBaseException {
+        if (CollectionUtils.isEmpty(entityHeaders)) {
+            return;
+        }
+
+        List<ITypedReferenceableInstance> typedRefInsts = 
toITypedReferenceable(entityHeaders);
+
         for (EntityChangeListener listener : entityChangeListeners) {
             try {
                 switch (operation) {
@@ -191,6 +181,10 @@ public class AtlasEntityChangeNotifier {
     }
 
     private void doFullTextMapping(List<AtlasEntityHeader> atlasEntityHeaders) 
{
+        if (CollectionUtils.isEmpty(atlasEntityHeaders)) {
+            return;
+        }
+
         try {
             if(!AtlasRepositoryConfiguration.isFullTextSearchEnabled()) {
                 return;

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/e841619c/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/EntityGraphRetriever.java
----------------------------------------------------------------------
diff --git 
a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/EntityGraphRetriever.java
 
b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/EntityGraphRetriever.java
index ea5bf93..815c3d2 100644
--- 
a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/EntityGraphRetriever.java
+++ 
b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/EntityGraphRetriever.java
@@ -20,7 +20,6 @@ package org.apache.atlas.repository.store.graph.v1;
 import com.sun.istack.Nullable;
 import org.apache.atlas.AtlasClient;
 import org.apache.atlas.AtlasErrorCode;
-import org.apache.atlas.AtlasException;
 import org.apache.atlas.exception.AtlasBaseException;
 import org.apache.atlas.model.instance.AtlasClassification;
 import org.apache.atlas.model.instance.AtlasEntity;
@@ -127,29 +126,36 @@ public final class EntityGraphRetriever {
     }
 
     private AtlasVertex getEntityVertex(String guid) throws AtlasBaseException 
{
-        try {
-            return graphHelper.getVertexForGUID(guid);
-        } catch (AtlasException excp) {
+        AtlasVertex ret = AtlasGraphUtilsV1.findByGuid(guid);
+
+        if (ret == null) {
             throw new 
AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, guid);
         }
+
+        return ret;
     }
 
     private AtlasVertex getEntityVertex(AtlasObjectId objId) throws 
AtlasBaseException {
-        try {
-            if (! AtlasTypeUtil.isValid(objId)) {
-                throw new AtlasBaseException(AtlasErrorCode.INVALID_OBJECT_ID, 
objId.toString());
-            }
-            if (AtlasTypeUtil.isAssignedGuid(objId)) {
-                return graphHelper.getVertexForGUID(objId.getGuid());
-            } else {
-                AtlasEntityType     entityType     = 
typeRegistry.getEntityTypeByName(objId.getTypeName());
-                Map<String, Object> uniqAttributes = 
objId.getUniqueAttributes();
+        AtlasVertex ret = null;
 
-                return 
AtlasGraphUtilsV1.getVertexByUniqueAttributes(entityType, uniqAttributes);
-            }
-        } catch (AtlasException excp) {
+        if (! AtlasTypeUtil.isValid(objId)) {
+            throw new AtlasBaseException(AtlasErrorCode.INVALID_OBJECT_ID, 
objId.toString());
+        }
+
+        if (AtlasTypeUtil.isAssignedGuid(objId)) {
+            ret = AtlasGraphUtilsV1.findByGuid(objId.getGuid());
+        } else {
+            AtlasEntityType     entityType     = 
typeRegistry.getEntityTypeByName(objId.getTypeName());
+            Map<String, Object> uniqAttributes = objId.getUniqueAttributes();
+
+            ret = AtlasGraphUtilsV1.getVertexByUniqueAttributes(entityType, 
uniqAttributes);
+        }
+
+        if (ret == null) {
             throw new 
AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, objId.toString());
         }
+
+        return ret;
     }
 
     private AtlasEntity mapVertexToAtlasEntity(AtlasVertex entityVertex, 
AtlasEntityExtInfo entityExtInfo) throws AtlasBaseException {

Reply via email to