/** * Starts the decision task for a workflow. * @param workflowId WorkflowId of the workflow. */ @Service public void decideWorkflow(String workflowId) { workflowExecutor.decide(workflowId); }
@Test public void testDecideWorkflow() { workflowService.decideWorkflow("test"); verify(mockWorkflowExecutor, times(1)).decide(anyString()); }
logger.debug("Running sweeper for workflow {}", workflowId); boolean done = workflowExecutor.decide(workflowId); if(!done) { queueDAO.setUnackTimeout(WorkflowExecutor.DECIDER_QUEUE, workflowId, config.getSweepFrequency() * 1000);
/** * @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); }
executionDAOFacade.updateTasks(workflow.getTasks()); decide(workflowId);
decide(workflowId);
workflow.setExternalOutputPayloadStoragePath(null); executionDAOFacade.updateWorkflow(workflow); decide(workflowId);
@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); }
decide(workflowId);
decide(parent.getWorkflowId());
executionDAOFacade.updateWorkflow(parent); decide(parent.getWorkflowId());
for (int i = 0; i < 10; i++) { futures.add(executors.submit(() -> { workflowExecutor.decide(wfid); return null; })); workflowExecutor.decide(wfid); es = workflowExecutionService.getExecutionStatus(wfid, true); assertNotNull(es); futures.add(executors.submit(() -> { long s = System.currentTimeMillis(); workflowExecutor.decide(wfid); System.out.println("Took " + (System.currentTimeMillis() - s) + " ms to run decider"); return null;
workflowExecutor.decide(wfid);
workflowExecutor.decide(workflowId);
decide(workflowId);
workflowExecutor.decide(workflowInstanceId);
assertEquals(workflowInstanceId, task.getWorkflowInstanceId()); workflowExecutor.decide(workflowInstanceId);
workflowExecutor.decide(wfid);