use of org.apache.oozie.XException 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.XException in project oozie by apache.
the class CoordActionsKillXCommand method loadState.
@Override
protected void loadState() throws CommandException {
try {
jpaService = Services.get().get(JPAService.class);
if (jpaService != null) {
coordJob = CoordJobQueryExecutor.getInstance().get(CoordJobQuery.GET_COORD_JOB_ACTION_KILL, jobId);
LogUtils.setLogInfo(coordJob);
coordActions = CoordUtils.getCoordActions(rangeType, coordJob.getId(), scope, true);
} 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 CoordJobsXCommand method execute.
/* (non-Javadoc)
* @see org.apache.oozie.command.XCommand#execute()
*/
@Override
protected CoordinatorJobInfo execute() throws CommandException {
try {
JPAService jpaService = Services.get().get(JPAService.class);
CoordinatorJobInfo coordInfo = null;
if (jpaService != null) {
coordInfo = jpaService.execute(new CoordJobInfoGetJPAExecutor(filter, start, len));
} else {
LOG.error(ErrorCode.E0610);
}
return coordInfo;
} catch (XException ex) {
throw new CommandException(ex);
}
}
use of org.apache.oozie.XException in project oozie by apache.
the class ExternalIdXCommand method execute.
@Override
protected String execute() throws CommandException {
try {
JPAService jpaService = Services.get().get(JPAService.class);
String wfId = null;
if (jpaService != null) {
wfId = jpaService.execute(new WorkflowIdGetForExternalIdJPAExecutor(externalId));
} else {
LOG.error(ErrorCode.E0610);
}
return wfId;
} catch (XException ex) {
throw new CommandException(ex);
}
}
use of org.apache.oozie.XException in project oozie by apache.
the class CoordRerunXCommand method rerunChildren.
@Override
public void rerunChildren() throws CommandException {
boolean isError = false;
try {
CoordinatorActionInfo coordInfo = null;
InstrumentUtils.incrJobCounter(getName(), 1, getInstrumentation());
List<CoordinatorActionBean> coordActions = CoordUtils.getCoordActions(rerunType, jobId, scope, false);
if (checkAllActionsRunnable(coordActions)) {
Map<String, Context> uriHandlerContextMap = new HashMap<String, Context>();
Configuration coordJobConf = null;
try {
coordJobConf = new XConfiguration(new StringReader(coordJob.getConf()));
} catch (IOException e) {
throw new CommandException(ErrorCode.E0907, "failed to read coord job conf to clean up output data");
}
try {
for (CoordinatorActionBean coordAction : coordActions) {
String actionXml = coordAction.getActionXml();
// Cleanup activity should not run when failed option has been provided
if (!noCleanup && !failed) {
Element eAction = XmlUtils.parseXml(actionXml);
cleanupOutputEvents(eAction, coordJobConf, uriHandlerContextMap);
}
if (refresh) {
refreshAction(coordJob, coordAction);
}
updateAction(coordJob, coordAction);
if (SLAService.isEnabled()) {
SLAOperations.updateRegistrationEvent(coordAction.getId());
}
queue(new CoordActionNotificationXCommand(coordAction), 100);
queue(new CoordActionInputCheckXCommand(coordAction.getId(), coordAction.getJobId()), 100);
if (coordAction.getPushMissingDependencies() != null) {
queue(new CoordPushDependencyCheckXCommand(coordAction.getId(), true), 100);
}
}
} finally {
Iterator<Entry<String, Context>> itr = uriHandlerContextMap.entrySet().iterator();
while (itr.hasNext()) {
Entry<String, Context> entry = itr.next();
entry.getValue().destroy();
itr.remove();
}
}
} else {
isError = true;
throw new CommandException(ErrorCode.E1018, "part or all actions are not eligible to rerun!");
}
coordInfo = new CoordinatorActionInfo(coordActions);
ret = coordInfo;
} catch (XException xex) {
isError = true;
throw new CommandException(xex);
} catch (JDOMException jex) {
isError = true;
throw new CommandException(ErrorCode.E0700, jex.getMessage(), jex);
} catch (Exception ex) {
isError = true;
throw new CommandException(ErrorCode.E1018, ex.getMessage(), ex);
} finally {
if (isError) {
transitToPrevious();
}
}
}
Aggregations