/** * Requests the shutdown of the this ShardConsumer. This should give the record processor a chance to checkpoint * before being shutdown. * * @param shutdownNotification used to signal that the record processor has been given the chance to shutdown. */ void notifyShutdownRequested(ShutdownNotification shutdownNotification) { this.shutdownNotification = shutdownNotification; markForShutdown(ShutdownReason.REQUESTED); }
/** * Shutdown this ShardConsumer (including invoking the RecordProcessor shutdown API). * This is called by Worker when it loses responsibility for a shard. * * @return true if shutdown is complete (false if shutdown is still in progress) */ synchronized boolean beginShutdown() { markForShutdown(ShutdownReason.ZOMBIE); checkAndSubmitNextTask(); return isShutdown(); }
/** * 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 // }