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);
}
}
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);
}
}
Aggregations