Skip to content

Commit

Permalink
add more comments to join routine
Browse files Browse the repository at this point in the history
  • Loading branch information
VerstraeteBert committed Apr 5, 2024
1 parent 00ec92c commit 6347e09
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public Join() {
@SuppressWarnings("unchecked")
public boolean execute(
WorkflowModel workflow, TaskModel task, WorkflowExecutor workflowExecutor) {

StringBuilder failureReason = new StringBuilder();
StringBuilder optionalTaskFailures = new StringBuilder();
List<String> joinOn = (List<String>) task.getInputData().get("joinOn");
Expand All @@ -57,7 +56,7 @@ public boolean execute(
for (String joinOnRef : joinOn) {
TaskModel forkedTask = workflow.getTaskByRefName(joinOnRef);
if (forkedTask == null) {
// Task is not even scheduled yet
// Continue checking other tasks if a referenced task is not yet scheduled
continue;
}

Expand All @@ -68,6 +67,9 @@ public boolean execute(
task.addOutput(joinOnRef, forkedTask.getOutputData());
}

// Determine if the join task fails immediately due to a non-optional, non-permissive
// task failure,
// or waits for all tasks to be terminal if the failed task is permissive.
var isJoinFailure =
!taskStatus.isSuccessful()
&& !forkedTask.getWorkflowTask().isOptional()
Expand Down Expand Up @@ -98,6 +100,7 @@ public boolean execute(
}
}

// Finalize the join task's status based on the outcomes of all referenced tasks.
if (allTasksTerminal) {
if (!optionalTaskFailures.isEmpty()) {
task.setStatus(TaskModel.Status.COMPLETED_WITH_ERRORS);
Expand All @@ -109,6 +112,7 @@ public boolean execute(
return true;
}

// Task execution not complete, waiting on more tasks to reach terminal state.
return false;
}

Expand Down

0 comments on commit 6347e09

Please sign in to comment.