Search in sources :

Example 71 with JPAExecutorException

use of org.apache.oozie.executor.jpa.JPAExecutorException in project oozie by apache.

the class CoordSubmitXCommand method storeToDB.

/**
 * Write a coordinator job into database
 *
 *@param appXML : Coordinator definition xml
 * @param eJob : XML element of job
 * @param coordJob : Coordinator job bean
 * @return Job id
 * @throws CommandException thrown if unable to save coordinator job to db
 */
protected String storeToDB(String appXML, Element eJob, CoordinatorJobBean coordJob) throws CommandException {
    String jobId = Services.get().get(UUIDService.class).generateId(ApplicationType.COORDINATOR);
    coordJob.setId(jobId);
    coordJob.setAppPath(conf.get(OozieClient.COORDINATOR_APP_PATH));
    coordJob.setCreatedTime(new Date());
    coordJob.setUser(conf.get(OozieClient.USER_NAME));
    String group = ConfigUtils.getWithDeprecatedCheck(conf, OozieClient.JOB_ACL, OozieClient.GROUP_NAME, null);
    coordJob.setGroup(group);
    coordJob.setConf(XmlUtils.prettyPrint(conf).toString());
    coordJob.setJobXml(XmlUtils.prettyPrint(eJob).toString());
    coordJob.setLastActionNumber(0);
    coordJob.setLastModifiedTime(new Date());
    if (!dryrun) {
        coordJob.setLastModifiedTime(new Date());
        try {
            CoordJobQueryExecutor.getInstance().insert(coordJob);
        } catch (JPAExecutorException jpaee) {
            coordJob.setId(null);
            coordJob.setStatus(CoordinatorJob.Status.FAILED);
            throw new CommandException(jpaee);
        }
    }
    return jobId;
}
Also used : JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) UUIDService(org.apache.oozie.service.UUIDService) CommandException(org.apache.oozie.command.CommandException) Date(java.util.Date)

Example 72 with JPAExecutorException

use of org.apache.oozie.executor.jpa.JPAExecutorException in project oozie by apache.

the class CoordUpdateXCommand method loadState.

@Override
protected void loadState() throws CommandException {
    super.loadState();
    jpaService = Services.get().get(JPAService.class);
    if (jpaService == null) {
        throw new CommandException(ErrorCode.E0610);
    }
    coordJob = new CoordinatorJobBean();
    try {
        oldCoordJob = CoordJobQueryExecutor.getInstance().get(CoordJobQuery.GET_COORD_JOB, jobId);
    } catch (JPAExecutorException e) {
        throw new CommandException(e);
    }
    LogUtils.setLogInfo(oldCoordJob);
    if (!isConfChange || StringUtils.isEmpty(conf.get(OozieClient.COORDINATOR_APP_PATH))) {
        try {
            XConfiguration jobConf = new XConfiguration(new StringReader(oldCoordJob.getConf()));
            if (!isConfChange) {
                conf = jobConf;
            } else {
                for (String bundleConfKey : bundleConfList) {
                    if (jobConf.get(bundleConfKey) != null) {
                        conf.set(bundleConfKey, jobConf.get(bundleConfKey));
                    }
                }
                if (StringUtils.isEmpty(conf.get(OozieClient.COORDINATOR_APP_PATH))) {
                    conf.set(OozieClient.COORDINATOR_APP_PATH, jobConf.get(OozieClient.COORDINATOR_APP_PATH));
                }
            }
        } catch (Exception e) {
            throw new CommandException(ErrorCode.E1023, e.getMessage(), e);
        }
    }
    coordJob.setConf(XmlUtils.prettyPrint(conf).toString());
    setJob(coordJob);
    LogUtils.setLogInfo(coordJob);
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) XConfiguration(org.apache.oozie.util.XConfiguration) StringReader(java.io.StringReader) CommandException(org.apache.oozie.command.CommandException) JPAService(org.apache.oozie.service.JPAService) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) IOException(java.io.IOException) CommandException(org.apache.oozie.command.CommandException)

Example 73 with JPAExecutorException

use of org.apache.oozie.executor.jpa.JPAExecutorException in project oozie by apache.

the class CoordUpdateXCommand method storeToDB.

