Search in sources :

Example 91 with CommandException

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

Example 92 with CommandException

use of org.apache.oozie.command.CommandException in project oozie by apache.

the class BundleStatusUpdateXCommand method execute.

@Override
protected Void execute() throws CommandException {
    try {
        LOG.debug("STARTED BundleStatusUpdateXCommand with bundle id : " + coordjob.getBundleId() + " coord job ID: " + coordjob.getId() + " coord Status " + coordjob.getStatus());
        Job.Status coordCurrentStatus = coordjob.getStatus();
        // should not be changed.
        if (bundleaction.getCoordId() != null || !bundleaction.isTerminalStatus() || (bundleaction.getCoordId() != null && bundleaction.isTerminalStatus() && coordjob.isTerminalStatus())) {
            bundleaction.setStatus(coordCurrentStatus);
        }
        if (bundleaction.isPending() && !ignorePending) {
            bundleaction.decrementAndGetPending();
        }
        // TODO - Uncomment this when bottom up rerun can change terminal state
        /*BundleJobBean bundleJob = jpaService.execute(new BundleJobGetJPAExecutor(bundleaction.getBundleId()));
            if (!bundleJob.isPending()) {
                bundleJob.setPending();
                jpaService.execute(new BundleJobUpdateJPAExecutor(bundleJob));
                LOG.info("Updated bundle job [{0}] pending to true", bundleaction.getBundleId());
            }*/
        bundleaction.setLastModifiedTime(new Date());
        bundleaction.setCoordId(coordjob.getId());
        BundleActionQueryExecutor.getInstance().executeUpdate(BundleActionQuery.UPDATE_BUNDLE_ACTION_STATUS_PENDING_MODTIME_COORDID, bundleaction);
        if (bundleaction.getCoordId() != null) {
            LOG.info("Updated bundle action [{0}] from prev status [{1}] to current coord status [{2}], " + "and new bundle action pending [{3}]", bundleaction.getBundleActionId(), bundleaction.getStatus(), coordCurrentStatus, bundleaction.getPending());
        } else {
            LOG.info("Updated Bundle action [{0}], status = [{1}], pending = [{2}]", bundleaction.getBundleActionId(), bundleaction.getStatus(), bundleaction.getPending());
        }
        LOG.debug("ENDED BundleStatusUpdateXCommand with bundle id : " + coordjob.getBundleId() + " coord job ID: " + coordjob.getId() + " coord Status " + coordjob.getStatus());
    } catch (Exception ex) {
        throw new CommandException(ErrorCode.E1309, bundleaction.getBundleId(), bundleaction.getCoordName());
    }
    return null;
}
Also used : CommandException(org.apache.oozie.command.CommandException) CoordinatorJob(org.apache.oozie.client.CoordinatorJob) Job(org.apache.oozie.client.Job) Date(java.util.Date) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) XException(org.apache.oozie.XException) CommandException(org.apache.oozie.command.CommandException) PreconditionException(org.apache.oozie.command.PreconditionException)

Example 93 with CommandException

use of org.apache.oozie.command.CommandException in project oozie by apache.

the class CoordWfActionInfoXCommand method execute.

@Override
protected List<CoordinatorWfActionBean> execute() throws CommandException {
    List<CoordinatorWfActionBean> coordWfActions = new ArrayList<CoordinatorWfActionBean>();
    for (CoordinatorActionBean coordAction : coordActions) {
        String wfId = coordAction.getExternalId();
        String nullReason = null;
        WorkflowActionBean wfAction = null;
        if (wfId != null) {
            String wfActionId = wfId + "@" + actionName;
            try {
                wfAction = jpaService.execute(new WorkflowActionGetJPAExecutor(wfActionId, true));
                if (wfAction == null) {
                    nullReason = CoordinatorWfAction.NullReason.ACTION_NULL.getNullReason(actionName, wfId);
                }
            } catch (JPAExecutorException ex) {
                throw new CommandException(ex);
            }
        } else {
            nullReason = CoordinatorWfAction.NullReason.PARENT_NULL.getNullReason();
            LOG.warn(nullReason);
            wfAction = null;
        }
        int actionNumber = coordAction.getActionNumber();
        CoordinatorWfActionBean coordWfAction = new CoordinatorWfActionBean(actionNumber, wfAction, nullReason);
        coordWfActions.add(coordWfAction);
    }
    return coordWfActions;
}
Also used : JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) ArrayList(java.util.ArrayList) WorkflowActionGetJPAExecutor(org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor) CommandException(org.apache.oozie.command.CommandException) WorkflowActionBean(org.apache.oozie.WorkflowActionBean) CoordinatorWfActionBean(org.apache.oozie.CoordinatorWfActionBean)

Example 94 with CommandException

use of org.apache.oozie.command.CommandException in project oozie by apache.

the class SLAEventsXCommand method execute.

@Override
protected List<SLAEventBean> execute() throws CommandException {
    try {
        JPAService jpaService = Services.get().get(JPAService.class);
        List<SLAEventBean> slaEventList = null;
        long[] lastSeqId = new long[1];
        if (jpaService != null) {
            slaEventList = jpaService.execute(new SLAEventsGetForFilterJPAExecutor(seqId, maxNoEvents, filter, lastSeqId));
        } else {
            LOG.error(ErrorCode.E0610);
        }
        setLastSeqId(lastSeqId[0]);
        return slaEventList;
    } catch (XException ex) {
        throw new CommandException(ex);
    }
}
Also used : XException(org.apache.oozie.XException) SLAEventsGetForFilterJPAExecutor(org.apache.oozie.executor.jpa.SLAEventsGetForFilterJPAExecutor) CommandException(org.apache.oozie.command.CommandException) JPAService(org.apache.oozie.service.JPAService) SLAEventBean(org.apache.oozie.SLAEventBean)

Example 95 with CommandException

use of org.apache.oozie.command.CommandException in project oozie by apache.

the class SLACoordActionJobEventXCommand method loadState.

@Override
protected void loadState() throws CommandException {
    try {
        ca = CoordActionQueryExecutor.getInstance().get(CoordActionQuery.GET_COORD_ACTION_FOR_SLA, slaCalc.getId());
        if (ca.getExternalId() != null) {
            wf = WorkflowJobQueryExecutor.getInstance().get(WorkflowJobQuery.GET_WORKFLOW_FOR_SLA, ca.getExternalId());
        }
        LogUtils.setLogInfo(ca);
    } catch (JPAExecutorException e) {
        throw new CommandException(e);
    }
}
Also used : JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) CommandException(org.apache.oozie.command.CommandException)

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