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; }
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 boolean pauseExecution(Long executionId) { ExecutionState executionState = executionStateService.readByExecutionIdAndBranchId(executionId, ExecutionState.EMPTY_BRANCH); if (canBePaused(executionState)) { pauseResumeService.pauseExecution(executionId, null, PauseReason.USER_PAUSED); return true; } else { return false; } }
private PauseReason findPauseReason(Long executionId, String branchId) { // 1. Check the configuration according to branch (can be null or not null...) if (workerConfigurationService.isExecutionPaused(executionId, branchId)) { ExecutionSummary execSummary = pauseService.readPausedExecution(executionId, branchId); if (execSummary != null && execSummary.getStatus().equals(ExecutionStatus.PENDING_PAUSE)) { return execSummary.getPauseReason(); } // 2. Check the parent if we're in branch (subflow or MI\Parallel lane). // If the user pressed Pause on the Parent then we need to pause the branch (the parent is in the Suspended table). } else if (branchId != null && workerConfigurationService.isExecutionPaused(executionId, null)) { ExecutionSummary execSummary = pauseService.readPausedExecution(executionId, null); if (execSummary != null && execSummary.getStatus().equals(ExecutionStatus.PENDING_PAUSE)) { PauseReason reason = execSummary.getPauseReason(); // we only care about User-Paused here! // we don't want to Pause if the parent is paused due to branch_paused! (other branch is paused for some reason (e.g. required_input), so the parent is paused as well). if (PauseReason.USER_PAUSED.equals(reason)) { return reason; } } } return null; // not paused }
@Override public MergedConfigurationDataContainer fetchMergedConfiguration(String workerUuid) { MergedConfigurationDataContainer mergedConfigurationDataContainer = new MergedConfigurationDataContainer(); try { mergedConfigurationDataContainer.setCancelledExecutions(cancelExecutionService.readCanceledExecutionsIds()); } catch(Exception ex) { log.error("Failed to fetch cancelled information: ", ex); } try { mergedConfigurationDataContainer.setPausedExecutions(pauseResumeService.readAllPausedExecutionBranchIds()); } catch(Exception ex) { log.error("Failed to read paused flows information: ", ex); } try { mergedConfigurationDataContainer.setWorkerGroups(workerNodeService.readWorkerGroups(workerUuid)); } catch(Exception ex) { log.error("Failed to fetch worker group information: ", ex); } return mergedConfigurationDataContainer; } }
@Override public boolean pauseExecution(Long executionId) { ExecutionState executionState = executionStateService.readByExecutionIdAndBranchId(executionId, ExecutionState.EMPTY_BRANCH); if (canBePaused(executionState)) { pauseResumeService.pauseExecution(executionId, null, PauseReason.USER_PAUSED); return true; } else { return false; } }
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; }
@Override public MergedConfigurationDataContainer fetchMergedConfiguration(String workerUuid) { MergedConfigurationDataContainer mergedConfigurationDataContainer = new MergedConfigurationDataContainer(); try { mergedConfigurationDataContainer.setCancelledExecutions(cancelExecutionService.readCanceledExecutionsIds()); } catch(Exception ex) { log.error("Failed to fetch cancelled information: ", ex); } try { mergedConfigurationDataContainer.setPausedExecutions(pauseResumeService.readAllPausedExecutionBranchIds()); } catch(Exception ex) { log.error("Failed to read paused flows information: ", ex); } try { mergedConfigurationDataContainer.setWorkerGroups(workerNodeService.readWorkerGroups(workerUuid)); } catch(Exception ex) { log.error("Failed to fetch worker group information: ", ex); } return mergedConfigurationDataContainer; } }