use of org.apache.oozie.command.CommandException 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();
}
}
}
use of org.apache.oozie.command.CommandException in project oozie by apache.
the class CoordSLAAlertsXCommand method updateJobSLA.
/**
* Update job sla.
*
* @param newParams the new params
* @throws CommandException the command exception
*/
protected void updateJobSLA(Map<String, String> newParams) throws CommandException {
try {
CoordinatorJobBean job = CoordJobQueryExecutor.getInstance().get(CoordJobQueryExecutor.CoordJobQuery.GET_COORD_JOB_XML, getJobId());
Element eAction;
try {
eAction = XmlUtils.parseXml(job.getJobXml());
} catch (JDOMException e) {
throw new CommandException(ErrorCode.E1005, e.getMessage(), e);
}
Element eSla = eAction.getChild("action", eAction.getNamespace()).getChild("info", eAction.getNamespace("sla"));
if (newParams != null) {
if (newParams.get(RestConstants.SLA_NOMINAL_TIME) != null) {
updateSlaTagElement(eSla, SLAOperations.NOMINAL_TIME, newParams.get(RestConstants.SLA_NOMINAL_TIME));
}
if (newParams.get(RestConstants.SLA_SHOULD_START) != null) {
updateSlaTagElement(eSla, SLAOperations.SHOULD_START, newParams.get(RestConstants.SLA_SHOULD_START));
}
if (newParams.get(RestConstants.SLA_SHOULD_END) != null) {
updateSlaTagElement(eSla, SLAOperations.SHOULD_END, newParams.get(RestConstants.SLA_SHOULD_END));
}
if (newParams.get(RestConstants.SLA_MAX_DURATION) != null) {
updateSlaTagElement(eSla, SLAOperations.MAX_DURATION, newParams.get(RestConstants.SLA_MAX_DURATION));
}
}
String actualXml = XmlUtils.prettyPrint(eAction).toString();
job.setJobXml(actualXml);
job.setId(getJobId());
CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQueryExecutor.CoordJobQuery.UPDATE_COORD_JOB_XML, job);
} catch (XException e) {
throw new CommandException(e);
}
}
use of org.apache.oozie.command.CommandException in project oozie by apache.
the class ActionCheckXCommand method loadState.
@Override
protected void loadState() throws CommandException {
try {
this.wfJob = WorkflowJobQueryExecutor.getInstance().get(WorkflowJobQuery.GET_WORKFLOW_ACTION_OP, jobId);
this.wfAction = WorkflowActionQueryExecutor.getInstance().get(WorkflowActionQuery.GET_ACTION_CHECK, actionId);
} catch (JPAExecutorException e) {
throw new CommandException(e);
}
LogUtils.setLogInfo(wfJob);
LogUtils.setLogInfo(wfAction);
}
use of org.apache.oozie.command.CommandException in project oozie by apache.
the class ActionCheckXCommand method eagerVerifyPrecondition.
@Override
protected void eagerVerifyPrecondition() throws CommandException, PreconditionException {
if (wfJob == null) {
throw new PreconditionException(ErrorCode.E0604, jobId);
}
if (wfAction == null) {
throw new PreconditionException(ErrorCode.E0605, actionId);
}
// if the action has been updated, quit this command
if (actionCheckDelay > 0) {
Timestamp actionCheckTs = new Timestamp(System.currentTimeMillis() - actionCheckDelay * 1000);
Timestamp actionLmt = wfAction.getLastCheckTimestamp();
if (actionLmt.after(actionCheckTs)) {
throw new PreconditionException(ErrorCode.E0817, actionId);
}
}
executor = Services.get().get(ActionService.class).getExecutor(wfAction.getType());
if (executor == null) {
throw new CommandException(ErrorCode.E0802, wfAction.getType());
}
}
use of org.apache.oozie.command.CommandException in project oozie by apache.
the class ActionEndXCommand 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_END, actionId);
LogUtils.setLogInfo(wfJob);
LogUtils.setLogInfo(wfAction);
} else {
throw new CommandException(ErrorCode.E0610);
}
} catch (XException ex) {
throw new CommandException(ex);
}
}
Aggregations