@Override
protected String storeToDB(String xmlElement, Element eJob, CoordinatorJobBean coordJob) throws CommandException {
    check(oldCoordJob, coordJob);
    computeDiff(eJob);
    oldCoordJob.setAppPath(conf.get(OozieClient.COORDINATOR_APP_PATH));
    if (isConfChange) {
        oldCoordJob.setConf(XmlUtils.prettyPrint(conf).toString());
    }
    oldCoordJob.setMatThrottling(coordJob.getMatThrottling());
    oldCoordJob.setOrigJobXml(xmlElement);
    oldCoordJob.setConcurrency(coordJob.getConcurrency());
    oldCoordJob.setExecution(coordJob.getExecution());
    oldCoordJob.setTimeout(coordJob.getTimeout());
    oldCoordJob.setJobXml(XmlUtils.prettyPrint(eJob).toString());
    if (!dryrun) {
        oldCoordJob.setLastModifiedTime(new Date());
        // Should log the changes, this should be useful for debugging.
        LOG.info("Coord update changes : " + diff.toString());
        try {
            CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQuery.UPDATE_COORD_JOB, oldCoordJob);
        } catch (JPAExecutorException jpaee) {
            throw new CommandException(jpaee);
        }
    }
    return jobId;
}
Also used : JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) CommandException(org.apache.oozie.command.CommandException) Date(java.util.Date)

Example 74 with JPAExecutorException

use of org.apache.oozie.executor.jpa.JPAExecutorException in project oozie by apache.

the class CoordActionSkipXCommand method execute.

@Override
protected Void execute() throws CommandException {
    if (actionBean.getStatus() == CoordinatorAction.Status.WAITING || actionBean.getStatus() == CoordinatorAction.Status.READY) {
        LOG.info("Setting action [{0}] status to SKIPPED", actionBean.getId());
        actionBean.setStatus(CoordinatorAction.Status.SKIPPED);
        try {
            queue(new CoordActionNotificationXCommand(actionBean), 100);
            actionBean.setLastModifiedTime(new Date());
            CoordActionQueryExecutor.getInstance().executeUpdate(CoordActionQuery.UPDATE_COORD_ACTION_STATUS_PENDING_TIME, actionBean);
            if (EventHandlerService.isEnabled()) {
                generateEvent(actionBean, user, appName, null);
            }
        } catch (JPAExecutorException e) {
            throw new CommandException(e);
        }
    }
    return null;
}
Also used : JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) CommandException(org.apache.oozie.command.CommandException) Date(java.util.Date)

Example 75 with JPAExecutorException

use of org.apache.oozie.executor.jpa.JPAExecutorException in project oozie by apache.

the class CoordActionTimeOutXCommand method loadState.

/* (non-Javadoc)
     * @see org.apache.oozie.command.XCommand#loadState()
     */
@Override
protected void loadState() throws CommandException {
    jpaService = Services.get().get(JPAService.class);
    if (jpaService == null) {
        throw new CommandException(ErrorCode.E0610);
    }
    try {
        actionBean = jpaService.execute(new CoordActionGetForTimeoutJPAExecutor(actionBean.getId()));
    } catch (JPAExecutorException e) {
        throw new CommandException(e);
    }
    LogUtils.setLogInfo(actionBean);
}
Also used : JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) CoordActionGetForTimeoutJPAExecutor(org.apache.oozie.executor.jpa.CoordActionGetForTimeoutJPAExecutor) CommandException(org.apache.oozie.command.CommandException) JPAService(org.apache.oozie.service.JPAService)

Aggregations

JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)195 JPAService (org.apache.oozie.service.JPAService)137 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)65 CommandException (org.apache.oozie.command.CommandException)63 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)55 Date (java.util.Date)53 CoordJobGetJPAExecutor (org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor)49 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)45 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)43 CoordActionGetJPAExecutor (org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor)37 WorkflowJobGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor)33 WorkflowActionGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor)31 IOException (java.io.IOException)26 BundleJobBean (org.apache.oozie.BundleJobBean)24 CoordJobInsertJPAExecutor (org.apache.oozie.executor.jpa.CoordJobInsertJPAExecutor)19 BundleActionBean (org.apache.oozie.BundleActionBean)18 Configuration (org.apache.hadoop.conf.Configuration)15 BundleJobGetJPAExecutor (org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor)15 BundleActionGetJPAExecutor (org.apache.oozie.executor.jpa.BundleActionGetJPAExecutor)14 XConfiguration (org.apache.oozie.util.XConfiguration)14