Commit eb22be8c by Madhan Neethiraj

ATLAS-2770: entity-delete fails when Atlas is configured for hard-delete

parent 78cfd718
...@@ -302,7 +302,7 @@ public class AtlasEntityChangeNotifier { ...@@ -302,7 +302,7 @@ public class AtlasEntityChangeNotifier {
} }
private void notifyV2Listeners(List<AtlasEntityHeader> entityHeaders, EntityOperation operation, boolean isImport) throws AtlasBaseException { private void notifyV2Listeners(List<AtlasEntityHeader> entityHeaders, EntityOperation operation, boolean isImport) throws AtlasBaseException {
List<AtlasEntity> entities = toAtlasEntities(entityHeaders); List<AtlasEntity> entities = toAtlasEntities(entityHeaders, operation);
for (EntityChangeListenerV2 listener : entityChangeListenersV2) { for (EntityChangeListenerV2 listener : entityChangeListenersV2) {
switch (operation) { switch (operation) {
...@@ -377,27 +377,42 @@ public class AtlasEntityChangeNotifier { ...@@ -377,27 +377,42 @@ public class AtlasEntityChangeNotifier {
return ret; return ret;
} }
private List<AtlasEntity> toAtlasEntities(List<AtlasEntityHeader> entityHeaders) throws AtlasBaseException { private List<AtlasEntity> toAtlasEntities(List<AtlasEntityHeader> entityHeaders, EntityOperation operation) throws AtlasBaseException {
List<AtlasEntity> ret = new ArrayList<>(); List<AtlasEntity> ret = new ArrayList<>();
if (CollectionUtils.isNotEmpty(entityHeaders)) { if (CollectionUtils.isNotEmpty(entityHeaders)) {
for (AtlasEntityHeader entityHeader : entityHeaders) { for (AtlasEntityHeader entityHeader : entityHeaders) {
String entityGuid = entityHeader.getGuid(); String entityGuid = entityHeader.getGuid();
String typeName = entityHeader.getTypeName(); String typeName = entityHeader.getTypeName();
AtlasEntityType entityType = atlasTypeRegistry.getEntityTypeByName(typeName);
if (entityType == null) {
continue;
}
// Skip all internal types as the HARD DELETE will cause lookup errors // Skip all internal types as the HARD DELETE will cause lookup errors
AtlasEntityType entityType = atlasTypeRegistry.getEntityTypeByName(typeName); if (entityType.isInternalType()) {
if (Objects.nonNull(entityType) && entityType.isInternalType()) {
if (LOG.isDebugEnabled()) { if (LOG.isDebugEnabled()) {
LOG.debug("Skipping internal type = {}", typeName); LOG.debug("Skipping internal type = {}", typeName);
} }
continue; continue;
} }
final AtlasEntity entity;
// delete notifications don't need all attributes. Hence the special handling for delete operation
if (operation == EntityOperation.DELETE) {
entity = new AtlasEntity(typeName, entityHeader.getAttributes());
entity.setGuid(entityGuid);
} else {
AtlasEntityWithExtInfo entityWithExtInfo = instanceConverter.getAndCacheEntity(entityGuid); AtlasEntityWithExtInfo entityWithExtInfo = instanceConverter.getAndCacheEntity(entityGuid);
if (entityWithExtInfo != null) { entity = (entityWithExtInfo != null) ? entityWithExtInfo.getEntity() : null;
ret.add(entityWithExtInfo.getEntity()); }
if (entity != null) {
ret.add(entity);
} }
} }
} }
......
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