private StateMachine buildTaskStateMachine() { final StateMachine.Builder stateMachineBuilder = StateMachine.newBuilder(); // Add states stateMachineBuilder.addState(State.READY, "The task is ready to be executed."); stateMachineBuilder.addState(State.EXECUTING, "The task is executing."); stateMachineBuilder.addState(State.ON_HOLD, "The task is paused (e.g., for dynamic optimization)."); stateMachineBuilder.addState(State.COMPLETE, "The task has completed."); stateMachineBuilder.addState(State.SHOULD_RETRY, "The task should be retried."); stateMachineBuilder.addState(State.FAILED, "Task failed, and is unrecoverable. The job will fail."); // From READY stateMachineBuilder.addTransition(State.READY, State.EXECUTING, "Scheduling to executor"); // From EXECUTING stateMachineBuilder.addTransition(State.EXECUTING, State.COMPLETE, "Task completed normally"); stateMachineBuilder.addTransition(State.EXECUTING, State.ON_HOLD, "Task paused for dynamic optimization"); stateMachineBuilder.addTransition(State.EXECUTING, State.SHOULD_RETRY, "Did not complete, should be retried"); stateMachineBuilder.addTransition(State.EXECUTING, State.FAILED, "Unrecoverable failure"); // From ON HOLD stateMachineBuilder.addTransition(State.ON_HOLD, State.COMPLETE, "Task completed after being on hold"); stateMachineBuilder.addTransition(State.ON_HOLD, State.SHOULD_RETRY, "Did not complete, should be retried"); stateMachineBuilder.addTransition(State.ON_HOLD, State.FAILED, "Unrecoverable failure"); // From COMPLETE stateMachineBuilder.addTransition(State.COMPLETE, State.SHOULD_RETRY, "Completed before, but should be retried"); // From SHOULD_RETRY stateMachineBuilder.addTransition(State.SHOULD_RETRY, State.SHOULD_RETRY, "SHOULD_RETRY can be caused by multiple reasons"); stateMachineBuilder.setInitialState(State.READY); return stateMachineBuilder.build(); }
private StateMachine buildTaskStateMachine() { final StateMachine.Builder stateMachineBuilder = StateMachine.newBuilder(); // Add states stateMachineBuilder.addState(State.READY, "The task is ready to be executed."); stateMachineBuilder.addState(State.EXECUTING, "The task is executing."); stateMachineBuilder.addState(State.ON_HOLD, "The task is paused (e.g., for dynamic optimization)."); stateMachineBuilder.addState(State.COMPLETE, "The task has completed."); stateMachineBuilder.addState(State.SHOULD_RETRY, "The task should be retried."); stateMachineBuilder.addState(State.FAILED, "Task failed, and is unrecoverable. The job will fail."); // From READY stateMachineBuilder.addTransition(State.READY, State.EXECUTING, "Scheduling to executor"); // From EXECUTING stateMachineBuilder.addTransition(State.EXECUTING, State.COMPLETE, "Task completed normally"); stateMachineBuilder.addTransition(State.EXECUTING, State.ON_HOLD, "Task paused for dynamic optimization"); stateMachineBuilder.addTransition(State.EXECUTING, State.SHOULD_RETRY, "Did not complete, should be retried"); stateMachineBuilder.addTransition(State.EXECUTING, State.FAILED, "Unrecoverable failure"); // From ON HOLD stateMachineBuilder.addTransition(State.ON_HOLD, State.COMPLETE, "Task completed after being on hold"); stateMachineBuilder.addTransition(State.ON_HOLD, State.SHOULD_RETRY, "Did not complete, should be retried"); stateMachineBuilder.addTransition(State.ON_HOLD, State.FAILED, "Unrecoverable failure"); // From COMPLETE stateMachineBuilder.addTransition(State.COMPLETE, State.SHOULD_RETRY, "Completed before, but should be retried"); // From SHOULD_RETRY stateMachineBuilder.addTransition(State.SHOULD_RETRY, State.SHOULD_RETRY, "SHOULD_RETRY can be caused by multiple reasons"); stateMachineBuilder.setInitialState(State.READY); return stateMachineBuilder.build(); }
private StateMachine buildTaskStateMachine() { final StateMachine.Builder stateMachineBuilder = StateMachine.newBuilder(); // Add states stateMachineBuilder.addState(State.READY, "The plan has been created and submitted to runtime."); stateMachineBuilder.addState(State.EXECUTING, "The plan is executing (with its stages executing)."); stateMachineBuilder.addState(State.COMPLETE, "The plan is complete."); stateMachineBuilder.addState(State.FAILED, "Plan failed."); // Add transitions stateMachineBuilder.addTransition(State.READY, State.EXECUTING, "Begin executing!"); stateMachineBuilder.addTransition(State.EXECUTING, State.COMPLETE, "All stages complete, plan complete"); stateMachineBuilder.addTransition(State.EXECUTING, State.FAILED, "Unrecoverable failure in a stage"); stateMachineBuilder.setInitialState(State.READY); return stateMachineBuilder.build(); }
private StateMachine buildBlockStateMachine() { final StateMachine.Builder stateMachineBuilder = StateMachine.newBuilder(); // Add states stateMachineBuilder.addState(State.IN_PROGRESS, "The block is in the progress of being created."); stateMachineBuilder.addState(State.AVAILABLE, "The block is available."); stateMachineBuilder.addState(State.NOT_AVAILABLE, "The block is not available."); // From IN_PROGRESS stateMachineBuilder.addTransition(State.IN_PROGRESS, State.AVAILABLE, "The block is successfully created"); stateMachineBuilder.addTransition(State.IN_PROGRESS, State.NOT_AVAILABLE, "The block is lost before being created"); // From AVAILABLE stateMachineBuilder.addTransition(State.AVAILABLE, State.NOT_AVAILABLE, "The block is not available"); stateMachineBuilder.setInitialState(State.IN_PROGRESS); return stateMachineBuilder.build(); }
private StateMachine buildTaskStateMachine() { final StateMachine.Builder stateMachineBuilder = StateMachine.newBuilder(); // Add states stateMachineBuilder.addState(State.INCOMPLETE, "Some tasks in this stage are not complete."); stateMachineBuilder.addState(State.COMPLETE, "All of this stage's tasks have completed."); // Add transitions stateMachineBuilder.addTransition( State.INCOMPLETE, State.INCOMPLETE, "A task in the stage needs to be retried"); stateMachineBuilder.addTransition(State.INCOMPLETE, State.COMPLETE, "All tasks complete"); stateMachineBuilder.addTransition(State.COMPLETE, State.INCOMPLETE, "Completed before, but a task in this stage should be retried"); stateMachineBuilder.addTransition(State.COMPLETE, State.COMPLETE, "Completed before, but probably a cloned task has completed again"); stateMachineBuilder.setInitialState(State.INCOMPLETE); return stateMachineBuilder.build(); }
private StateMachine buildTaskStateMachine() { final StateMachine.Builder stateMachineBuilder = StateMachine.newBuilder(); // Add states stateMachineBuilder.addState(State.INCOMPLETE, "Some tasks in this stage are not complete."); stateMachineBuilder.addState(State.COMPLETE, "All of this stage's tasks have completed."); // Add transitions stateMachineBuilder.addTransition( State.INCOMPLETE, State.INCOMPLETE, "A task in the stage needs to be retried"); stateMachineBuilder.addTransition(State.INCOMPLETE, State.COMPLETE, "All tasks complete"); stateMachineBuilder.addTransition(State.COMPLETE, State.INCOMPLETE, "Completed before, but a task in this stage should be retried"); stateMachineBuilder.addTransition(State.COMPLETE, State.COMPLETE, "Completed before, but probably a cloned task has completed again"); stateMachineBuilder.setInitialState(State.INCOMPLETE); return stateMachineBuilder.build(); }
private StateMachine buildTaskStateMachine() { final StateMachine.Builder stateMachineBuilder = StateMachine.newBuilder(); // Add states stateMachineBuilder.addState(State.READY, "The plan has been created and submitted to runtime."); stateMachineBuilder.addState(State.EXECUTING, "The plan is executing (with its stages executing)."); stateMachineBuilder.addState(State.COMPLETE, "The plan is complete."); stateMachineBuilder.addState(State.FAILED, "Plan failed."); // Add transitions stateMachineBuilder.addTransition(State.READY, State.EXECUTING, "Begin executing!"); stateMachineBuilder.addTransition(State.EXECUTING, State.COMPLETE, "All stages complete, plan complete"); stateMachineBuilder.addTransition(State.EXECUTING, State.FAILED, "Unrecoverable failure in a stage"); stateMachineBuilder.setInitialState(State.READY); return stateMachineBuilder.build(); }
private StateMachine buildBlockStateMachine() { final StateMachine.Builder stateMachineBuilder = StateMachine.newBuilder(); // Add states stateMachineBuilder.addState(State.IN_PROGRESS, "The block is in the progress of being created."); stateMachineBuilder.addState(State.AVAILABLE, "The block is available."); stateMachineBuilder.addState(State.NOT_AVAILABLE, "The block is not available."); // From IN_PROGRESS stateMachineBuilder.addTransition(State.IN_PROGRESS, State.AVAILABLE, "The block is successfully created"); stateMachineBuilder.addTransition(State.IN_PROGRESS, State.NOT_AVAILABLE, "The block is lost before being created"); // From AVAILABLE stateMachineBuilder.addTransition(State.AVAILABLE, State.NOT_AVAILABLE, "The block is not available"); stateMachineBuilder.setInitialState(State.IN_PROGRESS); return stateMachineBuilder.build(); }