/** * Checks whether the job ended before its time. This may or may not * be the result of an error. Prematurely ended jobs are eligible * for resuming. * @return <code>true</code> if job finished */ //TODO fix method typo (PrematurEly). @Override public boolean isPrematurlyEnded() { return duration.getEndTime() != null && !isCompleted(); } /**
/** * Checks whether the job was aborted or not (i.e. killed). That is, if * the job started and is no longer running, while it never * marked as finished. Remember that under normal conditions, a job * should always finish, whether it failed or not. An aborted progress * is usually the results of a job suite which got "killed" in the middle * of its execution (not having the chance to return properly). * @return <code>true</code> if job was started * @since 1.1 */ @Override public boolean isAborted() { return isStarted() && !isRunning() && duration.getEndTime() == null && !isCompleted(); }
/** * Gets the job execution state. * @return execution state */ @Override public JobState getState() { // The order is important to establish status if (isAborted()) { return JobState.ABORTED; } if (isStopped()) { return JobState.STOPPED; } if (isStopping()) { return JobState.STOPPING; } if (isCompleted()) { return JobState.COMPLETED; } if (isPrematurlyEnded()) { return JobState.PREMATURE_TERMINATION; } if (isRunning()) { return JobState.RUNNING; } return JobState.UNKNOWN; }
@Override public void visitJobStatus(IJobStatus jobStatus) { MutableJobStatus status = (MutableJobStatus) jobStatus; status.setStopRequested(false); JobDuration duration = status.getDuration(); if (status.isStarted() && !status.isCompleted()) { status.incrementResumeAttempts(); if (duration != null) { duration.setResumedStartTime( duration.getStartTime()); duration.setResumedLastActivity( status.getLastActivity()); } } } });