private boolean isExecutionTerminating(Execution nextStepExecution) { if(nextStepExecution.getPosition() == null) { //set current step to finished executionMessage.setStatus(ExecStatus.FINISHED); executionMessage.incMsgSeqId(); executionMessage.setPayload(null); //Flow is finished - does not matter if successfully or not ExecutionMessage terminationMessage = createTerminatedExecutionMessage(nextStepExecution); ExecutionMessage[] executionMessagesToSend = new ExecutionMessage[]{executionMessage, terminationMessage}; //Messages that we will send to OutBuffer try { outBuffer.put(executionMessagesToSend); } catch (InterruptedException e) { logger.warn("Thread was interrupted! Exiting the execution... ", e); return true; } return true; } else { return false; } }
protected ExecutionStep loadExecutionStep(Execution execution) { RunningExecutionPlan runningExecutionPlan; if (execution != null) { // Optimization for external workers - run the content only without loading the execution plan if (execution.getSystemContext().get(TempConstants.CONTENT_EXECUTION_STEP) != null) { return (ExecutionStep) execution.getSystemContext().get(TempConstants.CONTENT_EXECUTION_STEP); } Long position = execution.getPosition(); if (position != null) { runningExecutionPlan = workerDbSupportService .readExecutionPlanById(execution.getRunningExecutionPlanId()); if (runningExecutionPlan != null) { updateMetadata(execution, runningExecutionPlan); ExecutionStep currStep = runningExecutionPlan.getExecutionPlan().getStep(position); if (logger.isDebugEnabled()) { logger.debug("Begin step: " + position + " in flow " + runningExecutionPlan.getExecutionPlan() .getFlowUuid() + " [" + execution.getExecutionId() + "]"); } if (currStep != null) { return currStep; } } } } // If we got here - one of the objects was null throw new RuntimeException("Failed to load ExecutionStep!"); }
@Override // returns null in case the split was not done - flow is paused or cancelled public List<Execution> executeSplit(Execution execution) throws InterruptedException { try { ExecutionStep currStep = loadExecutionStep(execution); // Check if this execution was paused if (!isDebuggerMode(execution.getSystemContext()) && handlePausedFlow(execution)) { return null; } // dum bus event dumpBusEvents(execution); executeSplitStep(execution, currStep); failFlowIfSplitStepFailed(execution); dumpBusEvents(execution); // Run the split step List<StartBranchDataContainer> newBranches = execution.getSystemContext().removeBranchesData(); List<Execution> newExecutions = createChildExecutions(execution.getExecutionId(), newBranches); // Run the navigation navigate(execution, currStep); dumpBusEvents(execution); if (logger.isDebugEnabled()) { logger.debug( "End of step: " + execution.getPosition() + " in execution id: " + execution.getExecutionId()); } return newExecutions; } catch (Exception ex) { logger.error("Exception during the split step!", ex); throw ex; } }
if (logger.isDebugEnabled()) { logger.debug( "End of step: " + execution.getPosition() + " in execution id: " + execution.getExecutionId());