/** * Note: This is a private/internal method with package level access solely for testing purposes. * Update state based on information about: task success, current state, and shutdown info. * * @param taskOutcome The outcome of the last task */ void updateState(TaskOutcome taskOutcome) { if (taskOutcome == TaskOutcome.END_OF_SHARD) { markForShutdown(ShutdownReason.TERMINATE); } if (isShutdownRequested() && taskOutcome != TaskOutcome.FAILURE) { currentState = currentState.shutdownTransition(shutdownReason); } else if (taskOutcome == TaskOutcome.SUCCESSFUL) { if (currentState.getTaskType() == currentTask.getTaskType()) { currentState = currentState.successTransition(); } else { LOG.error("Current State task type of '" + currentState.getTaskType() + "' doesn't match the current tasks type of '" + currentTask.getTaskType() + "'. This shouldn't happen, and indicates a programming error. " + "Unable to safely transition to the next state."); } } // // Don't change state otherwise // }