use of org.apache.oozie.executor.jpa.JPAExecutorException in project oozie by apache.
the class CoordSubmitXCommand method storeToDB.
/**
* Write a coordinator job into database
*
*@param appXML : Coordinator definition xml
* @param eJob : XML element of job
* @param coordJob : Coordinator job bean
* @return Job id
* @throws CommandException thrown if unable to save coordinator job to db
*/
protected String storeToDB(String appXML, Element eJob, CoordinatorJobBean coordJob) throws CommandException {
String jobId = Services.get().get(UUIDService.class).generateId(ApplicationType.COORDINATOR);
coordJob.setId(jobId);
coordJob.setAppPath(conf.get(OozieClient.COORDINATOR_APP_PATH));
coordJob.setCreatedTime(new Date());
coordJob.setUser(conf.get(OozieClient.USER_NAME));
String group = ConfigUtils.getWithDeprecatedCheck(conf, OozieClient.JOB_ACL, OozieClient.GROUP_NAME, null);
coordJob.setGroup(group);
coordJob.setConf(XmlUtils.prettyPrint(conf).toString());
coordJob.setJobXml(XmlUtils.prettyPrint(eJob).toString());
coordJob.setLastActionNumber(0);
coordJob.setLastModifiedTime(new Date());
if (!dryrun) {
coordJob.setLastModifiedTime(new Date());
try {
CoordJobQueryExecutor.getInstance().insert(coordJob);
} catch (JPAExecutorException jpaee) {
coordJob.setId(null);
coordJob.setStatus(CoordinatorJob.Status.FAILED);
throw new CommandException(jpaee);
}
}
return jobId;
}
use of org.apache.oozie.executor.jpa.JPAExecutorException in project oozie by apache.
the class CoordUpdateXCommand method loadState.
@Override
protected void loadState() throws CommandException {
super.loadState();
jpaService = Services.get().get(JPAService.class);
if (jpaService == null) {
throw new CommandException(ErrorCode.E0610);
}
coordJob = new CoordinatorJobBean();
try {
oldCoordJob = CoordJobQueryExecutor.getInstance().get(CoordJobQuery.GET_COORD_JOB, jobId);
} catch (JPAExecutorException e) {
throw new CommandException(e);
}
LogUtils.setLogInfo(oldCoordJob);
if (!isConfChange || StringUtils.isEmpty(conf.get(OozieClient.COORDINATOR_APP_PATH))) {
try {
XConfiguration jobConf = new XConfiguration(new StringReader(oldCoordJob.getConf()));
if (!isConfChange) {
conf = jobConf;
} else {
for (String bundleConfKey : bundleConfList) {
if (jobConf.get(bundleConfKey) != null) {
conf.set(bundleConfKey, jobConf.get(bundleConfKey));
}
}
if (StringUtils.isEmpty(conf.get(OozieClient.COORDINATOR_APP_PATH))) {
conf.set(OozieClient.COORDINATOR_APP_PATH, jobConf.get(OozieClient.COORDINATOR_APP_PATH));
}
}
} catch (Exception e) {
throw new CommandException(ErrorCode.E1023, e.getMessage(), e);
}
}
coordJob.setConf(XmlUtils.prettyPrint(conf).toString());
setJob(coordJob);
LogUtils.setLogInfo(coordJob);
}
use of org.apache.oozie.executor.jpa.JPAExecutorException in project oozie by apache.
the class CoordUpdateXCommand method storeToDB.
@Override
protected String storeToDB(String xmlElement, Element eJob, CoordinatorJobBean coordJob) throws CommandException {
check(oldCoordJob, coordJob);
computeDiff(eJob);
oldCoordJob.setAppPath(conf.get(OozieClient.COORDINATOR_APP_PATH));
if (isConfChange) {
oldCoordJob.setConf(XmlUtils.prettyPrint(conf).toString());
}
oldCoordJob.setMatThrottling(coordJob.getMatThrottling());
oldCoordJob.setOrigJobXml(xmlElement);
oldCoordJob.setConcurrency(coordJob.getConcurrency());
oldCoordJob.setExecution(coordJob.getExecution());
oldCoordJob.setTimeout(coordJob.getTimeout());
oldCoordJob.setJobXml(XmlUtils.prettyPrint(eJob).toString());
if (!dryrun) {
oldCoordJob.setLastModifiedTime(new Date());
// Should log the changes, this should be useful for debugging.
LOG.info("Coord update changes : " + diff.toString());
try {
CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQuery.UPDATE_COORD_JOB, oldCoordJob);
} catch (JPAExecutorException jpaee) {
throw new CommandException(jpaee);
}
}
return jobId;
}
use of org.apache.oozie.executor.jpa.JPAExecutorException in project oozie by apache.
the class CoordActionSkipXCommand method execute.
@Override
protected Void execute() throws CommandException {
if (actionBean.getStatus() == CoordinatorAction.Status.WAITING || actionBean.getStatus() == CoordinatorAction.Status.READY) {
LOG.info("Setting action [{0}] status to SKIPPED", actionBean.getId());
actionBean.setStatus(CoordinatorAction.Status.SKIPPED);
try {
queue(new CoordActionNotificationXCommand(actionBean), 100);
actionBean.setLastModifiedTime(new Date());
CoordActionQueryExecutor.getInstance().executeUpdate(CoordActionQuery.UPDATE_COORD_ACTION_STATUS_PENDING_TIME, actionBean);
if (EventHandlerService.isEnabled()) {
generateEvent(actionBean, user, appName, null);
}
} catch (JPAExecutorException e) {
throw new CommandException(e);
}
}
return null;
}
use of org.apache.oozie.executor.jpa.JPAExecutorException in project oozie by apache.
the class CoordActionTimeOutXCommand method loadState.
/* (non-Javadoc)
* @see org.apache.oozie.command.XCommand#loadState()
*/
@Override
protected void loadState() throws CommandException {
jpaService = Services.get().get(JPAService.class);
if (jpaService == null) {
throw new CommandException(ErrorCode.E0610);
}
try {
actionBean = jpaService.execute(new CoordActionGetForTimeoutJPAExecutor(actionBean.getId()));
} catch (JPAExecutorException e) {
throw new CommandException(e);
}
LogUtils.setLogInfo(actionBean);
}
Aggregations