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 {
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;
......
......@@ -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 {
......
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