From 3de46417c70883c21924ea4d88d2270277c744db Mon Sep 17 00:00:00 2001 From: Suman Das <59254445+sumandas0@users.noreply.github.com> Date: Thu, 10 Aug 2023 14:12:55 +0530 Subject: [PATCH 1/2] fix: fix for refresh propagation --- .../repository/store/graph/v2/EntityGraphMapper.java | 2 +- .../repository/store/graph/v2/EntityGraphRetriever.java | 9 +++++++-- .../java/org/apache/atlas/tasks/AtlasTaskService.java | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java index 10a46f78b58..066a49fe70e 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java @@ -3523,7 +3523,7 @@ public void classificationRefreshPropagation(String classificationId) throws Atl LOG.info("{} entity vertices have classification with id {} attached", propagatedVerticesIds.size(), classificationId); List verticesIdsToAddClassification = new ArrayList<>(); - List propagatedVerticesIdWithoutEdge = entityRetriever.getImpactedVerticesIds(sourceEntityVertex , classificationId, + List propagatedVerticesIdWithoutEdge = entityRetriever.getImpactedVerticesIdsClassificationAttached(sourceEntityVertex , classificationId, CLASSIFICATION_PROPAGATION_EXCLUSION_MAP.get(propagationMode), verticesIdsToAddClassification); LOG.info("To add classification with id {} to {} vertices", classificationId, verticesIdsToAddClassification.size()); diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphRetriever.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphRetriever.java index 32773c8272d..abd44de91f6 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphRetriever.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphRetriever.java @@ -616,10 +616,15 @@ public List getImpactedVerticesIds(AtlasVertex entityVertex, String rela return ret; } - public List getImpactedVerticesIds(AtlasVertex entityVertex, String classificationId, List edgeLabelsToExclude, List verticesWithoutClassification) { + public List getImpactedVerticesIdsClassificationAttached(AtlasVertex entityVertex, String classificationId, List edgeLabelsToExclude, List verticesWithoutClassification) { List ret = new ArrayList<>(); - traverseImpactedVerticesByLevel(entityVertex, null, classificationId, ret, edgeLabelsToExclude, verticesWithoutClassification); + GraphHelper.getAllClassificationEdges(entityVertex).forEach(classificationEdge -> { + AtlasVertex classificationVertex = classificationEdge.getInVertex(); + if (classificationVertex != null && classificationId.equals(classificationVertex.getIdForDisplay())) { + traverseImpactedVerticesByLevel(entityVertex, null, classificationId, ret, edgeLabelsToExclude, verticesWithoutClassification); + } + }); return ret; } diff --git a/repository/src/main/java/org/apache/atlas/tasks/AtlasTaskService.java b/repository/src/main/java/org/apache/atlas/tasks/AtlasTaskService.java index 02212ef6394..ba0fe1a4da7 100644 --- a/repository/src/main/java/org/apache/atlas/tasks/AtlasTaskService.java +++ b/repository/src/main/java/org/apache/atlas/tasks/AtlasTaskService.java @@ -151,7 +151,7 @@ public List createAtlasTasks(List tasks) throws AtlasBaseE if (isClassificationTaskType(taskType)) { String classificationName = task.getClassificationName(); String entityGuid = task.getEntityGuid(); - String classificationId = resolveAndReturnClassificationId(classificationName, entityGuid); + String classificationId = StringUtils.isEmpty(task.getClassificationId()) ? resolveAndReturnClassificationId(classificationName, entityGuid) : task.getClassificationId(); if (StringUtils.isEmpty(classificationId)) { throw new AtlasBaseException(AtlasErrorCode.TASK_INVALID_PARAMETERS, task.toString()); } From 90011402a83daa42d91ca46369fd2aca917aae60 Mon Sep 17 00:00:00 2001 From: Suman Das <59254445+sumandas0@users.noreply.github.com> Date: Thu, 10 Aug 2023 18:35:33 +0530 Subject: [PATCH 2/2] fix: only get directly attached edges --- .../atlas/repository/store/graph/v2/EntityGraphRetriever.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphRetriever.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphRetriever.java index abd44de91f6..288764e4241 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphRetriever.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphRetriever.java @@ -619,7 +619,7 @@ public List getImpactedVerticesIds(AtlasVertex entityVertex, String rela public List getImpactedVerticesIdsClassificationAttached(AtlasVertex entityVertex, String classificationId, List edgeLabelsToExclude, List verticesWithoutClassification) { List ret = new ArrayList<>(); - GraphHelper.getAllClassificationEdges(entityVertex).forEach(classificationEdge -> { + GraphHelper.getClassificationEdges(entityVertex).forEach(classificationEdge -> { AtlasVertex classificationVertex = classificationEdge.getInVertex(); if (classificationVertex != null && classificationId.equals(classificationVertex.getIdForDisplay())) { traverseImpactedVerticesByLevel(entityVertex, null, classificationId, ret, edgeLabelsToExclude, verticesWithoutClassification);