if (workflow.getStatus().equals(WorkflowStatus.PAUSED)) { LOGGER.debug("Workflow " + workflow.getWorkflowId() + " is paused"); return outcome; if (workflow.getStatus().isTerminal()) {
/** * @param workflowId * @throws IllegalStateException */ public void resumeWorkflow(String workflowId) { Workflow workflow = executionDAOFacade.getWorkflowById(workflowId, false); if (!workflow.getStatus().equals(WorkflowStatus.PAUSED)) { throw new IllegalStateException("The workflow " + workflowId + " is not PAUSED so cannot resume. " + "Current status is " + workflow.getStatus().name()); } workflow.setStatus(WorkflowStatus.RUNNING); executionDAOFacade.updateWorkflow(workflow); decide(workflowId); }
@Override public boolean execute(Workflow workflow, Task task, WorkflowExecutor provider) { String workflowId = (String) task.getOutputData().get(SUB_WORKFLOW_ID); if (workflowId == null) { workflowId = (String) task.getInputData().get(SUB_WORKFLOW_ID); //Backward compatibility } if(StringUtils.isEmpty(workflowId)) { return false; } Workflow subWorkflow = provider.getWorkflow(workflowId, false); WorkflowStatus subWorkflowStatus = subWorkflow.getStatus(); if(!subWorkflowStatus.isTerminal()){ return false; } task.getOutputData().putAll(subWorkflow.getOutput()); if (subWorkflowStatus.isSuccessful()) { task.setStatus(Status.COMPLETED); } else { task.setReasonForIncompletion(subWorkflow.getReasonForIncompletion()); task.setStatus(Status.FAILED); } return true; }
if (workflowInstance.getStatus().isTerminal()) {
if (workflow.getStatus().equals(WorkflowStatus.PAUSED)) { LOGGER.debug("Workflow " + workflow.getWorkflowId() + " is paused"); return outcome; if (workflow.getStatus().isTerminal()) {
if (!workflow.getStatus().isTerminal()) { workflow.setStatus(WorkflowStatus.TERMINATED); input.put("workflowId", workflowId); input.put("reason", reason); input.put("failureStatus", workflow.getStatus().toString());
if (workflow.getStatus().isTerminal()) { LOGGER.warn("Workflow {} has been completed for {}/{}", workflow.getWorkflowId(), systemTask.getName(), task.getTaskId()); if (!task.getStatus().isTerminal()) {
Workflow workflow = executionDAOFacade.getWorkflowById(wf.getWorkflowId(), false); if (workflow.getStatus().equals(WorkflowStatus.COMPLETED)) { if (workflow.getStatus().isTerminal()) { String msg = "Workflow has already been completed. Current status " + workflow.getStatus(); throw new ApplicationException(CONFLICT, msg);
if (!workflow.getStatus().isTerminal()) { throw new ApplicationException(CONFLICT, "Workflow is still running. status=" + workflow.getStatus()); if (!workflowDef.isRestartable() && workflow.getStatus().equals(WorkflowStatus.COMPLETED)) { // Can only restart non-completed workflows when the configuration is set to false throw new ApplicationException(CONFLICT, String.format("WorkflowId: %s is an instance of WorkflowDef: %s and version: %d and is non restartable", workflowId, workflowDef.getName(), workflowDef.getVersion()));
if (!wf.getStatus().equals(WorkflowStatus.RUNNING)) { String errorMsg = String.format("The workflow %s is not running so the task referenced by %s cannot be skipped", workflowId, taskReferenceName); throw new IllegalStateException(errorMsg);
if (!workflow.getStatus().isTerminal()) { throw new ApplicationException(CONFLICT, "Workflow is still running. status=" + workflow.getStatus());
Preconditions.checkNotNull(workflow, "workflow object cannot be null"); if (workflow.getStatus().isTerminal()) { workflow.setEndTime(System.currentTimeMillis()); if (workflow.getStatus().isTerminal()) { dynoClient.srem(nsKey(PENDING_WORKFLOWS, workflow.getWorkflowName()), workflow.getWorkflowId()); } else {
/** * @param workflowId the id of the workflow for which callbacks are to be reset * @throws ApplicationException if the workflow is in terminal state */ public void resetCallbacksForInProgressTasks(String workflowId) { Workflow workflow = executionDAOFacade.getWorkflowById(workflowId, true); if (workflow.getStatus().isTerminal()) { throw new ApplicationException(CONFLICT, "Workflow is in terminal state. Status =" + workflow.getStatus()); } // Get tasks that are in progress and have callbackAfterSeconds > 0 // and set the callbackAfterSeconds to 0; for (Task task : workflow.getTasks()) { if (task.getStatus().equals(IN_PROGRESS) && task.getCallbackAfterSeconds() > 0) { if (queueDAO.setOffsetTime(QueueUtils.getQueueName(task), task.getTaskId(), 0)) { task.setCallbackAfterSeconds(0); executionDAOFacade.updateTask(task); } } } }
@Override public boolean execute(Workflow workflow, Task task, WorkflowExecutor provider) { String workflowId = (String) task.getOutputData().get(SUB_WORKFLOW_ID); if (workflowId == null) { workflowId = (String) task.getInputData().get(SUB_WORKFLOW_ID); //Backward compatibility } if(StringUtils.isEmpty(workflowId)) { return false; } Workflow subWorkflow = provider.getWorkflow(workflowId, false); WorkflowStatus subWorkflowStatus = subWorkflow.getStatus(); if(!subWorkflowStatus.isTerminal()){ return false; } task.getOutputData().putAll(subWorkflow.getOutput()); if (subWorkflowStatus.isSuccessful()) { task.setStatus(Status.COMPLETED); } else { task.setReasonForIncompletion(subWorkflow.getReasonForIncompletion()); task.setStatus(Status.FAILED); } return true; }
private void terminate(final Workflow workflow, TerminateWorkflowException tw) { if (!workflow.getStatus().isTerminal()) { workflow.setStatus(tw.workflowStatus); } String failureWorkflow = workflow.getWorkflowDefinition().getFailureWorkflow(); if (failureWorkflow != null) { if (failureWorkflow.startsWith("$")) { String[] paramPathComponents = failureWorkflow.split("\\."); String name = paramPathComponents[2]; // name of the input parameter failureWorkflow = (String) workflow.getInput().get(name); } } if (tw.task != null) { executionDAOFacade.updateTask(tw.task); } terminateWorkflow(workflow, tw.getMessage(), failureWorkflow); }
/** * @throws ApplicationException */ public void pauseWorkflow(String workflowId) { WorkflowStatus status = WorkflowStatus.PAUSED; Workflow workflow = executionDAOFacade.getWorkflowById(workflowId, false); if (workflow.getStatus().isTerminal()) { throw new ApplicationException(CONFLICT, "Workflow id " + workflowId + " has ended, status cannot be updated."); } if (workflow.getStatus().equals(status)) { return; //Already paused! } workflow.setStatus(status); executionDAOFacade.updateWorkflow(workflow); }
/** * @param workflowId * @throws IllegalStateException */ public void resumeWorkflow(String workflowId) { Workflow workflow = executionDAOFacade.getWorkflowById(workflowId, false); if (!workflow.getStatus().equals(WorkflowStatus.PAUSED)) { throw new IllegalStateException("The workflow " + workflowId + " is not PAUSED so cannot resume. " + "Current status is " + workflow.getStatus().name()); } workflow.setStatus(WorkflowStatus.RUNNING); executionDAOFacade.updateWorkflow(workflow); decide(workflowId); }
public static void recordUpdateConflict(String taskType, String workflowType, WorkflowStatus status) { counter(classQualifier, "task_update_conflict", "workflowName", workflowType, "taskType", taskType, "workflowStatus", status.name()); }
public static void recordWorkflowTermination(String workflowType, WorkflowStatus status, String ownerApp) { counter(classQualifier, "workflow_failure", "workflowName", workflowType, "status", status.name(), "ownerApp", ""+ownerApp); }
public List<Workflow> getWorkflowInstances(String workflowName, String correlationId, boolean includeClosed, boolean includeTasks) { List<Workflow> workflows = executionDAOFacade.getWorkflowsByCorrelationId(correlationId, includeTasks); List<Workflow> result = new LinkedList<>(); for (Workflow wf : workflows) { if (wf.getWorkflowName().equals(workflowName) && (includeClosed || wf.getStatus().equals(Workflow.WorkflowStatus.RUNNING))) { result.add(wf); } } return result; }