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 42a708f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 37 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 @@ -77,22 +77,21 @@ public CompletableFuture<Void> sweepAsync(String workflowId) {
}

public void sweep(String workflowId) {
WorkflowContext workflowContext = new WorkflowContext(properties.getAppId());
WorkflowContext.set(workflowContext);
WorkflowModel workflow = null;
try {
if (!executionLockService.acquireLock(workflowId)) {
return;
}
workflow = executionDAOFacade.getWorkflowModel(workflowId, true);
WorkflowContext workflowContext = new WorkflowContext(properties.getAppId());
WorkflowContext.set(workflowContext);
LOGGER.debug("Running sweeper for workflow {}", workflowId);

if (workflowRepairService != null) {
// Verify and repair tasks in the workflow.
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 42a708f

Please sign in to comment.