/// <summary> /// @see IFlow#Resume . /// </summary> /// <param name="stateName"></param> /// <param name="executor"></param> /// <returns></returns> /// <exception cref="FlowExecutionException"> </exception> public FlowExecution Resume(string stateName, IFlowExecutor executor) { FlowExecutionStatus status = FlowExecutionStatus.Unkown; IState state; _stateMap.TryGetValue(stateName, out state); if (Logger.IsDebugEnabled) { Logger.Debug("Resuming state={0} with status={1}", stateName, status); } StepExecution stepExecution = null; String currentStateName = stateName; // Terminate if there are no more states while (IsFlowContinued(state, status, stepExecution)) { currentStateName = state.GetName(); try { if (Logger.IsDebugEnabled) { Logger.Debug("Handling state={0}", currentStateName); } status = state.Handle(executor); stepExecution = executor.GetStepExecution(); } catch (FlowExecutionException) { executor.Close(new FlowExecution(currentStateName, status)); throw; } catch (Exception e) { executor.Close(new FlowExecution(currentStateName, status)); throw new FlowExecutionException( string.Format("Ended flow={0} at state={1} with exception", Name, currentStateName), e); } if (Logger.IsDebugEnabled) { Logger.Debug("Completed state={0} with status={1}", currentStateName, status); } state = NextState(currentStateName, status, stepExecution); } FlowExecution result = new FlowExecution(currentStateName, status); executor.Close(result); return(result); }
/// <summary> /// Returns the FlowExecutionStatus stored. /// @see IState#Handle /// </summary> /// <param name="executor"></param> /// <returns></returns> /// <exception cref="Exception"> </exception> public override FlowExecutionStatus Handle(IFlowExecutor executor) { lock (executor) { // Special case. If the last step execution could not complete we // are in an unknown state (possibly unrecoverable). StepExecution stepExecution = executor.GetStepExecution(); if (stepExecution != null && executor.GetStepExecution().BatchStatus == BatchStatus.Unknown) { return(FlowExecutionStatus.Unkown); } if (Status.IsStop()) { if (!executor.IsRestart()) { //If there are step executions, then we are not at the // beginning of a restart. if (Abandon) { // Only if instructed to do so, upgrade the status of // last step execution so it is not replayed on a // restart... executor.AbandonStepExecution(); } } else { // If we are a stop state and we got this far then it must // be a restart, so return COMPLETED. return(FlowExecutionStatus.Completed); } } SetExitStatus(executor, Code); return(Status); } }
/// <summary> /// @see IFlow#Resume . /// </summary> /// <param name="stateName"></param> /// <param name="executor"></param> /// <returns></returns> /// <exception cref="FlowExecutionException"></exception> public FlowExecution Resume(string stateName, IFlowExecutor executor) { FlowExecutionStatus status = FlowExecutionStatus.Unkown; IState state; _stateMap.TryGetValue(stateName, out state); if (Logger.IsDebugEnabled) { Logger.Debug("Resuming state={0} with status={1}", stateName, status); } StepExecution stepExecution = null; String currentStateName = stateName; // Terminate if there are no more states while (IsFlowContinued(state, status, stepExecution)) { currentStateName = state.GetName(); try { if (Logger.IsDebugEnabled) { Logger.Debug("Handling state={0}", currentStateName); } status = state.Handle(executor); stepExecution = executor.GetStepExecution(); } catch (FlowExecutionException) { executor.Close(new FlowExecution(currentStateName, status)); throw; } catch (Exception e) { executor.Close(new FlowExecution(currentStateName, status)); throw new FlowExecutionException( string.Format("Ended flow={0} at state={1} with exception", Name, currentStateName), e); } if (Logger.IsDebugEnabled) { Logger.Debug("Completed state={0} with status={1}", currentStateName, status); } state = NextState(currentStateName, status, stepExecution); } FlowExecution result = new FlowExecution(currentStateName, status); executor.Close(result); return result; }
/// <summary> /// Returns the FlowExecutionStatus stored. /// @see IState#Handle /// </summary> /// <param name="executor"></param> /// <returns></returns> /// <exception cref="Exception"> </exception> public override FlowExecutionStatus Handle(IFlowExecutor executor) { lock (executor) { // Special case. If the last step execution could not complete we // are in an unknown state (possibly unrecoverable). StepExecution stepExecution = executor.GetStepExecution(); if (stepExecution != null && executor.GetStepExecution().BatchStatus == BatchStatus.Unknown) { return FlowExecutionStatus.Unkown; } if (Status.IsStop()) { if (!executor.IsRestart()) { //If there are step executions, then we are not at the // beginning of a restart. if (Abandon) { // Only if instructed to do so, upgrade the status of // last step execution so it is not replayed on a // restart... executor.AbandonStepExecution(); } } else { // If we are a stop state and we got this far then it must // be a restart, so return COMPLETED. return FlowExecutionStatus.Completed; } } SetExitStatus(executor, Code); return Status; } }