/** * Computes the Chronos job's state based on current success and error count. * * @param job the {@link Job}. * @return the {@link JobState}. */ public static JobState getLastState(Job job) { // State = Fresh (success + error = 0), Success (success > 0), Failure (error > 0) // NOTE that Chronos increments the error only after all the retries has failed (x retries -> +1 // error) if (job.getSuccessCount() > 0) { return JobState.SUCCESS; } else { if (job.getErrorCount() > 0) { return JobState.FAILURE; } else { return JobState.FRESH; } } }