code: public ExecutionState updateExecutionState(ExecutionState newExecutionState, final String optionalMessage) {
  
  		if (newExecutionState == null) {
  			throw new IllegalArgumentException("Argument newExecutionState must not be null");
  		}
  
  		final ExecutionState currentExecutionState = this.executionState.get();
  		if (currentExecutionState == ExecutionState.CANCELING) {
  
  			// If we are in CANCELING, ignore state changes to FINISHING
  			if (newExecutionState == ExecutionState.FINISHING) {
  				return currentExecutionState;
  			}
  
  			// Rewrite FINISHED to CANCELED if the task has been marked to be canceled
  			if (newExecutionState == ExecutionState.FINISHED) {
  				LOG.info("Received transition from CANCELING to FINISHED for vertex " + toString()
  					+ ", converting it to CANCELED");
  				newExecutionState = ExecutionState.CANCELED;
  			}
  		}
  
  		// Check and save the new execution state
  		final ExecutionState previousState = this.executionState.getAndSet(newExecutionState);
  		if (previousState == newExecutionState) {
  			return previousState;
  		}
  
  		// Check the transition
  		ExecutionStateTransition.checkTransition(true, toString(), previousState, newExecutionState);
  
  		// Notify the listener objects
  		final Iterator<ExecutionListener> it = this.executionListeners.values().iterator();
  		while (it.hasNext()) {
  			it.next().executionStateChanged(this.executionGraph.getJobID(), this.vertexID, newExecutionState,
  				optionalMessage);
  		}
  
  		// The vertex was requested to be canceled by another thread
  		checkCancelRequestedFlag();
  
  		return previousState;
  	}
docs: Updates the vertex's current execution state.
  
  @param newExecutionState
  the new execution state
  @param optionalMessage
  an optional message related to the state change