Skip to content

Commit

Permalink
Rebased and applied changes from @v1r3n
Browse files Browse the repository at this point in the history
  • Loading branch information
rq-dbrady committed Jul 23, 2024
1 parent 4976cc6 commit 0c37dca
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,6 @@ void restart(String workflowId, boolean useLatestDefinitions)
*/
WorkflowModel decide(String workflowId);

/**
* @param workflow workflow to be evaluated
* @return updated workflow
*/
WorkflowModel decideWithLock(WorkflowModel workflow);

/**
* @param workflowId id of the workflow to be terminated
* @param reason termination reason to be recorded
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1039,33 +1039,6 @@ public WorkflowModel decide(String workflowId) {
}
}

/**
* This method overloads the {@link #decide(String)}. It will acquire a lock and evaluate the
* state of the workflow.
*
* @param workflow the workflow to evaluate the state for
* @return the workflow
*/
@Override
public WorkflowModel decideWithLock(WorkflowModel workflow) {
if (workflow == null) {
return null;
}
StopWatch watch = new StopWatch();
watch.start();
if (!executionLockService.acquireLock(workflow.getWorkflowId())) {
return null;
}
try {
return decide(workflow);

} finally {
executionLockService.releaseLock(workflow.getWorkflowId());
watch.stop();
Monitors.recordWorkflowDecisionTime(watch.getTime());
}
}

/**
* @param workflow the workflow to evaluate the state for
* @return true if the workflow has completed (success or failed), false otherwise. Note: This
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public void sweep(String workflowId) {
workflowRepairService.verifyAndRepairWorkflowTasks(workflow);
}
long decideStartTime = System.currentTimeMillis();
workflow = workflowExecutor.decide(workflow);
workflow = workflowExecutor.decide(workflow.getWorkflowId());
Monitors.recordWorkflowDecisionTime(System.currentTimeMillis() - decideStartTime);
if (workflow != null && workflow.getStatus().isTerminal()) {
queueDAO.remove(DECIDER_QUEUE, workflowId);
Expand Down

0 comments on commit 0c37dca

Please sign in to comment.