use of org.apache.oozie.client.Job 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;
}
use of org.apache.oozie.client.Job 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();
}
}
}
Aggregations