use of org.apache.oozie.client.CoordinatorAction in project oozie by apache.
the class TestPastActionsTimeOut method _testTimeout.
/**
* The catch-up mode time up has been setup in {@link CoordActionMaterializeXCommand}
* @param jobId job id
* @throws Exception thrown if failed
*/
private void _testTimeout(final String jobId) throws Exception {
final CoordinatorEngine ce = new CoordinatorEngine(getTestUser());
waitFor(6000, new Predicate() {
public boolean evaluate() throws Exception {
CoordinatorJob job = ce.getCoordJob(jobId);
return !(job.getStatus().equals(CoordinatorJob.Status.PREP));
}
});
CoordinatorJob job = ce.getCoordJob(jobId);
assertTrue(!(job.getStatus().equals(CoordinatorJob.Status.PREP)));
waitFor(6000, new Predicate() {
public boolean evaluate() throws Exception {
CoordinatorJob job = ce.getCoordJob(jobId);
List<CoordinatorAction> actions = job.getActions();
return actions.size() > 0;
}
});
job = ce.getCoordJob(jobId);
List<CoordinatorAction> actions = job.getActions();
assertTrue(actions.size() > 0);
for (CoordinatorAction action : actions) {
CoordinatorActionBean json = (CoordinatorActionBean) action;
assertEquals(10, json.getTimeOut());
}
}
use of org.apache.oozie.client.CoordinatorAction in project oozie by apache.
the class TestCoordUpdateXCommand method testReRunRefresh.
// test coord re-run with refresh. will use the updated coord definition.
public void testReRunRefresh() throws Exception {
Configuration conf = new XConfiguration();
File appPathFile1 = new File(getTestCaseDir(), "coordinator.xml");
String jobId = setupCoord(conf, "coord-multiple-input-instance3.xml");
sleep(1000);
final int actionNum = 1;
final String actionId = jobId + "@" + actionNum;
final OozieClient coordClient = LocalOozie.getCoordClient();
waitFor(120 * 1000, new Predicate() {
@Override
public boolean evaluate() throws Exception {
CoordinatorAction bean = coordClient.getCoordActionInfo(actionId);
return (bean.getStatus() == CoordinatorAction.Status.WAITING || bean.getStatus() == CoordinatorAction.Status.SUBMITTED);
}
});
CoordinatorAction bean = coordClient.getCoordActionInfo(actionId);
assertEquals(bean.getMissingDependencies(), "!!${coord:latest(0)}#${coord:latest(-1)}");
CoordinatorJobBean job = getCoordJobs(jobId);
Reader reader = IOUtils.getResourceAsReader("coord-multiple-input-instance4.xml", -1);
Writer writer = new FileWriter(appPathFile1);
IOUtils.copyCharStream(reader, writer);
conf.set(OozieClient.COORDINATOR_APP_PATH, appPathFile1.toURI().toString());
new CoordUpdateXCommand(false, conf, jobId).call();
job = getCoordJobs(jobId);
Element processedJobXml = XmlUtils.parseXml(job.getJobXml());
Namespace namespace = processedJobXml.getNamespace();
String text = ((Element) processedJobXml.getChild("input-events", namespace).getChild("data-in", namespace).getChildren("instance", namespace).get(0)).getText();
assertEquals(text, "${coord:future(0, 1)}");
new CoordActionsKillXCommand(jobId, RestConstants.JOB_COORD_SCOPE_ACTION, Integer.toString(actionNum)).call();
coordClient.reRunCoord(jobId, RestConstants.JOB_COORD_SCOPE_ACTION, Integer.toString(actionNum), true, true);
bean = coordClient.getCoordActionInfo(actionId);
sleep(1000);
assertEquals(bean.getMissingDependencies(), "!!${coord:future(0, 1)}");
}
use of org.apache.oozie.client.CoordinatorAction in project oozie by apache.
the class TestCoordinatorInputLogic method testCombineNegative.
public void testCombineNegative() throws Exception {
Configuration conf = getConf();
// @formatter:off
String inputLogic = "<combine name=\"test\">" + "<data-in dataset=\"A\" />" + "<data-in dataset=\"B\" />" + "</combine>";
// @formatter:on
conf.set("initial_instance_a", "2014-10-07T00:00Z");
conf.set("initial_instance_b", "2014-10-07T00:00Z");
final String jobId = _testCoordSubmit("coord-inputlogic-range.xml", conf, inputLogic, getInputEventForRange());
createTestCaseSubDir("input-data/a/2014/10/08/00/_SUCCESS".split("/"));
createTestCaseSubDir("input-data/a/2014/10/07/23/_SUCCESS".split("/"));
createTestCaseSubDir("input-data/b/2014/10/07/21/_SUCCESS".split("/"));
createTestCaseSubDir("input-data/b/2014/10/07/20/_SUCCESS".split("/"));
new CoordMaterializeTransitionXCommand(jobId, 3600).call();
new CoordActionInputCheckXCommand(jobId + "@1", jobId).call();
waitFor(5 * 1000, new Predicate() {
public boolean evaluate() throws Exception {
CoordinatorActionBean actionBean = CoordActionQueryExecutor.getInstance().get(CoordActionQuery.GET_COORD_ACTION, jobId + "@1");
return !actionBean.getStatus().equals(CoordinatorAction.Status.WAITING);
}
});
CoordinatorAction actionBean = CoordActionQueryExecutor.getInstance().get(CoordActionQuery.GET_COORD_ACTION, jobId + "@1");
assertEquals(actionBean.getStatus(), CoordinatorAction.Status.WAITING);
}
use of org.apache.oozie.client.CoordinatorAction in project oozie by apache.
the class TestCoordinatorInputLogic method testCoordWithoutInputCheck.
// TODO combine support for unresolved
// public void testLatestWithCombine() throws Exception {
// Configuration conf = getConf();
// conf.set("input_check", "combine(\"A\", \"B\")");
// conf.set("initial_instance_a", "2014-10-07T00:00Z");
// conf.set("initial_instance_b", "2014-10-07T00:00Z");
//
// String jobId = _testCoordSubmit("coord-inputlogic-range-latest.xml", conf);
//
// new CoordMaterializeTransitionXCommand(jobId, 3600).call();
// CoordinatorActionBean actionBean = CoordActionQueryExecutor.getInstance().get(
// CoordActionQuery.GET_COORD_ACTION, jobId + "@1");
// sleep(2000);
//
// new CoordActionInputCheckXCommand(jobId + "@1", jobId).call();
// assertEquals(actionBean.getStatus(), CoordinatorAction.Status.WAITING);
// createTestCaseSubDir("input-data/a/2014/10/08/00/_SUCCESS".split("/"));
// createTestCaseSubDir("input-data/a/2014/10/07/23/_SUCCESS".split("/"));
// createTestCaseSubDir("input-data/a/2014/10/07/22/_SUCCESS".split("/"));
// createTestCaseSubDir("input-data/b/2014/10/07/21/_SUCCESS".split("/"));
//
// new CoordActionInputCheckXCommand(jobId + "@1", jobId).call();
//
// actionBean = CoordActionQueryExecutor.getInstance().get(CoordActionQuery.GET_COORD_ACTION, jobId + "@1");
// assertEquals(actionBean.getStatus(), CoordinatorAction.Status.WAITING);
//
// createTestCaseSubDir("input-data/b/2014/10/07/20/_SUCCESS".split("/"));
// new CoordActionInputCheckXCommand(jobId + "@1", jobId).call();
//
// actionBean = CoordActionQueryExecutor.getInstance().get(CoordActionQuery.GET_COORD_ACTION, jobId + "@1");
// assertFalse(CoordinatorAction.Status.WAITING.equals(actionBean.getStatus()));
//
// }
public void testCoordWithoutInputCheck() throws Exception {
Configuration conf = new XConfiguration();
String jobId = setupCoord(conf, "coord-multiple-input-instance3.xml");
sleep(1000);
new CoordMaterializeTransitionXCommand(jobId, 3600).call();
new CoordActionInputCheckXCommand(jobId + "@1", jobId).call();
CoordinatorAction actionBean = CoordActionQueryExecutor.getInstance().get(CoordActionQuery.GET_COORD_ACTION, jobId + "@1");
assertEquals(actionBean.getMissingDependencies(), "!!${coord:latest(0)}#${coord:latest(-1)}");
}
use of org.apache.oozie.client.CoordinatorAction in project oozie by apache.
the class TestCoordinatorEngine method testEmptyDoneFlag.
/**
* Test Missing Dependencies with Empty Done Flag in Schema
*
* @throws Exception
*/
public void testEmptyDoneFlag() throws Exception {
Configuration conf = new XConfiguration();
String appPath = getTestCaseFileUri("coordinator.xml");
String appXml = "<coordinator-app name=\"NAME\" frequency=\"${coord:days(1)}\" start=\"2009-02-01T01:00Z\" end=" + "\"2009-02-01T02:00Z\" timezone=\"UTC\" " + "xmlns=\"uri:oozie:coordinator:0.1\"> <controls> <timeout>10</timeout> <concurrency>2</concurrency> " + "<execution>LIFO</execution> </controls> <datasets> " + "<dataset name=\"local_a\" frequency=\"${coord:days(1)}\" initial-instance=\"2009-02-01T01:00Z\" " + "timezone=\"UTC\"> <uri-template>" + getTestCaseFileUri("workflows/${YEAR}/${MONTH}/${DAY}") + "</uri-template> " + "<done-flag></done-flag> </dataset>" + "</datasets> <input-events> " + "<data-in name=\"A\" dataset=\"local_a\"> <instance>${coord:current(0)}</instance> </data-in> " + "</input-events> " + "<action> <workflow> <app-path>hdfs:///tmp/workflows2/</app-path> " + "<configuration> <property> <name>inputA</name> <value>${coord:dataIn('A')}</value> </property> " + "</configuration> </workflow> </action> </coordinator-app>";
writeToFile(appXml, appPath);
conf.set(OozieClient.COORDINATOR_APP_PATH, appPath);
conf.set(OozieClient.USER_NAME, getTestUser());
final CoordinatorEngine ce = new CoordinatorEngine(getTestUser());
final String jobId = ce.submitJob(conf, true);
waitFor(5000, new Predicate() {
public boolean evaluate() throws Exception {
try {
List<CoordinatorAction> actions = ce.getCoordJob(jobId).getActions();
for (CoordinatorAction action : actions) {
CoordinatorAction.Status actionStatus = action.getStatus();
if (actionStatus == CoordinatorAction.Status.WAITING) {
return true;
}
}
} catch (Exception ex) {
return false;
}
return false;
}
});
List<CoordinatorAction> actions = ce.getCoordJob(jobId).getActions();
assertTrue(actions.size() > 0);
CoordinatorAction action = actions.get(0);
String missingDeps = action.getMissingDependencies();
System.out.println("..Missing deps=" + missingDeps);
assertEquals(getTestCaseFileUri("workflows/2009/02/01"), missingDeps);
}
Aggregations