Skip to content

Commit

Permalink
minimised impact , fixed PR changes
Browse files Browse the repository at this point in the history
  • Loading branch information
hr2904 committed Oct 9, 2024
1 parent e4542a1 commit 974f3a4
Showing 1 changed file with 28 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4040,8 +4040,7 @@ public void updateClassifications(EntityMutationContext context, String guid, Li
for (String attributeName : updatedAttributes.keySet()) {
currentClassification.setAttribute(attributeName, updatedAttributes.get(attributeName));
}

isClassificationUpdated = true;
createAndQueueTask(CLASSIFICATION_PROPAGATION_TEXT_UPDATE, entityVertex, classificationVertex.getIdForDisplay(), classification.getTypeName());
}

// check for validity period update
Expand All @@ -4050,7 +4049,6 @@ public void updateClassifications(EntityMutationContext context, String guid, Li

if (!Objects.equals(currentValidityPeriods, updatedValidityPeriods)) {
currentClassification.setValidityPeriods(updatedValidityPeriods);

isClassificationUpdated = true;
}

Expand All @@ -4069,8 +4067,10 @@ public void updateClassifications(EntityMutationContext context, String guid, Li
}

if (isClassificationUpdated) {
createAndQueueTask(CLASSIFICATION_PROPAGATION_TEXT_UPDATE, entityVertex, classificationVertex.getIdForDisplay(), classification.getTypeName());
}
List<AtlasVertex> propagatedEntityVertices = graphHelper.getAllPropagatedEntityVertices(classificationVertex);

notificationVertices.addAll(propagatedEntityVertices);
}

if (LOG.isDebugEnabled()) {
LOG.debug("updating vertex {} for trait {}", string(classificationVertex), classificationName);
Expand Down Expand Up @@ -4281,35 +4281,31 @@ public void deleteClassifications(String guid) throws AtlasBaseException {
}
}

public void updateClassificationTextPropagation(String classificationVertexId) {
try {
if (StringUtils.isEmpty(classificationVertexId)) {
LOG.warn("updateClassificationTextPropagation(classificationVertexId={}): classification vertex id is empty", classificationVertexId);
return;
}
AtlasVertex classificationVertex = graph.getVertex(classificationVertexId);
AtlasClassification classification = entityRetriever.toAtlasClassification(classificationVertex);
LOG.info("Fetched classification : {} ", classification.toString());
List<AtlasVertex> impactedVertices = graphHelper.getAllPropagatedEntityVertices(classificationVertex);
LOG.info("impactedVertices : {}", impactedVertices.size());
int batchSize = 100;
for (int i = 0; i < impactedVertices.size(); i += batchSize) {
int end = Math.min(i + batchSize, impactedVertices.size());
List<AtlasVertex> batch = impactedVertices.subList(i, end);
for (AtlasVertex vertex : batch) {
String entityGuid = graphHelper.getGuid(vertex);
AtlasEntity entity = instanceConverter.getAndCacheEntity(entityGuid, ENTITY_CHANGE_NOTIFY_IGNORE_RELATIONSHIP_ATTRIBUTES);

if (entity != null) {
vertex.setProperty(CLASSIFICATION_TEXT_KEY, fullTextMapperV2.getClassificationTextForEntity(entity));
entityChangeNotifier.onClassificationUpdatedToEntity(entity, Collections.singletonList(classification));
}
public void updateClassificationTextPropagation(String classificationVertexId) throws AtlasBaseException {
if (StringUtils.isEmpty(classificationVertexId)) {
LOG.warn("updateClassificationTextPropagation(classificationVertexId={}): classification vertex id is empty", classificationVertexId);
return;
}
AtlasVertex classificationVertex = graph.getVertex(classificationVertexId);
AtlasClassification classification = entityRetriever.toAtlasClassification(classificationVertex);
LOG.info("Fetched classification : {} ", classification.toString());
List<AtlasVertex> impactedVertices = graphHelper.getAllPropagatedEntityVertices(classificationVertex);
LOG.info("impactedVertices : {}", impactedVertices.size());
int batchSize = 100;
for (int i = 0; i < impactedVertices.size(); i += batchSize) {
int end = Math.min(i + batchSize, impactedVertices.size());
List<AtlasVertex> batch = impactedVertices.subList(i, end);
for (AtlasVertex vertex : batch) {
String entityGuid = graphHelper.getGuid(vertex);
AtlasEntity entity = instanceConverter.getAndCacheEntity(entityGuid, true);

if (entity != null) {
vertex.setProperty(CLASSIFICATION_TEXT_KEY, fullTextMapperV2.getClassificationTextForEntity(entity));
entityChangeNotifier.onClassificationUpdatedToEntity(entity, Collections.singletonList(classification));
}
transactionInterceptHelper.intercept();
LOG.info("Updated classificationText from {} for {}", i, batchSize);
}
} catch (Exception e){
e.printStackTrace();
transactionInterceptHelper.intercept();
LOG.info("Updated classificationText from {} for {}", i, batchSize);
}
}

Expand Down

0 comments on commit 974f3a4

Please sign in to comment.