private static JobStatusTreeNode loadTreeNode( IJobStatus parentStatus, HierarchicalConfiguration jobXML, String suiteName, IJobStatusStore store) throws IOException { if (jobXML == null) { return null; } String jobId = jobXML.getString("[@name]"); IJobStatus jobStatus = store.read(suiteName, jobId); List<HierarchicalConfiguration> xmls = jobXML.configurationsAt("job"); List<JobStatusTreeNode> childNodes = new ArrayList<JobStatusTreeNode>(); if (xmls != null) { for (HierarchicalConfiguration xml : xmls) { JobStatusTreeNode child = loadTreeNode( jobStatus, xml, suiteName, store); if (child != null) { childNodes.add(child); } } } return new JobStatusTreeNode(parentStatus, jobStatus, childNodes); }
private void writeJobSuiteIndex(JobSuiteStatusSnapshot statusTree) throws IOException { File indexFile = getSuiteIndexFile(); StringWriter out = new StringWriter(); out.write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"); out.write("<suite-index>"); //--- Log Manager --- out.flush(); getLogManager().saveToXML(out); //--- JobStatusSerializer --- out.flush(); getJobStatusStore().saveToXML(out); //--- Job Status --- writeJobId(out, statusTree, statusTree.getRoot()); out.write("</suite-index>"); out.flush(); // Using RandomAccessFile since evidence has shown it is better at // dealing with files/locks in a way that cause less/no errors. try (RandomAccessFile ras = new RandomAccessFile(indexFile, "rwd"); FileChannel channel = ras.getChannel(); FileLock lock = channel.lock()) { ras.writeUTF(out.toString()); } }
@Override public void run() { try { while(!terminate) { for (MutableJobStatus status : statuses) { status.setLastActivity( new Date(suite.getJobStatusStore().touch( suite.getId(), status.getJobId()))); } Sleeper.sleepMillis(HEARTBEAT_INTERVAL); } } catch (IOException e) { throw new JEFException("Cannot update status heartbeat.", e); } }
@Override protected void statusUpdated(MutableJobStatus status) { try { getJobStatusStore().write(getId(), status); } catch (IOException e) { throw new JEFException( "Cannot persist status update for job: " + status.getJobId(), e); } fire(jobLifeCycleListeners, "jobProgressed", status); IJobStatus parentStatus = jobSuiteStatusSnapshot.getParent(status); if (parentStatus != null) { IJobGroup jobGroup = (IJobGroup) jobs.get(parentStatus.getJobId()); if (jobGroup != null) { jobGroup.groupProgressed(status); } } } }, this);
getJobStatusStore().backup( getId(), jobStatus.getJobId(), backupDate);
status.getDuration().setEndTime(new Date()); try { getJobStatusStore().write(getId(), status); } catch (IOException e) { LOG.error("Cannot save final status.", e);