/** * Terminate workflow execution. * @param workflowId WorkflowId of the workflow. * @param reason Reason for terminating the workflow. */ @Service public void terminateWorkflow(String workflowId, String reason) { workflowExecutor.terminateWorkflow(workflowId, reason); }
public void terminateWorkflow(String workflowId, String reason) { Workflow workflow = executionDAOFacade.getWorkflowById(workflowId, true); workflow.setStatus(WorkflowStatus.TERMINATED); terminateWorkflow(workflow, reason, null); }
/** * Terminate workflows execution. * @param workflowIds - list of workflow Ids to perform terminate operation on * @param reason - description to be specified for the terminated workflow for future references. * @return bulk response object containing a list of succeeded workflows and a list of failed ones with errors */ @Service public BulkResponse terminate(List<String> workflowIds, String reason) { BulkResponse bulkResponse = new BulkResponse(); for (String workflowId : workflowIds) { workflowExecutor.terminateWorkflow(workflowId, reason); try { workflowExecutor.terminateWorkflow(workflowId, reason); bulkResponse.appendSuccessResponse(workflowId); } catch (Exception e) { LOGGER.error("bulk terminate exception, workflowId {}, message: {} ",workflowId, e.getMessage(), e); bulkResponse.appendFailedResponse(workflowId, e.getMessage()); } } return bulkResponse; } }
@Override public void cancel(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; } Workflow subWorkflow = provider.getWorkflow(workflowId, false); subWorkflow.setStatus(WorkflowStatus.TERMINATED); provider.terminateWorkflow(subWorkflow, "Parent workflow has been terminated with status " + workflow.getStatus(), null); }
@Test public void testTerminateWorkflow() { workflowService.terminateWorkflow("w123", "test"); verify(mockWorkflowExecutor, times(1)).terminateWorkflow(anyString(), anyString()); }
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); }
@After public void clearWorkflows() { List<String> workflows = metadataService.getWorkflowDefs().stream() .map(WorkflowDef::getName) .collect(Collectors.toList()); for (String wfName : workflows) { List<String> running = workflowExecutionService.getRunningWorkflows(wfName); for (String wfid : running) { workflowExecutor.terminateWorkflow(wfid, "cleanup"); } } queueDAO.queuesDetail().keySet().forEach(queueDAO::flush); }
}).when(queueDAO).remove(anyString(), anyString()); workflowExecutor.terminateWorkflow("workflowId", "reason"); assertEquals(Workflow.WorkflowStatus.TERMINATED, workflow.getStatus()); assertEquals(1, updateWorkflowCalledCounter.get());
@Test public void testDeciderUpdate() { metadataService.getWorkflowDef(LINEAR_WORKFLOW_T1_T2, 1); String correlationId = "unit_test_1" + UUID.randomUUID().toString(); Map<String, Object> input = new HashMap<String, Object>(); String inputParam1 = "p1 value"; input.put("param1", inputParam1); input.put("param2", "p2 value"); String wfid = startOrLoadWorkflowExecution(LINEAR_WORKFLOW_T1_T2, 1, correlationId, input, null, null); assertNotNull(wfid); Workflow workflow = workflowExecutor.getWorkflow(wfid, false); long updated1 = workflow.getUpdateTime(); Uninterruptibles.sleepUninterruptibly(100, TimeUnit.MILLISECONDS); workflowExecutor.decide(wfid); workflow = workflowExecutor.getWorkflow(wfid, false); long updated2 = workflow.getUpdateTime(); assertEquals(updated1, updated2); Uninterruptibles.sleepUninterruptibly(100, TimeUnit.MILLISECONDS); workflowExecutor.terminateWorkflow(wfid, "done"); workflow = workflowExecutor.getWorkflow(wfid, false); updated2 = workflow.getUpdateTime(); assertTrue("updated1[" + updated1 + "] >? updated2[" + updated2 + "]", updated2 > updated1); }
assertEquals(RUNNING, es.getStatus()); workflowExecutor.terminateWorkflow(wfId, "fail"); es = workflowExecutionService.getExecutionStatus(wfId, true); assertEquals(WorkflowStatus.TERMINATED, es.getStatus());
/** * Terminate workflow execution. * @param workflowId WorkflowId of the workflow. * @param reason Reason for terminating the workflow. */ @Service public void terminateWorkflow(String workflowId, String reason) { workflowExecutor.terminateWorkflow(workflowId, reason); }
public void terminateWorkflow(String workflowId, String reason) { Workflow workflow = executionDAOFacade.getWorkflowById(workflowId, true); workflow.setStatus(WorkflowStatus.TERMINATED); terminateWorkflow(workflow, reason, null); }
/** * Terminate workflows execution. * @param workflowIds - list of workflow Ids to perform terminate operation on * @param reason - description to be specified for the terminated workflow for future references. * @return bulk response object containing a list of succeeded workflows and a list of failed ones with errors */ @Service public BulkResponse terminate(List<String> workflowIds, String reason) { BulkResponse bulkResponse = new BulkResponse(); for (String workflowId : workflowIds) { workflowExecutor.terminateWorkflow(workflowId, reason); try { workflowExecutor.terminateWorkflow(workflowId, reason); bulkResponse.appendSuccessResponse(workflowId); } catch (Exception e) { LOGGER.error("bulk terminate exception, workflowId {}, message: {} ",workflowId, e.getMessage(), e); bulkResponse.appendFailedResponse(workflowId, e.getMessage()); } } return bulkResponse; } }
@Override public void cancel(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; } Workflow subWorkflow = provider.getWorkflow(workflowId, false); subWorkflow.setStatus(WorkflowStatus.TERMINATED); provider.terminateWorkflow(subWorkflow, "Parent workflow has been terminated with status " + workflow.getStatus(), null); }
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); }