// XmlUtils.prettyPrint(runConf).toString());
DagEngine dagEngine = Services.get().get(DagEngineService.class).getDagEngine(user, authToken);
try {
boolean startJob = true;
Configuration conf = new XConfiguration(new StringReader(coordAction.getRunConf()));
SLAEventBean slaEvent = SLADbOperations.createStatusEvent(coordAction.getSlaXml(), coordAction.getId(), Status.STARTED,
SlaAppType.COORDINATOR_ACTION, log);
if(slaEvent != null) {
insertList.add(slaEvent);
}
// Normalize workflow appPath here;
JobUtils.normalizeAppPath(conf.get(OozieClient.USER_NAME), conf.get(OozieClient.GROUP_NAME), conf);
String wfId = dagEngine.submitJob(conf, startJob);
coordAction.setStatus(CoordinatorAction.Status.RUNNING);
coordAction.setExternalId(wfId);
coordAction.incrementAndGetPending();
//store.updateCoordinatorAction(coordAction);
JPAService jpaService = Services.get().get(JPAService.class);
if (jpaService != null) {
log.debug("Updating WF record for WFID :" + wfId + " with parent id: " + actionId);
WorkflowJobBean wfJob = jpaService.execute(new WorkflowJobGetJPAExecutor(wfId));
wfJob.setParentId(actionId);
wfJob.setLastModifiedTime(new Date());
updateList.add(wfJob);
updateList.add(coordAction);
try {
jpaService.execute(new BulkUpdateInsertForCoordActionStartJPAExecutor(updateList, insertList));
}
catch (JPAExecutorException je) {
throw new CommandException(je);
}
}
else {
log.error(ErrorCode.E0610);
}
makeFail = false;
}
catch (DagEngineException dee) {
errMsg = dee.getMessage();
errCode = dee.getErrorCode().toString();
log.warn("can not create DagEngine for submitting jobs", dee);
}
catch (CommandException ce) {
errMsg = ce.getMessage();
errCode = ce.getErrorCode().toString();
log.warn("command exception occured ", ce);
}
catch (java.io.IOException ioe) {
errMsg = ioe.getMessage();
errCode = "E1005";
log.warn("Configuration parse error. read from DB :" + coordAction.getRunConf(), ioe);
}
catch (Exception ex) {
errMsg = ex.getMessage();
errCode = "E1005";
log.warn("can not create DagEngine for submitting jobs", ex);
}
finally {
if (makeFail == true) { // No DB exception occurs
log.error("Failing the action " + coordAction.getId() + ". Because " + errCode + " : " + errMsg);
coordAction.setStatus(CoordinatorAction.Status.FAILED);
if (errMsg.length() > 254) { // Because table column size is 255
errMsg = errMsg.substring(0, 255);
}
coordAction.setErrorMessage(errMsg);
coordAction.setErrorCode(errCode);
updateList = new ArrayList<JsonBean>();
updateList.add(coordAction);
insertList = new ArrayList<JsonBean>();
SLAEventBean slaEvent = SLADbOperations.createStatusEvent(coordAction.getSlaXml(), coordAction.getId(), Status.FAILED,
SlaAppType.COORDINATOR_ACTION, log);
if(slaEvent != null) {
insertList.add(slaEvent); //Update SLA events
}
try {