Commit e841619c by Madhan Neethiraj

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

parent 9ba2ff0d
...@@ -72,32 +72,16 @@ public class AtlasEntityChangeNotifier { ...@@ -72,32 +72,16 @@ public class AtlasEntityChangeNotifier {
List<AtlasEntityHeader> partiallyUpdatedEntities = entityMutationResponse.getPartialUpdatedEntities(); List<AtlasEntityHeader> partiallyUpdatedEntities = entityMutationResponse.getPartialUpdatedEntities();
List<AtlasEntityHeader> deletedEntities = entityMutationResponse.getDeletedEntities(); List<AtlasEntityHeader> deletedEntities = entityMutationResponse.getDeletedEntities();
if (CollectionUtils.isNotEmpty(createdEntities)) { // complete full text mapping before calling toITypedReferenceable(), from notifyListners(), to
List<ITypedReferenceableInstance> typedRefInst = toITypedReferenceable(createdEntities); // include all vertex updates in the current graph-transaction
doFullTextMapping(createdEntities);
doFullTextMapping(createdEntities); doFullTextMapping(updatedEntities);
notifyListeners(typedRefInst, EntityOperation.CREATE); doFullTextMapping(partiallyUpdatedEntities);
}
notifyListeners(createdEntities, EntityOperation.CREATE);
if (CollectionUtils.isNotEmpty(updatedEntities)) { notifyListeners(updatedEntities, EntityOperation.UPDATE);
List<ITypedReferenceableInstance> typedRefInst = toITypedReferenceable(updatedEntities); notifyListeners(partiallyUpdatedEntities, EntityOperation.PARTIAL_UPDATE);
notifyListeners(deletedEntities, EntityOperation.DELETE);
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);
}
} }
public void onClassificationAddedToEntity(String entityId, List<AtlasClassification> classifications) throws AtlasBaseException { public void onClassificationAddedToEntity(String entityId, List<AtlasClassification> classifications) throws AtlasBaseException {
...@@ -133,7 +117,13 @@ public class AtlasEntityChangeNotifier { ...@@ -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) { for (EntityChangeListener listener : entityChangeListeners) {
try { try {
switch (operation) { switch (operation) {
...@@ -191,6 +181,10 @@ public class AtlasEntityChangeNotifier { ...@@ -191,6 +181,10 @@ public class AtlasEntityChangeNotifier {
} }
private void doFullTextMapping(List<AtlasEntityHeader> atlasEntityHeaders) { private void doFullTextMapping(List<AtlasEntityHeader> atlasEntityHeaders) {
if (CollectionUtils.isEmpty(atlasEntityHeaders)) {
return;
}
try { try {
if(!AtlasRepositoryConfiguration.isFullTextSearchEnabled()) { if(!AtlasRepositoryConfiguration.isFullTextSearchEnabled()) {
return; return;
......
...@@ -20,7 +20,6 @@ package org.apache.atlas.repository.store.graph.v1; ...@@ -20,7 +20,6 @@ package org.apache.atlas.repository.store.graph.v1;
import com.sun.istack.Nullable; import com.sun.istack.Nullable;
import org.apache.atlas.AtlasClient; import org.apache.atlas.AtlasClient;
import org.apache.atlas.AtlasErrorCode; import org.apache.atlas.AtlasErrorCode;
import org.apache.atlas.AtlasException;
import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.instance.AtlasClassification; import org.apache.atlas.model.instance.AtlasClassification;
import org.apache.atlas.model.instance.AtlasEntity; import org.apache.atlas.model.instance.AtlasEntity;
...@@ -127,29 +126,36 @@ public final class EntityGraphRetriever { ...@@ -127,29 +126,36 @@ public final class EntityGraphRetriever {
} }
private AtlasVertex getEntityVertex(String guid) throws AtlasBaseException { private AtlasVertex getEntityVertex(String guid) throws AtlasBaseException {
try { AtlasVertex ret = AtlasGraphUtilsV1.findByGuid(guid);
return graphHelper.getVertexForGUID(guid);
} catch (AtlasException excp) { if (ret == null) {
throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, guid); throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, guid);
} }
return ret;
} }
private AtlasVertex getEntityVertex(AtlasObjectId objId) throws AtlasBaseException { private AtlasVertex getEntityVertex(AtlasObjectId objId) throws AtlasBaseException {
try { AtlasVertex ret = null;
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();
return AtlasGraphUtilsV1.getVertexByUniqueAttributes(entityType, uniqAttributes); if (! AtlasTypeUtil.isValid(objId)) {
} throw new AtlasBaseException(AtlasErrorCode.INVALID_OBJECT_ID, objId.toString());
} catch (AtlasException excp) { }
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()); throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, objId.toString());
} }
return ret;
} }
private AtlasEntity mapVertexToAtlasEntity(AtlasVertex entityVertex, AtlasEntityExtInfo entityExtInfo) throws AtlasBaseException { private AtlasEntity mapVertexToAtlasEntity(AtlasVertex entityVertex, AtlasEntityExtInfo entityExtInfo) throws AtlasBaseException {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment