public class StateMachine extends Object implements IEventsState, IEventsProcessEngine
Constructor and Description |
---|
StateMachine(ProcessWorkflow processWorkflow,
ProcessEngine processEngine) |
Modifier and Type | Method and Description |
---|---|
void |
cancel()
Cancel as soon as possible the processWorkflow, To do that, the step pauseCancelAction is updated to be
PauseOrCancelAction.ACTION_CANCEL Unlike pause, - The finally step should be executed, -
PauseOrCancelAction.ACTION_CANCEL have no impact on the finally step - The finally step cannot be cancelled
|
protected void |
doCompleted()
Change the state of the process to completed Can be called only from running or pause state If running state, the
next step will be completed
|
protected void |
doPause(PauseRecover pauseRecover)
Change state of the process to pause Can be called only from running state If last step then change state to
completed
|
protected void |
doReplay(WorkerParameters workerParameters,
ProcessState targetState)
Change state of the process to running Can be called only from pause state
|
protected void |
doRunning(WorkerParameters workerParameters,
ProcessState targetState)
Change state of the process to running Can be called only from pause state
|
protected void |
executeFinallyStep(WorkerParameters workerParameters)
Execute the finally step of the workflow Update global status of the workflow Persist the process workflow
|
protected void |
executeSteps(WorkerParameters workerParameters,
PauseRecover pauseRecover,
boolean backwards)
Execute steps of the workflow and manage index of the current step Call engine to execute the current step
|
protected void |
finalizeLogbook(WorkerParameters workParams)
Create the final logbook entry for the corresponding process workflow This entry was created in ingest internal
and as the process is full async we moved it to here
|
String |
getContextId() |
LogbookTypeProcess |
getLogbookTypeProcess() |
int |
getTenant() |
String |
getWorkflowId() |
boolean |
isCompleted()
Check if the state is completed
|
boolean |
isDone() |
protected boolean |
isLastStep()
Check if the current step is the last one
|
protected boolean |
isPause()
Check if the state is pause
|
boolean |
isRecover() |
protected boolean |
isRunning()
Check if the state is running
|
boolean |
isStepByStep() |
void |
next(WorkerParameters workerParameters)
Like a resume but pause at the next step
|
void |
onComplete(ItemStatus itemStatus,
WorkerParameters workerParameters)
The ProcessEngine callback on complete step (for any status code)
|
void |
onError(Throwable throwable,
WorkerParameters workerParameters)
The ProcessEngine callback on system error occurred
|
void |
onPauseOrCancel(PauseOrCancelAction pauseCancelAction,
WorkerParameters workerParameters)
The ProcessEngine callback onPauseOrCancel when the step is paused or cancelled
|
void |
onUpdate(StatusCode statusCode)
Update the current step status code
|
void |
onUpdate(String messageIdentifier,
String prodService) |
void |
pause()
Pause the processWorkflow, If the last step the just wait the finally step Else pause the processWorkflow as soon
as possible Do not wait all elements of the current step to be executed The step pauseCancelAction will be
updated to PauseOrCancelAction.ACTION_PAUSE If all elements of the current step are executed then stop correctly
and step pauseCancelAction will be updated to PauseOrCancelAction.ACTION_COMPLETE
After next or resume occurs on paused processWorkflow, It will starts from the step pauseCancelAction equals to
PauseOrCancelAction.ACTION_PAUSE if exists and update pauseCancelAction to be PauseOrCancelAction.ACTION_RECOVER
Else starts normally from the next step
|
protected boolean |
persistProcessWorkflow()
Persist the process workflow in the workspace
|
void |
replay(WorkerParameters workerParameters)
Replay the last executed step, or if it s stated, the step passed as a parameter
|
void |
resume(WorkerParameters workerParameters)
Do an evaluation of the State RUNNING If the state is not permitted a StateNotAllowedException is thrown Else
call doRunning method
|
void |
shutdown()
Should used only when server is shutting down
To prevent deadlock, this method is not synchronized, Because onComplete and onPauseOrCancel are synchronized and
called from ProcessEngine
|
public StateMachine(ProcessWorkflow processWorkflow, ProcessEngine processEngine)
public void resume(WorkerParameters workerParameters) throws StateNotAllowedException, ProcessingException
IEventsState
resume
in interface IEventsState
StateNotAllowedException
ProcessingException
public void next(WorkerParameters workerParameters) throws StateNotAllowedException, ProcessingException
IEventsState
next
in interface IEventsState
StateNotAllowedException
ProcessingException
public void replay(WorkerParameters workerParameters) throws StateNotAllowedException, ProcessingException
IEventsState
replay
in interface IEventsState
StateNotAllowedException
ProcessingException
public void pause() throws StateNotAllowedException
IEventsState
pause
in interface IEventsState
StateNotAllowedException
public void shutdown() throws StateNotAllowedException
IEventsState
shutdown
in interface IEventsState
StateNotAllowedException
public void cancel() throws StateNotAllowedException, ProcessingException
IEventsState
cancel
in interface IEventsState
StateNotAllowedException
ProcessingException
public boolean isDone()
isDone
in interface IEventsState
public int getTenant()
getTenant
in interface IEventsState
public String getWorkflowId()
getWorkflowId
in interface IEventsState
public String getContextId()
getContextId
in interface IEventsState
public boolean isStepByStep()
isStepByStep
in interface IEventsState
public LogbookTypeProcess getLogbookTypeProcess()
getLogbookTypeProcess
in interface IEventsState
protected void doPause(PauseRecover pauseRecover) throws StateNotAllowedException
pauseRecover
- if RECOVER_FROM_SERVER_PAUSE then wait until pause is doneStateNotAllowedException
protected void doCompleted() throws StateNotAllowedException, ProcessingException
protected void doRunning(WorkerParameters workerParameters, ProcessState targetState) throws ProcessingException
workerParameters
- the parameters to be passed to the distributortargetState
- if true, run ony the next stepStateNotAllowedException
ProcessingException
protected void doReplay(WorkerParameters workerParameters, ProcessState targetState) throws ProcessingException
workerParameters
- the parameters to be passed to the distributortargetState
- if true, run ony the next stepStateNotAllowedException
ProcessingException
protected void executeSteps(WorkerParameters workerParameters, PauseRecover pauseRecover, boolean backwards) throws ProcessingException
workerParameters
- ProcessingException
protected void executeFinallyStep(WorkerParameters workerParameters)
workerParameters
- public void onUpdate(StatusCode statusCode)
IEventsProcessEngine
onUpdate
in interface IEventsProcessEngine
public void onUpdate(String messageIdentifier, String prodService)
onUpdate
in interface IEventsProcessEngine
public void onError(Throwable throwable, WorkerParameters workerParameters)
IEventsProcessEngine
onError
in interface IEventsProcessEngine
public void onPauseOrCancel(PauseOrCancelAction pauseCancelAction, WorkerParameters workerParameters)
IEventsProcessEngine
onPauseOrCancel
in interface IEventsProcessEngine
public void onComplete(ItemStatus itemStatus, WorkerParameters workerParameters)
IEventsProcessEngine
onComplete
in interface IEventsProcessEngine
protected boolean isRunning()
protected boolean isPause()
public boolean isCompleted()
public boolean isRecover()
isRecover
in interface IEventsState
protected boolean isLastStep()
protected boolean persistProcessWorkflow()
protected void finalizeLogbook(WorkerParameters workParams)
Copyright © 2018 Vitam. All rights reserved.