private void initialize(boolean resumeIfIncomplete) throws IOException { JobSuiteStatusSnapshot statusTree = JobSuiteStatusSnapshot.newSnapshot(getSuiteIndexFile()); if (statusTree != null) { LOG.info("Previous execution detected."); MutableJobStatus status = (MutableJobStatus) statusTree.getRoot(); JobState state = status.getState(); ensureValidExecutionState(state); if (resumeIfIncomplete && !state.isOneOf( JobState.COMPLETED, JobState.PREMATURE_TERMINATION)) { LOG.info("Resuming from previous execution."); prepareStatusTreeForResume(statusTree); } else { // Back-up so we can start clean LOG.info("Backing up previous execution status and log files."); backupSuite(statusTree); statusTree = null; } } else { LOG.info("No previous execution detected."); } if (statusTree == null) { statusTree = JobSuiteStatusSnapshot.create( getRootJob(), getLogManager()); writeJobSuiteIndex(statusTree); } this.jobSuiteStatusSnapshot = statusTree; }
public IJobStatus getJobStatus(String jobId) { if (jobSuiteStatusSnapshot != null) { return jobSuiteStatusSnapshot.getJobStatus(jobId); } try { File indexFile = JEFUtil.getSuiteIndexFile(getWorkdir(), getId()); JobSuiteStatusSnapshot snapshot = JobSuiteStatusSnapshot.newSnapshot(indexFile); if (snapshot != null) { return snapshot.getJobStatus(jobId); } return null; } catch (IOException e) { throw new JEFException("Cannot obtain suite status.", e); } }