use of org.apache.oozie.command.coord.CoordActionInputCheckXCommand in project oozie by apache.
the class TestCoordinatorInputLogic method testMultipleInstance.
public void testMultipleInstance() throws Exception {
Configuration conf = getConf();
Date now = new Date();
// @formatter:off
String inputLogic = "<and name=\"test\">" + "<data-in dataset=\"A\" min=\"2\"/>" + "<data-in dataset=\"B\"/>" + "</and>";
String event = "<data-in name=\"A\" dataset=\"a\">" + "<instance>${coord:current(-5)}</instance>" + "<instance>${coord:latest(-1)}</instance>" + "<instance>${coord:futureRange(0,2,10)}</instance>" + "</data-in>" + "<data-in name=\"B\" dataset=\"b\">" + "<instance>${coord:latest(0)}</instance>" + "<instance>${coord:latestRange(-3,0)}</instance>" + "</data-in>";
// @formatter:on
conf.set("start_time", DateUtils.formatDateOozieTZ(now));
conf.set("end_time", DateUtils.formatDateOozieTZ(new Date(now.getTime() + 3 * 60 * 60 * 1000)));
// 5 hour before
conf.set("initial_instance_a", DateUtils.formatDateOozieTZ(new Date(now.getTime() - 5 * 60 * 60 * 1000)));
// 5 hour before
conf.set("initial_instance_b", DateUtils.formatDateOozieTZ(new Date(now.getTime() - 5 * 60 * 60 * 1000)));
String jobId = _testCoordSubmit("coord-inputlogic-range.xml", conf, inputLogic, event);
List<String> inputDir = createDirWithTime("input-data/a/", now, 3, 5, 0, -1, -2);
inputDir.addAll(createDirWithTime("input-data/b/", now, 0, 1));
startCoordActionForWaiting(jobId);
CoordinatorActionBean actionBean = CoordActionQueryExecutor.getInstance().get(CoordActionQuery.GET_COORD_ACTION, jobId + "@1");
assertTrue(CoordinatorAction.Status.WAITING.equals(actionBean.getStatus()));
inputDir.addAll(createDirWithTime("input-data/b/", now, 2, 3));
new CoordActionInputCheckXCommand(jobId + "@1", jobId).call();
actionBean = CoordActionQueryExecutor.getInstance().get(CoordActionQuery.GET_COORD_ACTION, jobId + "@1");
assertFalse(CoordinatorAction.Status.WAITING.equals(actionBean.getStatus()));
XConfiguration runConf = new XConfiguration(new StringReader(actionBean.getRunConf()));
String dataSets = runConf.get("inputLogicData");
assertEquals(dataSets.split(",").length, 10);
checkDataSets(dataSets, inputDir.toArray(new String[inputDir.size()]));
}
use of org.apache.oozie.command.coord.CoordActionInputCheckXCommand in project oozie by apache.
the class TestCoordinatorInputLogic method testSimpleOr1.
public void testSimpleOr1() throws Exception {
Configuration conf = getConf();
// @formatter:off
String inputLogic = "<or name=\"test\">" + "<and>" + "<data-in dataset=\"C\" />" + "<data-in dataset=\"D\" />" + "</and>" + "<or>" + "<data-in dataset=\"A\" />" + "<data-in dataset=\"B\" />" + "</or>" + "</or>";
String jobId = _testCoordSubmit("coord-inputlogic.xml", conf, inputLogic);
new CoordMaterializeTransitionXCommand(jobId, 3600).call();
CoordinatorActionBean actionBean = CoordActionQueryExecutor.getInstance().get(CoordActionQuery.GET_COORD_ACTION, jobId + "@1");
assertEquals(actionBean.getStatus(), CoordinatorAction.Status.WAITING);
new CoordActionInputCheckXCommand(jobId + "@1", jobId).call();
String input1 = createTestCaseSubDir("input-data/b/2014/10/08/00/_SUCCESS".split("/"));
startCoordAction(jobId);
actionBean = CoordActionQueryExecutor.getInstance().get(CoordActionQuery.GET_COORD_ACTION, jobId + "@1");
XConfiguration runConf = new XConfiguration(new StringReader(actionBean.getRunConf()));
String dataSets = runConf.get("inputLogicData");
assertEquals(dataSets.split(",").length, 1);
checkDataSets(dataSets, input1);
}
use of org.apache.oozie.command.coord.CoordActionInputCheckXCommand in project oozie by apache.
the class TestCoordinatorInputLogic method startCoordAction.
private void startCoordAction(final String jobId, final CoordinatorAction.Status coordActionStatus) throws CommandException, JPAExecutorException {
new CoordMaterializeTransitionXCommand(jobId, 3600).call();
new CoordActionInputCheckXCommand(jobId + "@1", jobId).call();
waitFor(50 * 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");
assertFalse(actionBean.getStatus().equals(coordActionStatus));
CoordinatorJob coordJob = CoordJobQueryExecutor.getInstance().get(CoordJobQuery.GET_COORD_JOB, jobId);
new CoordActionStartXCommand(actionBean.getId(), coordJob.getUser(), coordJob.getAppName(), actionBean.getJobId()).call();
}
Aggregations