Search in sources :

Example 1 with CoordChangeXCommand

use of org.apache.oozie.command.coord.CoordChangeXCommand in project oozie by apache.

the class BundleJobChangeXCommand method execute.

/* (non-Javadoc)
     * @see org.apache.oozie.command.XCommand#execute()
     */
@Override
protected Void execute() throws CommandException {
    StringBuffer changeReport = new StringBuffer();
    try {
        if (isChangePauseTime || isChangeEndTime) {
            if (isChangePauseTime) {
                bundleJob.setPauseTime(newPauseTime);
            } else if (isChangeEndTime) {
                bundleJob.setEndTime(newEndTime);
                if (bundleJob.getStatus() == Job.Status.SUCCEEDED) {
                    bundleJob.setStatus(Job.Status.RUNNING);
                }
                if (bundleJob.getStatus() == Job.Status.DONEWITHERROR || bundleJob.getStatus() == Job.Status.FAILED) {
                    bundleJob.setStatus(StatusUtils.getStatusIfBackwardSupportTrue(Job.Status.RUNNINGWITHERROR));
                }
            }
            for (BundleActionBean action : this.bundleActions) {
                // queue coord change commands;
                if (action.getStatus() != Job.Status.KILLED && action.getCoordId() != null) {
                    try {
                        new CoordChangeXCommand(action.getCoordId(), changeValue).call();
                    } catch (Exception e) {
                        String errorMsg = action.getCoordId() + " : " + e.getMessage();
                        LOG.info("Change command failed " + errorMsg);
                        changeReport.append("[ ").append(errorMsg).append(" ]");
                    }
                } else {
                    String errorMsg = action.getCoordId() + " : Coord is in killed state";
                    LOG.info("Change command failed " + errorMsg);
                    changeReport.append("[ ").append(errorMsg).append(" ]");
                }
            }
            updateList.add(new UpdateEntry<BundleJobQuery>(BundleJobQuery.UPDATE_BUNDLE_JOB_STATUS_PAUSE_ENDTIME, bundleJob));
            BatchQueryExecutor.getInstance().executeBatchInsertUpdateDelete(null, updateList, null);
        }
        if (!changeReport.toString().isEmpty()) {
            throw new CommandException(ErrorCode.E1320, changeReport.toString());
        }
        return null;
    } catch (XException ex) {
        throw new CommandException(ex);
    }
}
Also used : BundleJobQuery(org.apache.oozie.executor.jpa.BundleJobQueryExecutor.BundleJobQuery) XException(org.apache.oozie.XException) CommandException(org.apache.oozie.command.CommandException) BundleActionBean(org.apache.oozie.BundleActionBean) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) XException(org.apache.oozie.XException) CommandException(org.apache.oozie.command.CommandException) PreconditionException(org.apache.oozie.command.PreconditionException) CoordChangeXCommand(org.apache.oozie.command.coord.CoordChangeXCommand)

Example 2 with CoordChangeXCommand

use of org.apache.oozie.command.coord.CoordChangeXCommand in project oozie by apache.

the class CoordinatorEngine method change.

/* (non-Javadoc)
     * @see org.apache.oozie.BaseEngine#change(java.lang.String, java.lang.String)
     */
@Override
public void change(String jobId, String changeValue) throws CoordinatorEngineException {
    try {
        new CoordChangeXCommand(jobId, changeValue).call();
        LOG.info("User " + user + " changed the Coordinator job [" + jobId + "] to " + changeValue);
    } catch (CommandException e) {
        throw new CoordinatorEngineException(e);
    }
}
Also used : CommandException(org.apache.oozie.command.CommandException) CoordChangeXCommand(org.apache.oozie.command.coord.CoordChangeXCommand)

Aggregations

CommandException (org.apache.oozie.command.CommandException)2 CoordChangeXCommand (org.apache.oozie.command.coord.CoordChangeXCommand)2 BundleActionBean (org.apache.oozie.BundleActionBean)1 XException (org.apache.oozie.XException)1 PreconditionException (org.apache.oozie.command.PreconditionException)1 BundleJobQuery (org.apache.oozie.executor.jpa.BundleJobQueryExecutor.BundleJobQuery)1 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)1