public static void checkTransition ( boolean jobManager , String taskName , ExecutionState oldState , ExecutionState newState ) { LOG . info ( ( jobManager ? "JM: " : "TM: " ) + "ExecutionState set from " + oldState + " to " + newState + " for task " + taskName ) ; boolean unexpectedStateChange = true ; // This is the regular life cycle of a task if ( oldState == ExecutionState . CREATED && newState == ExecutionState . SCHEDULED ) { unexpectedStateChange = false ; } else if ( oldState == ExecutionState . SCHEDULED && newState == ExecutionState . ASSIGNED ) { unexpectedStateChange = false ; } else if ( oldState == ExecutionState . ASSIGNED && newState == ExecutionState . READY ) { unexpectedStateChange = false ; } else if ( oldState == ExecutionState . READY && newState == ExecutionState . STARTING ) { unexpectedStateChange = false ; } else if ( oldState == ExecutionState . STARTING && newState == ExecutionState . RUNNING ) { unexpectedStateChange = false ; } else if ( oldState == ExecutionState . RUNNING && newState == ExecutionState . FINISHING ) { unexpectedStateChange = false ; } else if ( oldState == ExecutionState . FINISHING && newState == ExecutionState . FINISHED ) { unexpectedStateChange = false ; } // A vertex might skip the SCHEDULED state if its resource has been allocated in a previous stage. else if ( oldState == ExecutionState . CREATED && newState == ExecutionState . ASSIGNED ) { unexpectedStateChange = false ; } // This transition can appear if a task in a stage which is not yet executed gets canceled. else if ( oldState == ExecutionState . SCHEDULED && newState == ExecutionState . CANCELING ) { unexpectedStateChange = false ; } // This transition can appear if a task in a stage which is not yet executed gets canceled. else if ( oldState == ExecutionState . ASSIGNED && newState == ExecutionState . CANCELING ) { unexpectedStateChange = false ; } // This transition can appear if a task is canceled that is not yet running on the task manager. else if ( oldState == ExecutionState . READY && newState == ExecutionState . CANCELING ) { unexpectedStateChange = false ; } // -------------- error cases -------------- else if ( newState == FAILED || newState == CANCELED || newState == CANCELING ) { // any state may fail or cancel itself unexpectedStateChange = false ; } if ( unexpectedStateChange ) { LOG . error ( "Unexpected state change: " + oldState + " -> " + newState ) ; } }
Checks the transition of the execution state and outputs an error in case of an unexpected state transition .