use of org.apache.oozie.command.CommandException in project oozie by apache.
the class CoordUpdateXCommand method storeToDB.
@Override
protected String storeToDB(String xmlElement, Element eJob, CoordinatorJobBean coordJob) throws CommandException {
check(oldCoordJob, coordJob);
computeDiff(eJob);
oldCoordJob.setAppPath(conf.get(OozieClient.COORDINATOR_APP_PATH));
if (isConfChange) {
oldCoordJob.setConf(XmlUtils.prettyPrint(conf).toString());
}
oldCoordJob.setMatThrottling(coordJob.getMatThrottling());
oldCoordJob.setOrigJobXml(xmlElement);
oldCoordJob.setConcurrency(coordJob.getConcurrency());
oldCoordJob.setExecution(coordJob.getExecution());
oldCoordJob.setTimeout(coordJob.getTimeout());
oldCoordJob.setJobXml(XmlUtils.prettyPrint(eJob).toString());
if (!dryrun) {
oldCoordJob.setLastModifiedTime(new Date());
// Should log the changes, this should be useful for debugging.
LOG.info("Coord update changes : " + diff.toString());
try {
CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQuery.UPDATE_COORD_JOB, oldCoordJob);
} catch (JPAExecutorException jpaee) {
throw new CommandException(jpaee);
}
}
return jobId;
}
use of org.apache.oozie.command.CommandException 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.command.CommandException in project oozie by apache.
the class CoordActionInputCheckXCommand method checkUnresolvedInstances.
/**
* Check if any unsolved paths under data output. Resolve the unresolved data input paths.
*
* @param eAction action element
* @param actionConf action configuration
* @return true if successful to resolve input and output paths
* @throws Exception thrown if failed to resolve data input and output paths
*/
@SuppressWarnings("unchecked")
private boolean checkUnresolvedInstances(CoordinatorActionBean coordAction, Element eAction, Configuration actionConf) throws Exception {
boolean ret = coordAction.getPullInputDependencies().checkUnresolved(coordAction, eAction);
// Using latest() or future() in output-event is not intuitive.
// We need to make sure, this assumption is correct.
Element outputList = eAction.getChild("output-events", eAction.getNamespace());
if (outputList != null) {
for (Element dEvent : (List<Element>) outputList.getChildren("data-out", eAction.getNamespace())) {
if (dEvent.getChild(CoordCommandUtils.UNRESOLVED_INSTANCES_TAG, dEvent.getNamespace()) != null) {
throw new CommandException(ErrorCode.E1006, "coord:latest()/future()", " not permitted in output-event ");
}
}
}
return ret;
}
use of org.apache.oozie.command.CommandException in project oozie by apache.
the class CoordActionNotificationXCommand method loadState.
@Override
protected void loadState() throws CommandException {
Configuration conf;
try {
conf = new XConfiguration(new StringReader(actionBean.getRunConf()));
} catch (IOException e1) {
LOG.warn("Configuration parse error. read from DB :" + actionBean.getRunConf());
throw new CommandException(ErrorCode.E1005, e1.getMessage(), e1);
}
url = conf.get(OozieClient.COORD_ACTION_NOTIFICATION_URL);
if (url != null) {
url = url.replaceAll(ACTION_ID_PATTERN, actionBean.getId());
url = url.replaceAll(STATUS_PATTERN, actionBean.getStatus().toString());
proxyConf = conf.get(OozieClient.COORD_ACTION_NOTIFICATION_PROXY, Services.get().getConf().get(NOTIFICATION_PROXY_KEY));
LOG.debug("Proxy :" + proxyConf);
}
LOG.debug("Notification URL :" + url);
LogUtils.setLogInfo(actionBean);
}
use of org.apache.oozie.command.CommandException in project oozie by apache.
the class CoordActionSkipXCommand method execute.
@Override
protected Void execute() throws CommandException {
if (actionBean.getStatus() == CoordinatorAction.Status.WAITING || actionBean.getStatus() == CoordinatorAction.Status.READY) {
LOG.info("Setting action [{0}] status to SKIPPED", actionBean.getId());
actionBean.setStatus(CoordinatorAction.Status.SKIPPED);
try {
queue(new CoordActionNotificationXCommand(actionBean), 100);
actionBean.setLastModifiedTime(new Date());
CoordActionQueryExecutor.getInstance().executeUpdate(CoordActionQuery.UPDATE_COORD_ACTION_STATUS_PENDING_TIME, actionBean);
if (EventHandlerService.isEnabled()) {
generateEvent(actionBean, user, appName, null);
}
} catch (JPAExecutorException e) {
throw new CommandException(e);
}
}
return null;
}
Aggregations