use of org.apache.oozie.executor.jpa.CoordActionQueryExecutor.CoordActionQuery in project oozie by apache.
the class CoordKillXCommand method updateCoordAction.
private void updateCoordAction(CoordinatorActionBean action, boolean makePending) {
CoordinatorAction.Status prevStatus = action.getStatus();
action.setStatus(CoordinatorActionBean.Status.KILLED);
if (makePending) {
action.incrementAndGetPending();
} else {
// set pending to false
action.setPending(0);
}
if (EventHandlerService.isEnabled() && prevStatus != CoordinatorAction.Status.RUNNING && prevStatus != CoordinatorAction.Status.SUSPENDED) {
CoordinatorXCommand.generateEvent(action, coordJob.getUser(), coordJob.getAppName(), null);
}
action.setLastModifiedTime(new Date());
updateList.add(new UpdateEntry<CoordActionQuery>(CoordActionQuery.UPDATE_COORD_ACTION_STATUS_PENDING_TIME, action));
}
use of org.apache.oozie.executor.jpa.CoordActionQueryExecutor.CoordActionQuery in project oozie by apache.
the class CoordSuspendXCommand method updateCoordAction.
private void updateCoordAction(CoordinatorActionBean action) {
action.setStatus(CoordinatorActionBean.Status.SUSPENDED);
action.incrementAndGetPending();
action.setLastModifiedTime(new Date());
updateList.add(new UpdateEntry<CoordActionQuery>(CoordActionQuery.UPDATE_COORD_ACTION_STATUS_PENDING_TIME, action));
}
use of org.apache.oozie.executor.jpa.CoordActionQueryExecutor.CoordActionQuery in project oozie by apache.
the class CoordActionCheckXCommand method execute.
/* (non-Javadoc)
* @see org.apache.oozie.command.XCommand#execute()
*/
@Override
protected Void execute() throws CommandException {
try {
InstrumentUtils.incrJobCounter(getName(), 1, getInstrumentation());
Status slaStatus = null;
CoordinatorAction.Status initialStatus = coordAction.getStatus();
if (workflowJob.getStatus() == WorkflowJob.Status.SUCCEEDED) {
coordAction.setStatus(CoordinatorAction.Status.SUCCEEDED);
// set pending to false as the status is SUCCEEDED
coordAction.setPending(0);
slaStatus = Status.SUCCEEDED;
} else {
if (workflowJob.getStatus() == WorkflowJob.Status.FAILED) {
coordAction.setStatus(CoordinatorAction.Status.FAILED);
slaStatus = Status.FAILED;
// set pending to false as the status is FAILED
coordAction.setPending(0);
} else {
if (workflowJob.getStatus() == WorkflowJob.Status.KILLED) {
coordAction.setStatus(CoordinatorAction.Status.KILLED);
slaStatus = Status.KILLED;
// set pending to false as the status is KILLED
coordAction.setPending(0);
} else if (workflowJob.getStatus() == WorkflowJob.Status.SUSPENDED) {
coordAction.setStatus(CoordinatorAction.Status.SUSPENDED);
slaStatus = Status.FAILED;
// set pending to false as the status is SUSPENDED
coordAction.setPending(0);
} else {
LOG.warn("Unexpected workflow " + workflowJob.getId() + " STATUS " + workflowJob.getStatus());
coordAction.setLastModifiedTime(new Date());
CoordActionQueryExecutor.getInstance().executeUpdate(CoordActionQueryExecutor.CoordActionQuery.UPDATE_COORD_ACTION_FOR_MODIFIED_DATE, coordAction);
return null;
}
}
}
LOG.debug("Updating Coordinator actionId :" + coordAction.getId() + "status to =" + coordAction.getStatus());
coordAction.setLastModifiedTime(new Date());
updateList.add(new UpdateEntry<CoordActionQuery>(CoordActionQuery.UPDATE_COORD_ACTION_STATUS_PENDING_TIME, coordAction));
if (slaStatus != null) {
SLAEventBean slaEvent = SLADbOperations.createStatusEvent(coordAction.getSlaXml(), coordAction.getId(), slaStatus, SlaAppType.COORDINATOR_ACTION, LOG);
if (slaEvent != null) {
insertList.add(slaEvent);
}
}
BatchQueryExecutor.getInstance().executeBatchInsertUpdateDelete(insertList, updateList, null);
CoordinatorAction.Status endStatus = coordAction.getStatus();
if (endStatus != initialStatus && EventHandlerService.isEnabled()) {
generateEvent(coordAction, coordJob.getUser(), coordJob.getAppName(), workflowJob.getStartTime());
}
} catch (XException ex) {
LOG.warn("CoordActionCheckCommand Failed ", ex);
throw new CommandException(ex);
}
return null;
}
use of org.apache.oozie.executor.jpa.CoordActionQueryExecutor.CoordActionQuery in project oozie by apache.
the class CoordRerunXCommand method updateAction.
/**
* Update an action into database table
*
* @param coordJob coordinator job bean
* @param coordAction coordinator action bean
* @throws Exception thrown failed to update coordinator action bean or unable to write sla registration event
*/
private void updateAction(CoordinatorJobBean coordJob, CoordinatorActionBean coordAction) throws Exception {
LOG.debug("updateAction for actionId=" + coordAction.getId());
if (coordAction.getStatus() == CoordinatorAction.Status.TIMEDOUT) {
LOG.debug("Updating created time for TIMEDOUT action id =" + coordAction.getId());
coordAction.setCreatedTime(new Date());
}
coordAction.setStatus(CoordinatorAction.Status.WAITING);
if (!failed) {
coordAction.setExternalId(null);
}
coordAction.setExternalStatus(null);
coordAction.setRerunTime(new Date());
coordAction.setLastModifiedTime(new Date());
coordAction.setErrorCode("");
coordAction.setErrorMessage("");
// Pushing the configuration which passed through rerun.
if (actionRunConf != null && actionRunConf.size() > 0) {
Configuration createdConf = null;
if (coordAction.getCreatedConf() != null) {
createdConf = new XConfiguration(new StringReader(coordAction.getCreatedConf()));
} else {
createdConf = new Configuration();
}
createdConf.set(RERUN_CONF, XmlUtils.prettyPrint(actionRunConf).toString());
coordAction.setCreatedConf(XmlUtils.prettyPrint(createdConf).toString());
}
updateList.add(new UpdateEntry<CoordActionQuery>(CoordActionQuery.UPDATE_COORD_ACTION_RERUN, coordAction));
writeActionRegistration(coordAction.getActionXml(), coordAction, coordJob.getUser(), coordJob.getGroup());
}
use of org.apache.oozie.executor.jpa.CoordActionQueryExecutor.CoordActionQuery in project oozie by apache.
the class CoordResumeXCommand method updateCoordAction.
private void updateCoordAction(CoordinatorActionBean action) {
action.setStatus(CoordinatorActionBean.Status.RUNNING);
action.incrementAndGetPending();
action.setLastModifiedTime(new Date());
updateList.add(new UpdateEntry<CoordActionQuery>(CoordActionQuery.UPDATE_COORD_ACTION_STATUS_PENDING_TIME, action));
}
Aggregations