fail("Job ID " + jobId + " was not stored properly in db");
}
}
private void addRecordToJobTable(String jobId, Date start, Date end) throws StoreException {
CoordinatorStore store = new CoordinatorStore(false);
CoordinatorJobBean coordJob = new CoordinatorJobBean();
coordJob.setId(jobId);
coordJob.setAppName("testApp");
coordJob.setAppPath("testAppPath");
coordJob.setStatus(CoordinatorJob.Status.PREP);
coordJob.setCreatedTime(new Date()); // TODO: Do we need that?
coordJob.setLastModifiedTime(new Date());
coordJob.setUser("testUser");
coordJob.setGroup("testGroup");
String confStr = "<configuration></configuration>";
coordJob.setConf(confStr);
String startDateStr = null, endDateStr = null;
try {
startDateStr = DateUtils.formatDateUTC(start);
endDateStr = DateUtils.formatDateUTC(end);
}
catch (Exception ex) {
ex.printStackTrace();
fail("Could not format dates");
}
String appXml = "<coordinator-app xmlns='uri:oozie:coordinator:0.1' name='NAME' frequency=\"1\" start='" + startDateStr + "' end='" + endDateStr + "'";
appXml += "<controls>";
appXml += "<timeout>10</timeout>";
appXml += "<concurrency>2</concurrency>";
appXml += "<execution>LIFO</execution>";
appXml += "</controls>";
appXml += "<action>";
appXml += "<workflow>";
appXml += "<app-path>hdfs:///tmp/workflows/</app-path>";
appXml += "</workflow>";
appXml += "</action>";
appXml += "</coordinator-app>";
coordJob.setJobXml(appXml);
coordJob.setLastActionNumber(0);
coordJob.setFrequency(1);
try {
coordJob.setStartTime(start);
coordJob.setEndTime(end);
}
catch (Exception e) {
e.printStackTrace();
fail("Could not set Date/time");
}
try {
store.beginTrx();
store.insertCoordinatorJob(coordJob);
store.commitTrx();
}
catch (StoreException se) {
se.printStackTrace();
store.rollbackTrx();
fail("Unable to insert the test job record to table");
throw se;
}
finally {
store.closeTrx();
}
}