use of org.apache.oozie.util.ELEvaluator in project oozie by apache.
the class TestDagELFunctions method testLastErrorNodeWithRetrySucceed.
// This test simulates an action that gets retried because of an Error and succeeds on one of the retries. The lastErrorNode
// EL function should never be set to this node.
public void testLastErrorNodeWithRetrySucceed() throws Exception {
WorkflowJobBean job = this.addRecordToWfJobTable(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
WorkflowActionBean action = this.addRecordToWfActionTable(job.getId(), "1", WorkflowAction.Status.END_RETRY, true);
action.setType("java");
action.setExternalStatus("FAILED");
action.setErrorInfo("JA018", "some error occurred");
WorkflowActionQueryExecutor.getInstance().executeUpdate(WorkflowActionQueryExecutor.WorkflowActionQuery.UPDATE_ACTION, action);
new ActionEndXCommandIgnoreSignalException(action.getId(), action.getType()).call();
ELEvaluator eval = Services.get().get(ELService.class).createEvaluator("workflow");
job = WorkflowJobQueryExecutor.getInstance().get(WorkflowJobQueryExecutor.WorkflowJobQuery.GET_WORKFLOW, job.getId());
action = WorkflowActionQueryExecutor.getInstance().get(WorkflowActionQueryExecutor.WorkflowActionQuery.GET_ACTION, action.getId());
DagELFunctions.configureEvaluator(eval, job, action);
assertEquals("", eval.evaluate("${wf:lastErrorNode()}", String.class));
action.setExternalStatus("SUCCEEDED");
action.setStatus(WorkflowAction.Status.DONE);
WorkflowActionQueryExecutor.getInstance().executeUpdate(WorkflowActionQueryExecutor.WorkflowActionQuery.UPDATE_ACTION, action);
new ActionEndXCommandIgnoreSignalException(action.getId(), action.getType()).call();
job = WorkflowJobQueryExecutor.getInstance().get(WorkflowJobQueryExecutor.WorkflowJobQuery.GET_WORKFLOW, job.getId());
action = WorkflowActionQueryExecutor.getInstance().get(WorkflowActionQueryExecutor.WorkflowActionQuery.GET_ACTION, action.getId());
assertEquals(WorkflowAction.Status.OK, action.getStatus());
DagELFunctions.configureEvaluator(eval, job, action);
assertEquals("", eval.evaluate("${wf:lastErrorNode()}", String.class));
}
use of org.apache.oozie.util.ELEvaluator in project oozie by apache.
the class CoordELExtensions method ph1_today_echo.
public static String ph1_today_echo(int hr, int min) {
ELEvaluator eval = ELEvaluator.getCurrent();
eval.setVariable(".wrap", "true");
// Unresolved
return PREFIX + "today(" + hr + ", " + min + ")";
}
use of org.apache.oozie.util.ELEvaluator in project oozie by apache.
the class TestCoordELEvaluator method testCreateLazyEvaluator.
public void testCreateLazyEvaluator() throws Exception {
// Configuration conf = new
// XConfiguration(IOUtils.getResourceAsReader("org/apache/oozie/coord/conf.xml",
// -1));
String testCaseDir = getTestCaseDir();
Configuration conf = new XConfiguration(new StringReader(getConfString()));
Date actualTime = DateUtils.parseDateOozieTZ("2009-09-01T01:00Z");
Date nominalTime = DateUtils.parseDateOozieTZ("2009-09-01T00:00Z");
String dataEvntXML = "<data-in name=\"A\" dataset=\"a\"><uris>" + getTestCaseFileUri("US/2009/1/30") + "|file:///tmp/coord/US/2009/1/31</uris>";
dataEvntXML += "<dataset name=\"a\" frequency=\"1440\" initial-instance=\"2009-01-01T00:00Z\"" + " freq_timeunit=\"MINUTE\" timezone=\"UTC\" end_of_duration=\"NONE\">";
dataEvntXML += "<uri-template>" + getTestCaseFileUri("${YEAR}/${MONTH}/${DAY}") + "</uri-template></dataset></data-in>";
Element dEvent = XmlUtils.parseXml(dataEvntXML);
ELEvaluator eval = CoordELEvaluator.createLazyEvaluator(actualTime, nominalTime, dEvent, conf);
createTestCaseSubDir("2009/01/02/_SUCCESS".split("/"));
String expr = "${coord:latest(0)} ${coord:latest(-1)}";
// Dependent on the directory structure
// TODO: Create the directory
assertEquals("2009-01-02T00:00Z ${coord:latest(-1)}", eval.evaluate(expr, String.class));
// future
createTestCaseSubDir("2009/09/04/_SUCCESS".split("/"));
createTestCaseSubDir("2009/09/05/_SUCCESS".split("/"));
expr = "${coord:future(1, 30)}";
assertEquals("2009-09-05T00:00Z", eval.evaluate(expr, String.class));
// System.out.println("OUTPUT :" + eval.evaluate(expr, String.class));
}
use of org.apache.oozie.util.ELEvaluator in project oozie by apache.
the class TestCoordELEvaluator method testCreateFreqELValuator.
public void testCreateFreqELValuator() throws Exception {
// System.out.println("CP :" + System.getProperty("java.class.path"));
// Configuration conf = new
// XConfiguration(IOUtils.getResourceAsReader("org/apache/oozie/coord/conf.xml",
// -1));
Configuration conf = new XConfiguration(new StringReader(getConfString()));
ELEvaluator eval = CoordELEvaluator.createELEvaluatorForGroup(conf, "coord-job-submit-freq");
String expr = "<coordinator-app name=\"mycoordinator-app\" start=\"${start}\" end=\"${end}\"" + " frequency=\"${coord:hours(12)}\"><data-in name=\"A\" dataset=\"a\"></data-in>";
String reply = expr.replace("${start}", conf.get("start")).replace("${end}", conf.get("end")).replace("${coord:hours(12)}", "720");
assertEquals(reply, CoordELFunctions.evalAndWrap(eval, expr));
expr = "<coordinator-app name=\"mycoordinator-app\" start=\"${start}\" end=\"${end}\"" + " frequency=\"${coord:days(7)}\"><data-in name=\"A\" dataset=\"a\"></data-in>";
reply = expr.replace("${start}", conf.get("start")).replace("${end}", conf.get("end")).replace("${coord:days(7)}", "7");
assertEquals(reply, CoordELFunctions.evalAndWrap(eval, expr));
expr = "<coordinator-app name=\"mycoordinator-app\" start=\"${start}\" end=\"${end}\"" + " frequency=\"${coord:months(1)}\"><data-in name=\"A\" dataset=\"a\"></data-in>";
reply = expr.replace("${start}", conf.get("start")).replace("${end}", conf.get("end")).replace("${coord:months(1)}", "1");
// System.out.println("****testCreateELValuator :"+
// CoordELFunctions.evaluateFunction(eval, expr));
assertEquals(reply, CoordELFunctions.evalAndWrap(eval, expr));
expr = "frequency=${coord:days(2)}";
expr = "frequency=60";
CoordELFunctions.evalAndWrap(eval, expr);
expr = "frequency=${coord:daysInMonth(2)}";
try {
CoordELFunctions.evalAndWrap(eval, expr);
fail();
} catch (Exception ex) {
}
expr = "frequency=${coord:hoursInDay(2)}";
try {
CoordELFunctions.evalAndWrap(eval, expr);
fail();
} catch (Exception ex) {
}
expr = "frequency=${coord:tzOffset()}";
try {
CoordELFunctions.evalAndWrap(eval, expr);
fail();
} catch (Exception ex) {
}
expr = "<frequency=120";
assertEquals(expr, CoordELFunctions.evalAndWrap(eval, expr));
}
use of org.apache.oozie.util.ELEvaluator in project oozie by apache.
the class TestCoordELEvaluator method testCreateInstancesELEvaluator.
public void testCreateInstancesELEvaluator() throws Exception {
String dataEvntXML = "<data-in name=\"A\" dataset=\"a\">" + "<uris>file:///tmp/coord/US/2009/1/30|file:///tmp/coord/US/2009/1/31</uris>";
dataEvntXML += "<dataset name=\"a\" frequency=\"1440\" initial-instance=\"2009-01-01T00:00Z\"" + " freq_timeunit=\"MINUTE\" timezone=\"UTC\" end_of_duration=\"NONE\">";
dataEvntXML += "<uri-template>file:///tmp/coord/US/${YEAR}/${MONTH}/${DAY}</uri-template></dataset></data-in>";
Element event = XmlUtils.parseXml(dataEvntXML);
SyncCoordAction appInst = new SyncCoordAction();
appInst.setNominalTime(DateUtils.parseDateOozieTZ("2009-09-08T01:00Z"));
appInst.setActualTime(DateUtils.parseDateOozieTZ("2010-10-01T00:00Z"));
appInst.setTimeUnit(TimeUnit.MINUTE);
// Configuration conf = new
// XConfiguration(IOUtils.getResourceAsReader("org/apache/oozie/coord/conf.xml",
// -1));
Configuration conf = new XConfiguration(new StringReader(getConfString()));
ELEvaluator eval = CoordELEvaluator.createInstancesELEvaluator(event, appInst, conf);
String expr = "${coord:current(0)}";
// System.out.println("OUTPUT :" + eval.evaluate(expr, String.class));
assertEquals("2009-09-08T00:00Z", eval.evaluate(expr, String.class));
}
Aggregations