use of org.apache.oozie.client.OozieClient in project oozie by apache.
the class TestCoordJobsToBeMaterializedJPAExecutor method getCoordConf.
private Properties getCoordConf(Path appPath) {
Path wfAppPath = new Path(getFsTestCaseDir(), "workflow");
final OozieClient coordClient = LocalOozie.getCoordClient();
Properties conf = coordClient.createConfiguration();
conf.setProperty(OozieClient.COORDINATOR_APP_PATH, appPath.toString());
conf.setProperty("jobTracker", getJobTrackerUri());
conf.setProperty("nameNode", getNameNodeUri());
conf.setProperty("wfAppPath", wfAppPath.toString());
conf.remove("user.name");
conf.setProperty("user.name", getTestUser());
return conf;
}
use of org.apache.oozie.client.OozieClient in project oozie by apache.
the class TestLocalOozieClientCoord method testJobMethods.
public void testJobMethods() throws Exception {
final OozieClient client = LocalOozie.getCoordClient();
// Just in case, check that there are no Coord job records left by previous tests:
List<CoordinatorJob> list0 = client.getCoordJobsInfo("", 1, 100);
assertEquals(0, list0.size());
Properties conf = client.createConfiguration();
String appPath = getTestCaseFileUri("coordinator.xml");
String appXml = "<coordinator-app name=\"NAME\" frequency=\"${coord:minutes(20)}\" " + "start=\"2009-02-01T01:00Z\" end=\"2009-02-03T23:59Z\" timezone=\"UTC\" " + "xmlns=\"uri:oozie:coordinator:0.1\"> <controls> <timeout>10</timeout> <concurrency>1</concurrency> " + "<execution>LIFO</execution> </controls> <datasets> " + "<dataset name=\"a\" frequency=\"${coord:minutes(20)}\" initial-instance=\"2009-02-01T01:00Z\" " + "timezone=\"UTC\"> <uri-template>" + getTestCaseFileUri("coord/workflows/${YEAR}/${DAY}") + "</uri-template> </dataset> " + "<dataset name=\"local_a\" frequency=\"${coord:minutes(20)}\" initial-instance=\"2009-02-01T01:00Z\" " + "timezone=\"UTC\"> <uri-template>" + getTestCaseFileUri("coord/workflows/${YEAR}/${DAY}") + "</uri-template> </dataset> " + "</datasets> <input-events> " + "<data-in name=\"A\" dataset=\"a\"> <instance>${coord:latest(0)}</instance> </data-in> " + "</input-events> " + "<output-events> <data-out name=\"LOCAL_A\" dataset=\"local_a\"> " + "<instance>${coord:current(-1)}</instance> </data-out> </output-events> <action> <workflow> " + "<app-path>hdfs:///tmp/workflows/</app-path> " + "<configuration> <property> <name>inputA</name> <value>${coord:dataIn('A')}</value> </property> " + "<property> <name>inputB</name> <value>${coord:dataOut('LOCAL_A')}</value> " + "</property></configuration> </workflow> </action> </coordinator-app>";
writeToFile(appXml, appPath);
conf.setProperty(OozieClient.COORDINATOR_APP_PATH, appPath);
String jobId0 = client.submit(conf);
client.kill(jobId0);
String jobId = client.run(conf);
client.suspend(jobId);
client.resume(jobId);
client.kill(jobId);
CoordinatorJob job = client.getCoordJobInfo(jobId);
String appName = job.getAppName();
assertEquals("NAME", appName);
List<CoordinatorJob> list = client.getCoordJobsInfo("", 1, 5);
assertEquals(2, list.size());
}
use of org.apache.oozie.client.OozieClient in project oozie by apache.
the class TestLocalOozieClientCoord method testJobsOperations.
public void testJobsOperations() throws Exception {
final OozieClient client = LocalOozie.getCoordClient();
// Just in case, check that there are no Coord job records left by previous tests:
List<CoordinatorJob> list0 = client.getCoordJobsInfo("", 1, 100);
assertEquals(0, list0.size());
Properties conf = client.createConfiguration();
String appPath = storedCoordAppPath();
conf.setProperty(OozieClient.COORDINATOR_APP_PATH, appPath);
final String jobId0 = client.run(conf);
final String jobId1 = client.run(conf);
final String jobId2 = client.run(conf);
waitFor(client, jobId0);
waitFor(client, jobId1);
waitFor(client, jobId2);
list0 = client.getCoordJobsInfo("name=NAME", 1, 10);
assertEquals(3, list0.size());
JSONObject jsonObject = client.suspendJobs("name=NAME", "coord", 1, 3);
assertEquals(3, jsonObject.get("total"));
assertEquals(3, ((JSONArray) jsonObject.get("coordinatorjobs")).size());
assertEquals(Job.Status.SUSPENDED, client.getCoordJobInfo(jobId0).getStatus());
assertEquals(Job.Status.SUSPENDED, client.getCoordJobInfo(jobId1).getStatus());
assertEquals(Job.Status.SUSPENDED, client.getCoordJobInfo(jobId2).getStatus());
jsonObject = client.resumeJobs("name=NAME", "coord", 1, 3);
assertEquals(3, jsonObject.get("total"));
assertEquals(3, ((JSONArray) jsonObject.get("coordinatorjobs")).size());
assertEquals(Job.Status.RUNNING, client.getCoordJobInfo(jobId0).getStatus());
assertEquals(Job.Status.RUNNING, client.getCoordJobInfo(jobId1).getStatus());
assertEquals(Job.Status.RUNNING, client.getCoordJobInfo(jobId2).getStatus());
jsonObject = client.killJobs("name=NAME", "coord", 1, 3);
assertEquals(3, jsonObject.get("total"));
assertEquals(3, ((JSONArray) jsonObject.get("coordinatorjobs")).size());
assertEquals(Job.Status.KILLED, client.getCoordJobInfo(jobId0).getStatus());
assertEquals(Job.Status.KILLED, client.getCoordJobInfo(jobId1).getStatus());
assertEquals(Job.Status.KILLED, client.getCoordJobInfo(jobId2).getStatus());
}
use of org.apache.oozie.client.OozieClient in project oozie by apache.
the class TestLocalOozieClientCoord method testGetProtocolUrl.
public void testGetProtocolUrl() throws IOException, OozieClientException {
OozieClient client = LocalOozie.getCoordClient();
assertEquals("localoozie", client.getProtocolUrl());
}
use of org.apache.oozie.client.OozieClient in project oozie by apache.
the class TestLocalOozieClientCoord method testReRun2.
public void testReRun2() {
OozieClient client = LocalOozie.getCoordClient();
try {
client.reRun("foo-id", client.createConfiguration());
fail("OozieClientException expected.");
} catch (OozieClientException oce) {
assertEquals(ErrorCode.E0301.toString(), oce.getErrorCode());
}
}
Aggregations