Search in sources :

Example 6 with BundleStatusUpdateXCommand

use of org.apache.oozie.command.bundle.BundleStatusUpdateXCommand in project oozie by apache.

the class CoordUnpauseXCommand method notifyParent.

/*
     * (non-Javadoc)
     *
     * @see org.apache.oozie.command.TransitionXCommand#notifyParent()
     */
@Override
public void notifyParent() throws CommandException {
    // update bundle action
    if (coordJob.getBundleId() != null) {
        BundleStatusUpdateXCommand bundleStatusUpdate = new BundleStatusUpdateXCommand(coordJob, prevStatus);
        bundleStatusUpdate.call();
    }
}
Also used : BundleStatusUpdateXCommand(org.apache.oozie.command.bundle.BundleStatusUpdateXCommand)

Example 7 with BundleStatusUpdateXCommand

use of org.apache.oozie.command.bundle.BundleStatusUpdateXCommand in project oozie by apache.

the class CoordResumeXCommand method notifyParent.

@Override
public void notifyParent() throws CommandException {
    // update bundle action
    if (this.coordJob.getBundleId() != null) {
        BundleStatusUpdateXCommand bundleStatusUpdate = new BundleStatusUpdateXCommand(coordJob, prevStatus);
        bundleStatusUpdate.call();
    }
}
Also used : BundleStatusUpdateXCommand(org.apache.oozie.command.bundle.BundleStatusUpdateXCommand)

Example 8 with BundleStatusUpdateXCommand

use of org.apache.oozie.command.bundle.BundleStatusUpdateXCommand in project oozie by apache.

the class CoordKillXCommand method notifyParent.

@Override
public void notifyParent() throws CommandException {
    // update bundle action
    if (coordJob.getBundleId() != null) {
        BundleStatusUpdateXCommand bundleStatusUpdate = new BundleStatusUpdateXCommand(coordJob, prevStatus);
        bundleStatusUpdate.call();
    }
}
Also used : BundleStatusUpdateXCommand(org.apache.oozie.command.bundle.BundleStatusUpdateXCommand)

Example 9 with BundleStatusUpdateXCommand

use of org.apache.oozie.command.bundle.BundleStatusUpdateXCommand in project oozie by apache.

the class CoordRerunXCommand method notifyParent.

@Override
public void notifyParent() throws CommandException {
    // update bundle action
    if (getPrevStatus() != null && coordJob.getBundleId() != null) {
        BundleStatusUpdateXCommand bundleStatusUpdate = new BundleStatusUpdateXCommand(coordJob, getPrevStatus());
        bundleStatusUpdate.call();
    }
}
Also used : BundleStatusUpdateXCommand(org.apache.oozie.command.bundle.BundleStatusUpdateXCommand)

Example 10 with BundleStatusUpdateXCommand

use of org.apache.oozie.command.bundle.BundleStatusUpdateXCommand in project oozie by apache.

the class CoordStatusTransitXCommand method updateJobStatus.

@Override
protected void updateJobStatus(Status coordStatus) throws JPAExecutorException, CommandException {
    final Job.Status prevStatus = coordJob.getStatus();
    boolean prevPending = coordJob.isPending();
    if (isPending) {
        coordJob.setPending();
    } else {
        coordJob.resetPending();
    }
    boolean isPendingStateChanged = prevPending != coordJob.isPending();
    // Update the Coord Job
    if (coordJob.isTerminalStatus() && (coordStatus == Job.Status.SUSPENDED || coordStatus == Job.Status.SUSPENDEDWITHERROR)) {
        LOG.info("Coord Job [" + coordJob.getId() + "] status to " + coordStatus + " can not be updated as its already in Terminal state");
        if (isPendingStateChanged) {
            LOG.info("Pending for job  [" + coordJob.getId() + "] is changed to to '" + coordJob.isPending() + "' from '" + prevStatus + "'");
            coordJob.setLastModifiedTime(new Date());
            CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQuery.UPDATE_COORD_JOB_STATUS_PENDING_MODTIME, coordJob);
        }
        return;
    }
    // Check for backward support when RUNNINGWITHERROR, SUSPENDEDWITHERROR and PAUSEDWITHERROR is
    // not supported
    coordJob.setStatus(StatusUtils.getStatusIfBackwardSupportTrue(coordStatus));
    // Backward support when coordinator namespace is 0.1
    coordJob.setStatus(StatusUtils.getStatus(coordJob));
    if (coordJob.getStatus() != prevStatus || isPendingStateChanged) {
        LOG.info("Set coordinator job [" + coordJob.getId() + "] status to '" + coordJob.getStatus() + "' from '" + prevStatus + "'");
        coordJob.setLastModifiedTime(new Date());
        CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQuery.UPDATE_COORD_JOB_STATUS_PENDING_MODTIME, coordJob);
    }
    // update bundle action only when status changes in coord job
    if (coordJob.getBundleId() != null) {
        if (!prevStatus.equals(coordJob.getStatus())) {
            new BundleStatusUpdateXCommand(coordJob, prevStatus).call();
        }
    }
}
Also used : BundleStatusUpdateXCommand(org.apache.oozie.command.bundle.BundleStatusUpdateXCommand) Status(org.apache.oozie.client.Job.Status) Job(org.apache.oozie.client.Job) Date(java.util.Date)

Aggregations

BundleStatusUpdateXCommand (org.apache.oozie.command.bundle.BundleStatusUpdateXCommand)10 Date (java.util.Date)2 XException (org.apache.oozie.XException)1 Job (org.apache.oozie.client.Job)1 Status (org.apache.oozie.client.Job.Status)1 CommandException (org.apache.oozie.command.CommandException)1 CoordJobQuery (org.apache.oozie.executor.jpa.CoordJobQueryExecutor.CoordJobQuery)1