use of org.apache.oozie.client.OozieClient in project oozie by apache.
the class TestLocalOozieClientCoord method testGetOozieUrl.
public void testGetOozieUrl() {
OozieClient client = LocalOozie.getCoordClient();
assertEquals("localoozie", client.getOozieUrl());
}
use of org.apache.oozie.client.OozieClient in project oozie by apache.
the class TestLocalOozieClientCoord method testGetJobsInfo.
public void testGetJobsInfo() {
OozieClient client = LocalOozie.getCoordClient();
try {
client.getJobsInfo("foo");
fail("OozieClientException expected.");
} catch (OozieClientException oce) {
assertEquals(ErrorCode.E0301.toString(), oce.getErrorCode());
}
try {
client.getJobsInfo("foo", 0, 5);
fail("OozieClientException expected.");
} catch (OozieClientException oce) {
assertEquals(ErrorCode.E0301.toString(), oce.getErrorCode());
}
try {
client.getJobInfo("foo-id");
fail("OozieClientException expected.");
} catch (OozieClientException oce) {
assertEquals(ErrorCode.E0301.toString(), oce.getErrorCode());
}
}
use of org.apache.oozie.client.OozieClient in project oozie by apache.
the class TestWorkflow method testWorkflowWithStartAndEndCompletesSuccessfully.
public void testWorkflowWithStartAndEndCompletesSuccessfully() throws Exception {
final String wfApp = "<workflow-app xmlns='uri:oozie:workflow:0.1' name='test-wf'>" + " <start to='end'/>" + " <end name='end'/>" + "</workflow-app>";
final FileSystem fs = getFileSystem();
final Path appPath = new Path(getFsTestCaseDir(), "app");
fs.mkdirs(appPath);
fs.mkdirs(new Path(appPath, "lib"));
final Writer writer = new OutputStreamWriter(fs.create(new Path(appPath, "workflow.xml")));
writer.write(wfApp);
writer.close();
final OozieClient wc = LocalOozie.getClient();
final Properties conf = wc.createConfiguration();
conf.setProperty(OozieClient.APP_PATH, new Path(appPath, "workflow.xml").toString());
conf.setProperty(OozieClient.USER_NAME, getTestUser());
final String jobId = wc.submit(conf);
assertNotNull(jobId);
WorkflowJob wf = wc.getJobInfo(jobId);
assertNotNull(wf);
assertEquals(WorkflowJob.Status.PREP, wf.getStatus());
wc.start(jobId);
waitFor(1000, new Predicate() {
public boolean evaluate() throws Exception {
final WorkflowJob wf = wc.getJobInfo(jobId);
return wf.getStatus() == WorkflowJob.Status.SUCCEEDED;
}
});
wf = wc.getJobInfo(jobId);
assertNotNull(wf);
assertEquals(WorkflowJob.Status.SUCCEEDED, wf.getStatus());
}
use of org.apache.oozie.client.OozieClient in project oozie by apache.
the class TestWorkflow method runWorkflowFromFile.
private void runWorkflowFromFile(final String workflowFileName, final Properties additionalWorkflowProperties) throws IOException, OozieClientException {
final FileSystem fs = getFileSystem();
final Path appPath = new Path(getFsTestCaseDir(), "app");
fs.mkdirs(appPath);
fs.mkdirs(new Path(appPath, "lib"));
final Reader reader = getResourceAsReader(workflowFileName, -1);
final Writer writer = new OutputStreamWriter(fs.create(new Path(appPath, "workflow.xml")));
copyCharStream(reader, writer);
writer.close();
reader.close();
final Path path = getFsTestCaseDir();
final OozieClient oozieClient = LocalOozie.getClient();
final Properties conf = oozieClient.createConfiguration();
conf.setProperty(OozieClient.APP_PATH, new Path(appPath, "workflow.xml").toString());
conf.setProperty(OozieClient.USER_NAME, getTestUser());
conf.setProperty("nameNodeBasePath", path.toString());
conf.setProperty("base", path.toUri().getPath());
conf.setProperty("nameNode", getNameNodeUri());
conf.setProperty("jobTracker", getJobTrackerUri());
for (final String additionalKey : additionalWorkflowProperties.stringPropertyNames()) {
conf.setProperty(additionalKey, additionalWorkflowProperties.getProperty(additionalKey));
}
final String jobId = oozieClient.submit(conf);
assertNotNull(jobId);
WorkflowJob wf = oozieClient.getJobInfo(jobId);
assertNotNull(wf);
assertEquals(WorkflowJob.Status.PREP, wf.getStatus());
oozieClient.start(jobId);
waitFor(15 * 1000, new Predicate() {
public boolean evaluate() throws Exception {
final WorkflowJob wf = oozieClient.getJobInfo(jobId);
return wf.getStatus() == WorkflowJob.Status.SUCCEEDED;
}
});
wf = oozieClient.getJobInfo(jobId);
assertNotNull(wf);
assertEquals(WorkflowJob.Status.SUCCEEDED, wf.getStatus());
}
use of org.apache.oozie.client.OozieClient in project oozie by apache.
the class SubWorkflowActionExecutor method kill.
public void kill(Context context, WorkflowAction action) throws ActionExecutorException {
LOG.info("Killing action");
try {
String subWorkflowId = action.getExternalId();
String oozieUri = action.getTrackerUri();
if (subWorkflowId != null && oozieUri != null) {
OozieClient oozieClient = getWorkflowClient(context, oozieUri);
oozieClient.kill(subWorkflowId);
}
context.setEndData(WorkflowAction.Status.KILLED, getActionSignal(WorkflowAction.Status.KILLED));
} catch (Exception ex) {
throw convertException(ex);
}
}
Aggregations