Search in sources :

Example 6 with PreconditionException

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

the class BundleSubmitXCommand method eagerVerifyPrecondition.

@Override
protected void eagerVerifyPrecondition() throws CommandException, PreconditionException {
    try {
        mergeDefaultConfig();
        String appXml = readAndValidateXml();
        bundleBean.setOrigJobXml(appXml);
        LOG.debug("jobXml after initial validation " + XmlUtils.prettyPrint(appXml).toString());
    } catch (BundleJobException ex) {
        LOG.warn("BundleJobException:  ", ex);
        throw new CommandException(ex);
    } catch (IllegalArgumentException iex) {
        LOG.warn("IllegalArgumentException:  ", iex);
        throw new CommandException(ErrorCode.E1310, iex.getMessage(), iex);
    } catch (Exception ex) {
        LOG.warn("Exception:  ", ex);
        throw new CommandException(ErrorCode.E1310, ex.getMessage(), ex);
    }
}
Also used : CommandException(org.apache.oozie.command.CommandException) URISyntaxException(java.net.URISyntaxException) JDOMException(org.jdom.JDOMException) HadoopAccessorException(org.apache.oozie.service.HadoopAccessorException) CommandException(org.apache.oozie.command.CommandException) SAXException(org.xml.sax.SAXException) PreconditionException(org.apache.oozie.command.PreconditionException) IOException(java.io.IOException)

Example 7 with PreconditionException

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

the class BundleStatusUpdateXCommand method verifyPrecondition.

@Override
protected void verifyPrecondition() throws CommandException, PreconditionException {
    if (bundleaction.getStatusStr().compareToIgnoreCase(prevStatus.toString()) != 0 && bundleaction.getCoordId() != null) {
        // to allow recovery service to pick and kill the coord job
        if (bundleaction.isTerminalStatus() && coordjob.isTerminalStatus()) {
            LOG.info("Bundle action [{0}] status [{1}] is different from prev coord status [{2}], " + "but coord job is currently in terminal state = [{3}]", bundleaction.getBundleActionId(), bundleaction.getStatusStr(), prevStatus.toString(), coordjob.getStatus());
            return;
        }
        if (bundleaction.isPending() && coordjob.getStatus().equals(bundleaction.getStatus()) && !ignorePending) {
            bundleaction.decrementAndGetPending();
        }
        bundleaction.setLastModifiedTime(new Date());
        try {
            BundleActionQueryExecutor.getInstance().executeUpdate(BundleActionQuery.UPDATE_BUNDLE_ACTION_PENDING_MODTIME, bundleaction);
        } catch (JPAExecutorException je) {
            throw new CommandException(je);
        }
        LOG.info("Bundle action [{0}] status [{1}] is different from prev coord status [{2}] and current coord" + " status [{3}], decrement pending so new pending = [{4}]", bundleaction.getBundleActionId(), bundleaction.getStatusStr(), prevStatus.toString(), coordjob.getStatusStr(), bundleaction.getPending());
        throw new PreconditionException(ErrorCode.E1308, bundleaction.getStatusStr(), prevStatus.toString());
    } else if (bundleaction.getStatusStr().compareToIgnoreCase(prevStatus.toString()) != 0) {
        LOG.info("Bundle action [{0}] status [{1}] is different from prev coord status [{2}], " + "pending = [{3}] and bundle not yet updated with coord-id", bundleaction.getBundleActionId(), bundleaction.getStatusStr(), prevStatus.toString(), bundleaction.getPending());
    }
}
Also used : JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) CommandException(org.apache.oozie.command.CommandException) Date(java.util.Date) PreconditionException(org.apache.oozie.command.PreconditionException)

Aggregations

PreconditionException (org.apache.oozie.command.PreconditionException)7 CommandException (org.apache.oozie.command.CommandException)4 Date (java.util.Date)3 Timestamp (java.sql.Timestamp)2 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)2 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)2 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 CoordinatorAction (org.apache.oozie.client.CoordinatorAction)1 XCommand (org.apache.oozie.command.XCommand)1 CoordActionGetJPAExecutor (org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor)1 CoordJobGetJPAExecutor (org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor)1 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)1 HadoopAccessorException (org.apache.oozie.service.HadoopAccessorException)1 JPAService (org.apache.oozie.service.JPAService)1 StatusTransitService (org.apache.oozie.service.StatusTransitService)1 JDOMException (org.jdom.JDOMException)1 SAXException (org.xml.sax.SAXException)1