use of org.apache.oozie.command.CommandException in project oozie by apache.
the class DagEngine method resumeJobs.
/**
* return the jobs that've been resumed
* @param filter Filter for jobs that will be resumed, can be name, user, group, status, id or combination of any
* @param start Offset for the jobs that will be resumed
* @param len maximum number of jobs that will be resumed
* @return workflowsInfo returns the jobs that've been resumed
* @throws DagEngineException if the jobs cloud not be resumed
*/
public WorkflowsInfo resumeJobs(String filter, int start, int len) throws DagEngineException {
try {
Map<String, List<String>> filterList = parseFilter(filter);
WorkflowsInfo workflowsInfo = new BulkWorkflowXCommand(filterList, start, len, OperationType.Resume).call();
if (workflowsInfo == null) {
return new WorkflowsInfo(new ArrayList<WorkflowJobBean>(), 0, 0, 0);
}
return workflowsInfo;
} catch (CommandException ex) {
throw new DagEngineException(ex);
}
}
use of org.apache.oozie.command.CommandException in project oozie by apache.
the class DagEngine method submitJob.
/**
* Submit a workflow job. <p> It validates configuration properties.
*
* @param conf job configuration.
* @param startJob indicates if the job should be started or not.
* @return the job Id.
* @throws DagEngineException thrown if the job could not be created.
*/
@Override
public String submitJob(Configuration conf, boolean startJob) throws DagEngineException {
validateSubmitConfiguration(conf);
try {
String jobId;
SubmitXCommand submit = new SubmitXCommand(conf);
jobId = submit.call();
if (startJob) {
start(jobId);
}
return jobId;
} catch (CommandException ex) {
throw new DagEngineException(ex);
}
}
use of org.apache.oozie.command.CommandException in project oozie by apache.
the class DagEngine method reRun.
/**
* Rerun a job.
*
* @param jobId job Id to rerun.
* @param conf configuration information for the rerun.
* @throws DagEngineException thrown if the job could not be rerun.
*/
@Override
public void reRun(String jobId, Configuration conf) throws DagEngineException {
try {
WorkflowJobBean wfBean = WorkflowJobQueryExecutor.getInstance().get(WorkflowJobQuery.GET_WORKFLOW, jobId);
Configuration wfConf = new XConfiguration(new StringReader(wfBean.getConf()));
XConfiguration.copy(conf, wfConf);
validateReRunConfiguration(wfConf);
new ReRunXCommand(jobId, wfConf).call();
} catch (CommandException ex) {
throw new DagEngineException(ex);
} catch (JPAExecutorException ex) {
throw new DagEngineException(ex);
} catch (IOException ex) {
throw new DagEngineException(ErrorCode.E0803, ex.getMessage());
}
}
use of org.apache.oozie.command.CommandException in project oozie by apache.
the class LocalOozieClientCoord method getCoordinatorActions.
private List<CoordinatorAction> getCoordinatorActions(String jobId, String rerunType, String scope, boolean refresh, boolean noCleanup, boolean failed, Properties prop) throws OozieClientException {
try {
XConfiguration conf = null;
if (prop != null) {
conf = new XConfiguration(prop);
}
if (!(rerunType.equals(RestConstants.JOB_COORD_SCOPE_DATE) || rerunType.equals(RestConstants.JOB_COORD_SCOPE_ACTION))) {
throw new CommandException(ErrorCode.E1018, "date or action expected.");
}
CoordinatorActionInfo coordInfo = coordEngine.reRun(jobId, rerunType, scope, Boolean.valueOf(refresh), Boolean.valueOf(noCleanup), Boolean.valueOf(failed), conf);
List<CoordinatorActionBean> actionBeans;
if (coordInfo != null) {
actionBeans = coordInfo.getCoordActions();
} else {
actionBeans = CoordUtils.getCoordActions(rerunType, jobId, scope, false);
}
List<CoordinatorAction> actions = new ArrayList<CoordinatorAction>();
for (CoordinatorActionBean actionBean : actionBeans) {
actions.add(actionBean);
}
return actions;
} catch (CommandException ce) {
throw new OozieClientException(ce.getErrorCode().toString(), ce);
} catch (BaseEngineException ex) {
throw new OozieClientException(ex.getErrorCode().toString(), ex);
}
}
use of org.apache.oozie.command.CommandException in project oozie by apache.
the class TestActionUserRetry method testUserRetryPolicy.
public void testUserRetryPolicy() throws JPAExecutorException, IOException, CommandException {
Configuration conf = new XConfiguration();
String workflowUri = getTestCaseFileUri("workflow.xml");
// @formatter:off
String appXml = "<workflow-app xmlns=\"uri:oozie:workflow:0.5\" name=\"wf-fork\">" + "<start to=\"fork1\"/>" + "<fork name=\"fork1\">" + "<path start=\"action1\"/>" + "<path start=\"action2\"/>" + "</fork>" + "<action name=\"action1\" retry-max=\"2\" retry-interval=\"1\" retry-policy=\"exponential\">" + "<test xmlns=\"uri:test\">" + "<signal-value>${wf:conf('signal-value')}</signal-value>" + "<external-status>${wf:conf('external-status')}</external-status> " + "<error>${wf:conf('error')}</error>" + "<avoid-set-execution-data>${wf:conf('avoid-set-execution-data')}</avoid-set-execution-data>" + "<avoid-set-end-data>${wf:conf('avoid-set-end-data')}</avoid-set-end-data>" + "<running-mode>${wf:conf('running-mode')}</running-mode>" + "</test>" + "<ok to=\"join1\"/>" + "<error to=\"kill\"/>" + "</action>" + "<action name=\"action2\">" + "<fs></fs><ok to=\"join1\"/>" + "<error to=\"kill\"/>" + "</action>" + "<join name=\"join1\" to=\"end\"/>" + "<kill name=\"kill\"><message>killed</message></kill>" + "<end name=\"end\"/>" + "</workflow-app>";
// @Formatter:on
writeToFile(appXml, workflowUri);
conf.set(OozieClient.APP_PATH, workflowUri);
conf.set(OozieClient.USER_NAME, getTestUser());
conf.set("error", "start.error");
conf.set("external-status", "error");
conf.set("signal-value", "based_on_action_status");
SubmitXCommand sc = new SubmitXCommand(conf);
final String jobId = sc.call();
new StartXCommand(jobId).call();
final WorkflowActionsGetForJobJPAExecutor actionsGetExecutor = new WorkflowActionsGetForJobJPAExecutor(jobId);
final JPAService jpaService = Services.get().get(JPAService.class);
// set a timeout for exponential retry of action with respect to given
// retry-interval and retry-max.
// If retry-interval is 1 then, for first retry, delay will be 1 min,
// for second retry it will be 2 min, 4, 8, 16 & so on.
int timeout = (1 + 2) * 60 * 1000;
waitFor(timeout, new Predicate() {
public boolean evaluate() throws Exception {
List<WorkflowActionBean> actions = jpaService.execute(actionsGetExecutor);
WorkflowActionBean action = null;
for (WorkflowActionBean bean : actions) {
if (bean.getType().equals("test")) {
action = bean;
break;
}
}
return (action != null && action.getUserRetryCount() == 2);
}
});
List<WorkflowActionBean> actions = jpaService.execute(actionsGetExecutor);
WorkflowActionBean action = null;
for (WorkflowActionBean bean : actions) {
if (bean.getType().equals("test")) {
action = bean;
break;
}
}
assertNotNull(action);
assertEquals(2, action.getUserRetryCount());
}
Aggregations