Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DG-1924 | Add 'assetsCountToPropagate' and 'assetsCountPropagated' in task vertex. #4032

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

abhijeet-atlan
Copy link

@abhijeet-atlan abhijeet-atlan commented Jan 27, 2025

DG1924
Design plan ref :Execution Plan - Phase v1 - WIP | 1. Task Vertex
Test cases: DG1924 - TestCase

The task for this ticket:

Add 'assetsCountToPropagate' and 'assetsCountPropagated' params to the task vertex and

update 'assetsCountToPropagate' with a count of the assets count to propagate once the planning phase is finished.
update 'assetsCountPropagated' with a count as the task progresses.

Type of change

  • Bug fix (fixes an issue)
  • New feature (adds functionality)

Related issues

Fix #1

Checklists

Development

  • Lint rules pass locally
  • Application changes have been tested thoroughly
  • Automated tests covering modified code pass

Security

  • Security impact of change has been considered
  • Code follows company security practices and guidelines

Code review

  • Pull request has a descriptive title and context useful to a reviewer. Screenshots or screencasts are attached as necessary
  • "Ready for review" label attached and reviewers assigned
  • Changes have been reviewed by at least one other contributor
  • Pull request linked to task tracker where applicable

jnkrmg
jnkrmg previously approved these changes Jan 28, 2025
Copy link

@jnkrmg jnkrmg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@@ -28,6 +28,8 @@ on:
- master
- lineageondemand
- makerlogic
- taskdg1924deleteprop

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove these

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

RequestContext.get().setCurrentTask(task);

task.setStartTime(new Date());

task.setAssetsCountToPropagate(runnableTask.getAssetsCountToPropagate());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we need to pass runnable task here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the task goes into progress the existing code updates the startTime and a few other details about the task. In the same scenario I needed to update value for assetsCountToPropagate with the number of tasks and for that I need the runnable.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure you have the real number here to set assetsCountToPropagate?
IMO here you will always get it as 0, as per previous code I saw while creating Task vertex we already write value as 0, I feel this is not needed

//update the 'assetsCountToPropagate' in the current task vertex.
AtlasVertex currentTaskVertex = (AtlasVertex) graph.query().has(TASK_GUID, currentTask.getGuid()).vertices().iterator().next();
currentTaskVertex.setProperty(TASK_ASSET_COUNT_TO_PROPAGATE, currentTask.getAssetsCountToPropagate());
graph.commit();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't use graph.commit()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to commit here given we will be committing to the graph just after 2 line

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrote a new function updateTaskVertexProperty that is used everywhere and it doesn't have graph.commit() in it.

//update the 'assetsCountToPropagate' in the current task vertex.
AtlasVertex currentTaskVertex = (AtlasVertex) graph.query().has(TASK_GUID, currentTask.getGuid()).vertices().iterator().next();
currentTaskVertex.setProperty(TASK_ASSET_COUNT_TO_PROPAGATE, currentTask.getAssetsCountToPropagate());
graph.commit();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove graph.commit()

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrote a new function updateTaskVertexProperty that is used everywhere and it doesn't have graph.commit() in it.

@@ -3460,9 +3481,16 @@ public List<String> propagateClassification(String entityGuid, String classifica
Boolean toExclude = propagationMode == CLASSIFICATION_PROPAGATION_MODE_RESTRICT_LINEAGE ? true:false;
List<AtlasVertex> impactedVertices = entityRetriever.getIncludedImpactedVerticesV2(entityVertex, relationshipGuid, classificationVertexId, edgeLabelsToCheck,toExclude);

// update the 'assetsCountToPropagate' on in memory java object.
AtlasTask currentTask = RequestContext.get().getCurrentTask();
currentTask.setAssetsCountToPropagate((long) impactedVertices.size() - 1);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create a method to update the task vertex

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrote a new function updateTaskVertexProperty that is used everywhere and it doesn't have graph.commit() in it.

//update the 'assetsCountToPropagate' in the current task vertex.
AtlasVertex currentTaskVertex = (AtlasVertex) graph.query().has(TASK_GUID, currentTask.getGuid()).vertices().iterator().next();
currentTaskVertex.setProperty(TASK_ASSET_COUNT_TO_PROPAGATE, currentTask.getAssetsCountToPropagate());
graph.commit();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove graph.commit

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrote a new function updateTaskVertexProperty that is used everywhere and it doesn't have graph.commit() in it.

@@ -4351,6 +4416,15 @@ List<String> processClassificationEdgeDeletionInChunk(AtlasClassification classi
int toIndex;
int offset = 0;

// update the 'assetsCountToPropagate' on in memory java object.
AtlasTask currentTask = RequestContext.get().getCurrentTask();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

too much code repetition, create a generic method for updating it

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrote a new function updateTaskVertexProperty that is used everywhere and it doesn't have graph.commit() in it.

@@ -100,9 +101,7 @@ public AtlasTask.Status perform() throws AtlasBaseException {

try {
setStatus(IN_PROGRESS);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: no need for this changes

@@ -361,8 +363,8 @@ public List<AtlasTask> getTasksForReQueueGraphQuery() {
.has(Constants.TASK_TYPE_PROPERTY_KEY, Constants.TASK_TYPE_NAME);

List<AtlasGraphQuery> orConditions = new LinkedList<>();
orConditions.add(query.createChildQuery().has(Constants.TASK_STATUS, AtlasTask.Status.IN_PROGRESS));
orConditions.add(query.createChildQuery().has(Constants.TASK_STATUS, AtlasTask.Status.PENDING));
orConditions.add(query.createChildQuery().has(TASK_STATUS, AtlasTask.Status.IN_PROGRESS));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reason for these changes?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have reverted these back

@@ -28,6 +28,7 @@ on:
- master
- lineageondemand
- makerlogic
- tagpropv1master

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do once all review is complete and we are ready to move to master

Copy link

@sumandas0 sumandas0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly reviews are for code quality

@abhijeet-atlan abhijeet-atlan requested review from sumandas0 and removed request for Madusudanan February 3, 2025 03:45
@abhijeet-atlan
Copy link
Author

removed madu from review because of new team structure

jnkrmg and others added 3 commits February 4, 2025 11:58
…k vertex. The former will be updated with the total count of propagations to be done once the planning phase is complete and the task begins execution. The latter will be updated as the task progresses, reflecting the count of completed propagations at any given point.
@@ -55,6 +61,21 @@ public class TaskManagement implements Service, ActiveStateChangeHandler {
private final RedisService redisService;
private Thread watcherThread = null;

public void updateTaskVertexProperty(String propertyKey, AtlasGraph graph, long value, boolean isIncremental, BiConsumer<AtlasTask, Long> taskSetter) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine, just add few descriptions how we are using BiConsumer, as its bit complicated to understand for reviewer

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

Copy link

@sumandas0 sumandas0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just add proper description, all looks good now otherwise. Will approve

jnkrmg
jnkrmg previously approved these changes Feb 5, 2025
RequestContext.get().setCurrentTask(task);

task.setStartTime(new Date());

task.setAssetsCountToPropagate(runnableTask.getAssetsCountToPropagate());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure you have the real number here to set assetsCountToPropagate?
IMO here you will always get it as 0, as per previous code I saw while creating Task vertex we already write value as 0, I feel this is not needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants