Search in sources :

Example 86 with CommandException

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);
    }
}
Also used : XException(org.apache.oozie.XException) CommandException(org.apache.oozie.command.CommandException) JPAService(org.apache.oozie.service.JPAService)

Example 87 with CommandException

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);
    }
}
Also used : CommandException(org.apache.oozie.command.CommandException) JPAService(org.apache.oozie.service.JPAService) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) WorkflowActionBean(org.apache.oozie.WorkflowActionBean) URISyntaxException(java.net.URISyntaxException) HadoopAccessorException(org.apache.oozie.service.HadoopAccessorException) IOException(java.io.IOException) WorkflowException(org.apache.oozie.workflow.WorkflowException) CommandException(org.apache.oozie.command.CommandException)

Example 88 with CommandException

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);
    }
}
Also used : XException(org.apache.oozie.XException) BundleJobInfo(org.apache.oozie.BundleJobInfo) CommandException(org.apache.oozie.command.CommandException) JPAService(org.apache.oozie.service.JPAService) BundleJobInfoGetJPAExecutor(org.apache.oozie.executor.jpa.BundleJobInfoGetJPAExecutor)

Example 89 with CommandException

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);
}
Also used : Attribute(org.jdom.Attribute) CommandException(org.apache.oozie.command.CommandException) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) JDOMException(org.jdom.JDOMException) IOException(java.io.IOException) XException(org.apache.oozie.XException) CommandException(org.apache.oozie.command.CommandException) PreconditionException(org.apache.oozie.command.PreconditionException)

Example 90 with CommandException

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);
    }
}
Also used : JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) XConfiguration(org.apache.oozie.util.XConfiguration) Configuration(org.apache.hadoop.conf.Configuration) Attribute(org.jdom.Attribute) Element(org.jdom.Element) CommandException(org.apache.oozie.command.CommandException) JDOMException(org.jdom.JDOMException) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) JDOMException(org.jdom.JDOMException) IOException(java.io.IOException) XException(org.apache.oozie.XException) CommandException(org.apache.oozie.command.CommandException) PreconditionException(org.apache.oozie.command.PreconditionException)

Aggregations

CommandException (org.apache.oozie.command.CommandException)225 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)85 XConfiguration (org.apache.oozie.util.XConfiguration)62 Date (java.util.Date)59 IOException (java.io.IOException)57 Configuration (org.apache.hadoop.conf.Configuration)56 JPAService (org.apache.oozie.service.JPAService)56 XException (org.apache.oozie.XException)42 PreconditionException (org.apache.oozie.command.PreconditionException)35 ArrayList (java.util.ArrayList)26 StringReader (java.io.StringReader)25 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)24 List (java.util.List)23 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)23 Element (org.jdom.Element)23 JDOMException (org.jdom.JDOMException)20 File (java.io.File)16 HadoopAccessorException (org.apache.oozie.service.HadoopAccessorException)16 WorkflowException (org.apache.oozie.workflow.WorkflowException)16 URISyntaxException (java.net.URISyntaxException)14