use of org.apache.oozie.command.CommandException 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.command.CommandException in project oozie by apache.
the class ActionXCommand method handleNonTransient.
/**
* Takes care of non transient failures. The job is suspended, and the state of the action is changed to *MANUAL and
* set pending flag of action to false
*
* @param context the execution context.
* @param executor the executor instance being used.
* @param status the status to be set for the action.
* @throws CommandException thrown if unable to suspend job
*/
protected void handleNonTransient(ActionExecutor.Context context, ActionExecutor executor, WorkflowAction.Status status) throws CommandException {
ActionExecutorContext aContext = (ActionExecutorContext) context;
WorkflowActionBean action = (WorkflowActionBean) aContext.getAction();
incrActionErrorCounter(action.getType(), "nontransient", 1);
WorkflowJobBean workflow = (WorkflowJobBean) context.getWorkflow();
String id = workflow.getId();
action.setStatus(status);
action.resetPendingOnly();
LOG.warn("Suspending Workflow Job id=" + id);
try {
SuspendXCommand.suspendJob(Services.get().get(JPAService.class), workflow, id, action.getId(), null);
} catch (Exception e) {
throw new CommandException(ErrorCode.E0727, id, e.getMessage());
} finally {
updateParentIfNecessary(workflow, 3);
}
}
use of org.apache.oozie.command.CommandException 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.command.CommandException in project oozie by apache.
the class BundleStartXCommand method isEnabled.
/**
* Checks whether the coordinator is enabled
*
* @param coordElem
* @param coordConf
* @return true if coordinator is enabled, otherwise false.
* @throws CommandException
*/
private boolean isEnabled(Element coordElem, Configuration coordConf) throws CommandException {
Attribute enabled = coordElem.getAttribute("enabled");
if (enabled == null) {
// default is true
return true;
}
String isEnabled = enabled.getValue();
try {
isEnabled = ELUtils.resolveAppName(isEnabled, coordConf);
} catch (Exception e) {
throw new CommandException(ErrorCode.E1321, e.getMessage(), e);
}
return Boolean.parseBoolean(isEnabled);
}
use of org.apache.oozie.command.CommandException in project oozie by apache.
the class BundleStartXCommand method startCoordJobs.
/**
* Start Coord Jobs
*
* @throws CommandException thrown if failed to start coord jobs
*/
@SuppressWarnings("unchecked")
private void startCoordJobs() throws CommandException {
if (bundleJob != null) {
try {
Element bAppXml = XmlUtils.parseXml(bundleJob.getJobXml());
List<Element> coordElems = bAppXml.getChildren("coordinator", bAppXml.getNamespace());
for (Element coordElem : coordElems) {
Attribute name = coordElem.getAttribute("name");
Configuration coordConf = mergeConfig(coordElem);
coordConf.set(OozieClient.BUNDLE_ID, jobId);
if (OozieJobInfo.isJobInfoEnabled()) {
coordConf.set(OozieJobInfo.BUNDLE_NAME, bundleJob.getAppName());
}
// skip coord job if it is not enabled
if (!isEnabled(coordElem, coordConf)) {
continue;
}
String coordName = name.getValue();
try {
coordName = ELUtils.resolveAppName(coordName, coordConf);
} catch (Exception e) {
throw new CommandException(ErrorCode.E1321, e.getMessage(), e);
}
queue(new BundleCoordSubmitXCommand(coordConf, bundleJob.getId(), name.getValue()));
}
updateBundleAction();
} catch (JDOMException jex) {
throw new CommandException(ErrorCode.E1301, jex.getMessage(), jex);
} catch (JPAExecutorException je) {
throw new CommandException(je);
}
} else {
throw new CommandException(ErrorCode.E0604, jobId);
}
}
Aggregations