/** * {@inheritDoc} */ @Override public TaskType getTaskType() { return other.getTaskType(); }
@Override public String toString() { return this.getClass().getName() + "<" + other.getTaskType() + ">(" + other + ")"; }
private void logTaskException(TaskResult taskResult) { if (LOG.isDebugEnabled()) { Exception taskException = taskResult.getException(); if (taskException instanceof BlockedOnParentShardException) { // No need to log the stack trace for this exception (it is very specific). LOG.debug("Shard " + shardInfo.getShardId() + " is blocked on completion of parent shard."); } else { LOG.debug("Caught exception running " + currentTask.getTaskType() + " task: ", taskResult.getException()); } } }
TaskResult result = future.get(); if (result.getException() != null) { LOG.error("Caught exception running " + currentTask.getTaskType() + " task: ", result.getException()); LOG.warn(currentTask.getTaskType() + " task encountered exception.", e); submittedNewTask = true; if (LOG.isDebugEnabled()) { LOG.debug("Submitted new " + currentTask.getTaskType() + " task."); LOG.debug("Previous " + currentTask.getTaskType() + " task still pending. Not submitting new task.");
currentTaskSubmitTime = System.currentTimeMillis(); submittedNewTask = true; LOG.debug("Submitted new " + currentTask.getTaskType() + " task for shard " + shardInfo.getShardId()); } catch (RejectedExecutionException e) { LOG.info(currentTask.getTaskType() + " task was not accepted for execution.", e); } catch (RuntimeException e) { LOG.info(currentTask.getTaskType() + " task encountered exception ", e); final long timeElapsed = System.currentTimeMillis() - currentTaskSubmitTime; final String commonMessage = String.format("Previous %s task still pending for shard %s since %d ms ago. ", currentTask.getTaskType(), shardInfo.getShardId(), timeElapsed); if (LOG.isDebugEnabled()) { LOG.debug(commonMessage + "Not submitting new task.");
/** * 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 // }