/** * Returns true when the execution is a branch with the new branch mechanism * It will return true for executions of parallel, multi-instance, sub-flows and non blocking */ private boolean isBranch(Execution execution) { return execution != null && !StringUtils.isEmpty(execution.getSystemContext().getBranchId()); }
private Serializable createBranchFailureEventData(Execution execution) { Map<String, Serializable> eventData = new HashMap<>(); eventData.put(ExecutionParametersConsts.SYSTEM_CONTEXT, execution.getSystemContext()); eventData.put(EventConstants.EXECUTION_ID_CONTEXT, execution.getExecutionId()); eventData.put(EventConstants.BRANCH_ID, execution.getSystemContext().getBranchId()); return (Serializable) eventData; }
@Override public String getId() { return parent.getExecutionId().toString() + parent.getSystemContext().getBranchId(); }
private Serializable createFailureEventData(Execution execution) { Map<String, Serializable> eventData = new HashMap<>(); eventData.put(ExecutionParametersConsts.SYSTEM_CONTEXT, execution.getSystemContext()); eventData.put(EventConstants.EXECUTION_ID_CONTEXT, execution.getExecutionId()); eventData.put(EventConstants.BRANCH_ID, execution.getSystemContext().getBranchId()); eventData.put(ExecutionParametersConsts.RUNNING_EXECUTION_PLAN_ID, execution.getRunningExecutionPlanId()); return (Serializable) eventData; }
@Override public String getId() { return parent.getExecutionId().toString() + parent.getSystemContext().getBranchId(); }
private Serializable createNoWorkerFailureEventData(Execution execution, Long pauseId) { String flowUuid = extractFlowUuid(execution.getRunningExecutionPlanId()); Map<String, Serializable> eventData = new HashMap<>(); eventData.put(ExecutionParametersConsts.SYSTEM_CONTEXT, execution.getSystemContext()); eventData.put(EventConstants.EXECUTION_ID_CONTEXT, execution.getExecutionId()); eventData.put(EventConstants.BRANCH_ID, execution.getSystemContext().getBranchId()); eventData.put(EventConstants.FLOW_UUID, flowUuid); eventData.put(EventConstants.PAUSE_ID, pauseId); return (Serializable) eventData; }
protected boolean handlePausedFlow(Execution execution) throws InterruptedException { String branchId = execution.getSystemContext().getBranchId(); PauseReason reason = findPauseReason(execution.getExecutionId(), branchId); if (reason != null) { // need to pause the execution pauseFlow(reason, execution); return true; } return false; }
logger.debug("finishing branch " + execution.getSystemContext().getBranchId() + " for execution " + execution.getExecutionId());
logger.debug("finishing branch " + execution.getSystemContext().getBranchId() + " for execution " + execution.getExecutionId());
String branchId = execution.getSystemContext().getBranchId(); if(logger.isDebugEnabled()){ logger.debug("Worker starts to work on execution: " + executionId + " branch: " + branchId);
private boolean handlePausedFlowAfterStep(Execution execution) throws InterruptedException { String branchId = execution.getSystemContext().getBranchId(); PauseReason reason = null; ExecutionSummary execSummary = pauseService.readPausedExecution(execution.getExecutionId(), branchId); if (execSummary != null && execSummary.getStatus().equals(ExecutionStatus.PENDING_PAUSE)) { reason = execSummary.getPauseReason(); } if (reason != null) { // need to pause the execution pauseFlow(reason, execution); return true; } return false; }
private void pauseFlow(PauseReason reason, Execution execution) throws InterruptedException { SystemContext systemContext = execution.getSystemContext(); Long executionId = execution.getExecutionId(); String branchId = systemContext.getBranchId(); // If USER_PAUSED send such event if (!isDebuggerMode(execution.getSystemContext()) && reason.equals(PauseReason.USER_PAUSED)) { if (branchId != null) { // we pause the branch because the Parent was user-paused (see findPauseReason) pauseService.pauseExecution(executionId, branchId, reason); // this creates a DB record for this branch, as Pending-paused } } addPauseEvent(systemContext); // dump bus events here because out side is too late dumpBusEvents(execution); // Write execution to the db! Pay attention - do not do anything to the execution or its context after this line!!! pauseService.writeExecutionObject(executionId, branchId, execution); if (logger.isDebugEnabled()) { logger.debug("Execution with execution_id: " + execution.getExecutionId() + " is paused!"); } }
@Override public FinishedBranch convert(Execution execution) { boolean isBranchCancelled = ExecutionStatus.CANCELED.equals(execution.getSystemContext().getFlowTerminationType()); return new FinishedBranch(execution.getExecutionId().toString(), execution.getSystemContext().getBranchId(), execution.getSystemContext().getSplitId(), execution.getSystemContext().getStepErrorKey(), new BranchContexts(isBranchCancelled, execution.getContexts(), execution.getSystemContext())); } };
@Override public FinishedBranch convert(Execution execution) { boolean isBranchCancelled = ExecutionStatus.CANCELED.equals(execution.getSystemContext().getFlowTerminationType()); return new FinishedBranch(execution.getExecutionId().toString(), execution.getSystemContext().getBranchId(), execution.getSystemContext().getSplitId(), execution.getSystemContext().getStepErrorKey(), new BranchContexts(isBranchCancelled, execution.getContexts(), execution.getSystemContext())); } };
private Long pauseExecution(Execution execution) { String branchId = execution.getSystemContext().getBranchId(); ExecutionSummary pe = pauseResumeService.readPausedExecution(execution.getExecutionId(), branchId); //Check if this execution is not paused already (by user) Long pauseId; if (pe == null) { // When cancel execution and no worker in group it should return to be paused without any termination type execution.getSystemContext().setFlowTerminationType(null); pauseId = pauseResumeService.pauseExecution(execution.getExecutionId(), branchId, PauseReason.NO_WORKERS_IN_GROUP); pauseResumeService.writeExecutionObject(execution.getExecutionId(), branchId, execution); } else { pauseId = null; //If yes - just write the object pauseResumeService.writeExecutionObject(execution.getExecutionId(), branchId, execution); } return pauseId; }