use of org.apache.oozie.XException in project oozie by apache.
the class CoordActionCheckXCommand method loadState.
/* (non-Javadoc)
* @see org.apache.oozie.command.XCommand#loadState()
*/
@Override
protected void loadState() throws CommandException {
try {
jpaService = Services.get().get(JPAService.class);
if (jpaService != null) {
coordAction = jpaService.execute(new CoordActionGetForCheckJPAExecutor(actionId));
coordJob = jpaService.execute(new CoordinatorJobGetForUserAppnameJPAExecutor(coordAction.getJobId()));
workflowJob = WorkflowJobQueryExecutor.getInstance().get(WorkflowJobQuery.GET_WORKFLOW_FOR_SLA, coordAction.getExternalId());
LogUtils.setLogInfo(coordAction);
} else {
throw new CommandException(ErrorCode.E0610);
}
} catch (XException ex) {
throw new CommandException(ex);
}
}
use of org.apache.oozie.XException in project oozie by apache.
the class CoordActionUpdateXCommand method execute.
@Override
protected Void execute() throws CommandException {
try {
LOG.debug("STARTED CoordActionUpdateXCommand for wfId=[{0}]", workflow.getId());
final CoordinatorAction.Status formerCoordinatorStatus = coordAction.getStatus();
final int formerCoordinatorPending = coordAction.getPending();
Status slaStatus = null;
if (workflow.getStatus() == WorkflowJob.Status.SUCCEEDED) {
coordAction.setStatus(CoordinatorAction.Status.SUCCEEDED);
coordAction.setPending(0);
slaStatus = Status.SUCCEEDED;
} else if (workflow.getStatus() == WorkflowJob.Status.FAILED) {
coordAction.setStatus(CoordinatorAction.Status.FAILED);
coordAction.setPending(0);
slaStatus = Status.FAILED;
} else if (workflow.getStatus() == WorkflowJob.Status.KILLED) {
coordAction.setStatus(CoordinatorAction.Status.KILLED);
coordAction.setPending(0);
slaStatus = Status.KILLED;
} else if (workflow.getStatus() == WorkflowJob.Status.SUSPENDED) {
coordAction.setStatus(CoordinatorAction.Status.SUSPENDED);
coordAction.decrementAndGetPending();
} else if (workflow.getStatus() == WorkflowJob.Status.RUNNING || workflow.getStatus() == WorkflowJob.Status.PREP) {
// resume workflow job and update coord action accordingly
coordAction.setStatus(CoordinatorAction.Status.RUNNING);
coordAction.decrementAndGetPending();
} else {
LOG.warn("Unexpected workflow [{0}] STATUS [{1}]", workflow.getId(), workflow.getStatus());
// update lastModifiedTime
coordAction.setLastModifiedTime(new Date());
CoordActionQueryExecutor.getInstance().executeUpdate(CoordActionQueryExecutor.CoordActionQuery.UPDATE_COORD_ACTION_FOR_MODIFIED_DATE, coordAction);
/* CoordinatorJobBean coordJob = jpaService.execute(new CoordJobGetJPAExecutor(coordAction.getJobId()));
if (!coordJob.isPending()) {
coordJob.setPending();
jpaService.execute(new CoordJobUpdateJPAExecutor(coordJob));
}*/
return null;
}
LOG.info("Updating Coordinator action id: [{0}] status [{1}] to [{2}] pending [{3}] to [{4}]", coordAction.getId(), formerCoordinatorStatus, coordAction.getStatus(), formerCoordinatorPending, coordAction.getPending());
coordAction.setLastModifiedTime(new Date());
updateList.add(new UpdateEntry<CoordActionQuery>(CoordActionQuery.UPDATE_COORD_ACTION_STATUS_PENDING_TIME, coordAction));
/*CoordinatorJobBean coordJob = jpaService.execute(new CoordJobGetJPAExecutor(coordAction.getJobId()));
if (!coordJob.isPending()) {
coordJob.setPending();
jpaService.execute(new CoordJobUpdateJPAExecutor(coordJob));
LOG.info("Updating Coordinator job "+ coordJob.getId() + "pending to true");
}*/
if (slaStatus != null) {
SLAEventBean slaEvent = SLADbOperations.createStatusEvent(coordAction.getSlaXml(), coordAction.getId(), slaStatus, SlaAppType.COORDINATOR_ACTION, LOG);
if (slaEvent != null) {
insertList.add(slaEvent);
}
}
if (workflow.getStatus() != WorkflowJob.Status.SUSPENDED && workflow.getStatus() != WorkflowJob.Status.RUNNING) {
queue(new CoordActionReadyXCommand(coordAction.getJobId()));
}
BatchQueryExecutor.getInstance().executeBatchInsertUpdateDelete(insertList, updateList, null);
if (EventHandlerService.isEnabled()) {
generateEvent(coordAction, coordJob.getUser(), coordJob.getAppName(), workflow.getStartTime());
}
LOG.debug("ENDED CoordActionUpdateXCommand for wfId= [{0}]", workflow.getId());
} catch (XException ex) {
LOG.warn("CoordActionUpdate Failed [{0}]", ex.getMessage());
throw new CommandException(ex);
}
return null;
}
use of org.apache.oozie.XException in project oozie by apache.
the class CoordJobXCommand method execute.
/* (non-Javadoc)
* @see org.apache.oozie.command.XCommand#execute()
*/
@Override
protected CoordinatorJobBean execute() throws CommandException {
try {
JPAService jpaService = Services.get().get(JPAService.class);
CoordinatorJobBean coordJob = null;
if (jpaService != null) {
coordJob = jpaService.execute(new CoordJobGetJPAExecutor(id));
if (getActionInfo) {
int numAction = jpaService.execute(new CoordActionsCountForJobIdJPAExecutor(id, filterMap));
List<CoordinatorActionBean> coordActions = null;
if (len == 0) {
coordActions = new ArrayList<CoordinatorActionBean>();
} else {
coordActions = jpaService.execute(new CoordJobGetActionsSubsetJPAExecutor(id, filterMap, offset, len, desc));
}
coordJob.setActions(coordActions);
coordJob.setNumActions(numAction);
}
} else {
LOG.error(ErrorCode.E0610);
}
return coordJob;
} catch (XException ex) {
throw new CommandException(ex);
}
}
use of org.apache.oozie.XException in project oozie by apache.
the class CoordKillXCommand method loadState.
@Override
protected void loadState() throws CommandException {
try {
jpaService = Services.get().get(JPAService.class);
if (jpaService != null) {
this.coordJob = CoordJobQueryExecutor.getInstance().get(CoordJobQuery.GET_COORD_JOB_SUSPEND_KILL, jobId);
// Get actions which are not succeeded, failed, timed out or killed
this.actionList = jpaService.execute(new CoordJobGetActionsNotCompletedJPAExecutor(jobId));
prevStatus = coordJob.getStatus();
LogUtils.setLogInfo(coordJob);
} else {
throw new CommandException(ErrorCode.E0610);
}
} catch (XException ex) {
throw new CommandException(ex);
}
}
use of org.apache.oozie.XException in project oozie by apache.
the class ActionKillXCommand method loadState.
@Override
protected void loadState() throws CommandException {
try {
jpaService = Services.get().get(JPAService.class);
if (jpaService != null) {
this.wfJob = WorkflowJobQueryExecutor.getInstance().get(WorkflowJobQuery.GET_WORKFLOW_ACTION_OP, jobId);
this.wfAction = WorkflowActionQueryExecutor.getInstance().get(WorkflowActionQuery.GET_ACTION, actionId);
LogUtils.setLogInfo(wfJob);
LogUtils.setLogInfo(wfAction);
} else {
throw new CommandException(ErrorCode.E0610);
}
} catch (XException ex) {
throw new CommandException(ex);
}
}
Aggregations