use of org.apache.oozie.client.OozieClientException 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.client.OozieClientException in project oozie by apache.
the class TestReRunXCommand method testRerunWithExistingConf.
// rerun should use existing wf conf
public void testRerunWithExistingConf() throws IOException, OozieClientException {
Reader reader = IOUtils.getResourceAsReader("rerun-wf.xml", -1);
Writer writer = new FileWriter(new File(getTestCaseDir(), "workflow.xml"));
IOUtils.copyCharStream(reader, writer);
Path path = getFsTestCaseDir();
getFileSystem().create(new Path(path, "p2"));
final OozieClient wfClient = LocalOozie.getClient();
final Properties conf = wfClient.createConfiguration();
conf.setProperty(OozieClient.APP_PATH, getTestCaseFileUri("workflow.xml"));
conf.setProperty(OozieClient.USER_NAME, getTestUser());
conf.setProperty("nnbase", path.toString());
conf.setProperty("base", path.toUri().getPath());
Properties newConf = wfClient.createConfiguration();
newConf.setProperty("base", path.toUri().getPath());
final String jobId = wfClient.submit(conf);
wfClient.start(jobId);
waitFor(15 * 1000, new Predicate() {
public boolean evaluate() throws Exception {
return wfClient.getJobInfo(jobId).getStatus() == WorkflowJob.Status.KILLED;
}
});
assertEquals(WorkflowJob.Status.KILLED, wfClient.getJobInfo(jobId).getStatus());
try {
wfClient.reRun(jobId, newConf);
} catch (OozieClientException e) {
assertTrue(e.getCause().getMessage().contains(ErrorCode.E0401.toString()));
}
newConf = wfClient.createConfiguration();
// Skip a non-executed node
getFileSystem().delete(new Path(path, "p2"), true);
newConf.setProperty(OozieClient.RERUN_SKIP_NODES, "fs1");
wfClient.reRun(jobId, newConf);
waitFor(15 * 1000, new Predicate() {
public boolean evaluate() throws Exception {
return wfClient.getJobInfo(jobId).getStatus() == WorkflowJob.Status.SUCCEEDED;
}
});
assertEquals(WorkflowJob.Status.SUCCEEDED, wfClient.getJobInfo(jobId).getStatus());
}
use of org.apache.oozie.client.OozieClientException in project oozie by apache.
the class TestReRunXCommand method testRerun.
public void testRerun() throws IOException, OozieClientException {
Reader reader = IOUtils.getResourceAsReader("rerun-wf.xml", -1);
Writer writer = new FileWriter(new File(getTestCaseDir(), "workflow.xml"));
IOUtils.copyCharStream(reader, writer);
Path path = getFsTestCaseDir();
getFileSystem().create(new Path(path, "p2"));
final OozieClient wfClient = LocalOozie.getClient();
Properties conf = wfClient.createConfiguration();
conf.setProperty(OozieClient.APP_PATH, getTestCaseFileUri("workflow.xml"));
conf.setProperty(OozieClient.USER_NAME, getTestUser());
conf.setProperty("nnbase", path.toString());
conf.setProperty("base", path.toUri().getPath());
final String jobId1 = wfClient.submit(conf);
wfClient.start(jobId1);
waitFor(15 * 1000, new Predicate() {
public boolean evaluate() throws Exception {
return wfClient.getJobInfo(jobId1).getStatus() == WorkflowJob.Status.KILLED;
}
});
assertEquals(WorkflowJob.Status.KILLED, wfClient.getJobInfo(jobId1).getStatus());
// Skip a non-executed node
conf.setProperty(OozieClient.RERUN_SKIP_NODES, "fs1,fs2,dec3");
boolean failed = false;
try {
wfClient.reRun(jobId1, conf);
} catch (OozieClientException e) {
failed = true;
assertTrue(e.getCause().getMessage().contains(ErrorCode.E0807.toString()));
}
assertEquals(true, failed);
// Skip executed nodes
getFileSystem().delete(new Path(path, "p2"), true);
conf.setProperty(OozieClient.RERUN_SKIP_NODES, "fs1");
wfClient.reRun(jobId1, conf);
waitFor(15 * 1000, new Predicate() {
public boolean evaluate() throws Exception {
return wfClient.getJobInfo(jobId1).getStatus() == WorkflowJob.Status.SUCCEEDED;
}
});
assertEquals(WorkflowJob.Status.SUCCEEDED, wfClient.getJobInfo(jobId1).getStatus());
}
use of org.apache.oozie.client.OozieClientException in project oozie by apache.
the class TestReRunXCommand method testRerunFromFailNodes.
public void testRerunFromFailNodes() throws IOException, OozieClientException {
Reader reader = IOUtils.getResourceAsReader("rerun-wf.xml", -1);
Writer writer = new FileWriter(new File(getTestCaseDir(), "workflow.xml"));
IOUtils.copyCharStream(reader, writer);
Path path = getFsTestCaseDir();
getFileSystem().create(new Path(path, "p2"));
final OozieClient wfClient = LocalOozie.getClient();
Properties conf = wfClient.createConfiguration();
conf.setProperty(OozieClient.APP_PATH, getTestCaseFileUri("workflow.xml"));
conf.setProperty(OozieClient.USER_NAME, getTestUser());
conf.setProperty("nnbase", path.toString());
conf.setProperty("base", path.toUri().getPath());
final String jobId1 = wfClient.submit(conf);
wfClient.start(jobId1);
waitFor(15 * 1000, new Predicate() {
public boolean evaluate() throws Exception {
return wfClient.getJobInfo(jobId1).getStatus() == WorkflowJob.Status.KILLED;
}
});
assertEquals(WorkflowJob.Status.KILLED, wfClient.getJobInfo(jobId1).getStatus());
// Skip succeeded nodes
getFileSystem().delete(new Path(path, "p2"), true);
conf.setProperty(OozieClient.RERUN_FAIL_NODES, "true");
wfClient.reRun(jobId1, conf);
waitFor(15 * 1000, new Predicate() {
public boolean evaluate() throws Exception {
return wfClient.getJobInfo(jobId1).getStatus() == WorkflowJob.Status.SUCCEEDED;
}
});
assertEquals(WorkflowJob.Status.SUCCEEDED, wfClient.getJobInfo(jobId1).getStatus());
}
use of org.apache.oozie.client.OozieClientException in project oozie by apache.
the class TestReRunXCommand method testRerunDisableForChild.
/**
* Rerun workflow should run by parent only if configuration has been set to
* true for oozie.wf.child.disable.rerun , Default it is disabled.
* @throws Exception
*/
public void testRerunDisableForChild() throws Exception {
final OozieClient wfClient = LocalOozie.getClient();
Date start = DateUtils.parseDateOozieTZ("2009-12-15T01:00Z");
Date end = DateUtils.parseDateOozieTZ("2009-12-16T01:00Z");
CoordinatorJobBean coordJob = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, start, end, false, false, 1);
CoordinatorActionBean action = addRecordToCoordActionTable(coordJob.getId(), 1, CoordinatorAction.Status.SUBMITTED, "coord-action-start-escape-strings.xml", 0);
String actionId = action.getId();
new CoordActionStartXCommand(actionId, getTestUser(), "myapp", "myjob").call();
final JPAService jpaService = Services.get().get(JPAService.class);
action = jpaService.execute(new CoordActionGetJPAExecutor(actionId));
if (action.getStatus() == CoordinatorAction.Status.SUBMITTED) {
fail("CoordActionStartCommand didn't work because the status for action id" + actionId + " is :" + action.getStatus() + " expected to be NOT SUBMITTED (i.e. RUNNING)");
}
final String wfId = action.getExternalId();
wfClient.kill(wfId);
waitFor(15 * 1000, new Predicate() {
public boolean evaluate() throws Exception {
return wfClient.getJobInfo(wfId).getStatus() == WorkflowJob.Status.KILLED;
}
});
Properties newConf = wfClient.createConfiguration();
newConf.setProperty(OozieClient.RERUN_FAIL_NODES, "true");
Services.get().getConf().setBoolean(ReRunXCommand.DISABLE_CHILD_RERUN, true);
try {
wfClient.reRun(wfId, newConf);
fail("OozieClientException should have been thrown (" + ErrorCode.E0755 + " Rerun is not allowed through child workflow, please re-run through the parent)");
} catch (OozieClientException ex) {
assertEquals(ErrorCode.E0755.toString(), ex.getErrorCode());
}
Services.get().getConf().setBoolean(ReRunXCommand.DISABLE_CHILD_RERUN, false);
wfClient.reRun(wfId, newConf);
waitFor(15 * 1000, new Predicate() {
public boolean evaluate() throws Exception {
return wfClient.getJobInfo(wfId).getStatus() == WorkflowJob.Status.SUCCEEDED;
}
});
assertEquals(WorkflowJob.Status.SUCCEEDED, wfClient.getJobInfo(wfId).getStatus());
}
Aggregations