Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/loop_performance_improvement'
Browse files Browse the repository at this point in the history
  • Loading branch information
manan164 committed Apr 4, 2023
2 parents 8c65ec1 + 9322716 commit e4e7e0d
Showing 1 changed file with 9 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,35 +68,21 @@ public boolean execute(
if (doWhileTaskModel
.getWorkflowTask()
.has(TaskUtils.removeIterationFromTaskRefName(t.getReferenceTaskName()))
&& !doWhileTaskModel.getReferenceTaskName().equals(t.getReferenceTaskName())
&& doWhileTaskModel.getIteration() == t.getIteration()) {
&& !task.getReferenceTaskName().equals(t.getReferenceTaskName())
&& task.getIteration() == t.getIteration()) {
relevantTask = relevantTasks.get(t.getReferenceTaskName());
if (relevantTask == null || t.getRetryCount() > relevantTask.getRetryCount()) {
relevantTasks.put(t.getReferenceTaskName(), t);
}
}
}
Collection<TaskModel> loopOverTasks = relevantTasks.values();

if (LOGGER.isDebugEnabled()) {
LOGGER.debug(
"Workflow {} waiting for tasks {} to complete iteration {}",
workflow.getWorkflowId(),
loopOverTasks.stream()
.map(TaskModel::getReferenceTaskName)
.collect(Collectors.toList()),
doWhileTaskModel.getIteration());
}

// if the loopOverTasks collection is empty, no tasks inside the loop have been scheduled.
// so schedule it and exit the method.
if (loopOverTasks.isEmpty()) {
doWhileTaskModel.setIteration(1);
doWhileTaskModel.addOutput("iteration", doWhileTaskModel.getIteration());
return scheduleNextIteration(doWhileTaskModel, workflow, workflowExecutor);
}

for (TaskModel loopOverTask : loopOverTasks) {
Collection<TaskModel> loopOver = relevantTasks.values();
LOGGER.debug(
"Workflow {} waiting for tasks {} to complete iteration {}",
workflow.getWorkflowId(),
loopOver.stream().map(TaskModel::getReferenceTaskName).collect(Collectors.toList()),
task.getIteration());
for (TaskModel loopOverTask : loopOver) {
TaskModel.Status taskStatus = loopOverTask.getStatus();
hasFailures = !taskStatus.isSuccessful();
if (hasFailures) {
Expand Down

0 comments on commit e4e7e0d

Please sign in to comment.