use of org.apache.oozie.XException in project oozie by apache.
the class CoordSLAAlertsXCommand method updateJobSLA.
/**
* Update job sla.
*
* @param newParams the new params
* @throws CommandException the command exception
*/
protected void updateJobSLA(Map<String, String> newParams) throws CommandException {
try {
CoordinatorJobBean job = CoordJobQueryExecutor.getInstance().get(CoordJobQueryExecutor.CoordJobQuery.GET_COORD_JOB_XML, getJobId());
Element eAction;
try {
eAction = XmlUtils.parseXml(job.getJobXml());
} catch (JDOMException e) {
throw new CommandException(ErrorCode.E1005, e.getMessage(), e);
}
Element eSla = eAction.getChild("action", eAction.getNamespace()).getChild("info", eAction.getNamespace("sla"));
if (newParams != null) {
if (newParams.get(RestConstants.SLA_NOMINAL_TIME) != null) {
updateSlaTagElement(eSla, SLAOperations.NOMINAL_TIME, newParams.get(RestConstants.SLA_NOMINAL_TIME));
}
if (newParams.get(RestConstants.SLA_SHOULD_START) != null) {
updateSlaTagElement(eSla, SLAOperations.SHOULD_START, newParams.get(RestConstants.SLA_SHOULD_START));
}
if (newParams.get(RestConstants.SLA_SHOULD_END) != null) {
updateSlaTagElement(eSla, SLAOperations.SHOULD_END, newParams.get(RestConstants.SLA_SHOULD_END));
}
if (newParams.get(RestConstants.SLA_MAX_DURATION) != null) {
updateSlaTagElement(eSla, SLAOperations.MAX_DURATION, newParams.get(RestConstants.SLA_MAX_DURATION));
}
}
String actualXml = XmlUtils.prettyPrint(eAction).toString();
job.setJobXml(actualXml);
job.setId(getJobId());
CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQueryExecutor.CoordJobQuery.UPDATE_COORD_JOB_XML, job);
} catch (XException e) {
throw new CommandException(e);
}
}
use of org.apache.oozie.XException in project oozie by apache.
the class ActionEndXCommand method loadState.
@Override
protected void loadState() throws CommandException {
try {
jpaService = Services.get().get(JPAService.class);
if (jpaService != null) {
this.wfJob = WorkflowJobQueryExecutor.getInstance().get(WorkflowJobQuery.GET_WORKFLOW_ACTION_OP, jobId);
this.wfAction = WorkflowActionQueryExecutor.getInstance().get(WorkflowActionQuery.GET_ACTION_END, actionId);
LogUtils.setLogInfo(wfJob);
LogUtils.setLogInfo(wfAction);
} else {
throw new CommandException(ErrorCode.E0610);
}
} catch (XException ex) {
throw new CommandException(ex);
}
}
use of org.apache.oozie.XException in project oozie by apache.
the class ActionStartXCommand method loadState.
@Override
protected void loadState() throws CommandException {
try {
jpaService = Services.get().get(JPAService.class);
if (jpaService != null) {
if (wfJob == null) {
this.wfJob = WorkflowJobQueryExecutor.getInstance().get(WorkflowJobQuery.GET_WORKFLOW, jobId);
}
this.wfAction = WorkflowActionQueryExecutor.getInstance().get(WorkflowActionQuery.GET_ACTION, actionId);
LogUtils.setLogInfo(wfJob);
LogUtils.setLogInfo(wfAction);
} else {
throw new CommandException(ErrorCode.E0610);
}
} catch (XException ex) {
throw new CommandException(ex);
}
}
use of org.apache.oozie.XException in project oozie by apache.
the class BundleJobsXCommand method execute.
/* (non-Javadoc)
* @see org.apache.oozie.command.XCommand#execute()
*/
@Override
protected BundleJobInfo execute() throws CommandException {
try {
JPAService jpaService = Services.get().get(JPAService.class);
BundleJobInfo bundleInfo = null;
if (jpaService != null) {
bundleInfo = jpaService.execute(new BundleJobInfoGetJPAExecutor(filter, start, len));
} else {
LOG.error(ErrorCode.E0610);
}
return bundleInfo;
} catch (XException ex) {
throw new CommandException(ex);
}
}
use of org.apache.oozie.XException in project oozie by apache.
the class BundleStartXCommand method loadState.
@Override
public void loadState() throws CommandException {
try {
this.bundleJob = BundleJobQueryExecutor.getInstance().get(BundleJobQuery.GET_BUNDLE_JOB, jobId);
LogUtils.setLogInfo(bundleJob);
super.setJob(bundleJob);
} catch (XException ex) {
throw new CommandException(ex);
}
}
Aggregations