use of org.apache.oozie.util.ELEvaluator in project oozie by apache.
the class TestCoordELEvaluator method testCreateDataEvaluator.
public void testCreateDataEvaluator() throws Exception {
String jobXml = "<coordinator-app name=\"mycoordinator-app\" start=\"2009-02-01T01:00GMT\"" + " end=\"2009-02-03T23:59GMT\" timezone=\"UTC\"";
jobXml += " frequency=\"720\" freq_timeunit=\"MINUTE\"";
jobXml += " action-nominal-time='2009-09-01T00:00Z' action-actual-time='2010-10-01T00:00Z'>";
jobXml += "<input-events><data-in name=\"A\" dataset=\"a\">" + "<uris>file:///tmp/coord/US/2009/1/30|file:///tmp/coord/US/2009/1/31</uris>";
jobXml += "<dataset name=\"a\" frequency=\"1440\" initial-instance=\"2009-01-01T00:00Z\">";
jobXml += "<uri-template>file:///tmp/coord/US/${YEAR}/${MONTH}/${DAY}</uri-template></dataset></data-in></input-events>";
jobXml += "<action><workflow><url>http://foobar.com:8080/oozie</url>" + "<app-path>hdfs://foobarfoobar.com:9000/usr/tucu/mywf</app-path>";
jobXml += "<configuration><property><name>inputA</name><value>${coord:dataIn('A')}</value></property>";
jobXml += "<property><name>ACTIONID</name><value>${coord:actionId()}</value></property>";
jobXml += "<property><name>NAME</name><value>${coord:name()}</value></property>";
jobXml += "<property><name>NOMINALTIME</name><value>${coord:nominalTime()}</value></property>";
jobXml += "<property><name>ACTUALTIME</name><value>${coord:actualTime()}</value></property>";
jobXml += "</configuration></workflow></action></coordinator-app>";
String reply = "<action><workflow><url>http://foobar.com:8080/oozie</url>" + "<app-path>hdfs://foobarfoobar.com:9000/usr/tucu/mywf</app-path>";
reply += "<configuration><property><name>inputA</name>" + "<value>file:///tmp/coord/US/2009/1/30|file:///tmp/coord/US/2009/1/31</value></property>";
reply += "<property><name>ACTIONID</name><value>00000-oozie-C@1</value></property>";
reply += "<property><name>NAME</name><value>mycoordinator-app</value></property>";
reply += "<property><name>NOMINALTIME</name><value>2009-09-01T00:00Z</value></property>";
reply += "<property><name>ACTUALTIME</name><value>2010-10-01T00:00Z</value></property>";
reply += "</configuration></workflow></action>";
Element eJob = XmlUtils.parseXml(jobXml);
Configuration conf = new XConfiguration(new StringReader(getConfString()));
ELEvaluator eval = CoordELEvaluator.createDataEvaluator(eJob, conf, "00000-oozie-C@1");
Element action = eJob.getChild("action", eJob.getNamespace());
String str = XmlUtils.prettyPrint(action).toString();
assertEquals(XmlUtils.prettyPrint(XmlUtils.parseXml(reply)).toString(), CoordELFunctions.evalAndWrap(eval, str));
}
use of org.apache.oozie.util.ELEvaluator in project oozie by apache.
the class TestHCatELFunctions method testHCatPartitionExists.
@Test
public void testHCatPartitionExists() throws Exception {
dropTable("db1", "table1", true);
dropDatabase("db1", true);
createDatabase("db1");
createTable("db1", "table1", "year,month,dt,country");
addPartition("db1", "table1", "year=2012;month=12;dt=02;country=us");
Configuration protoConf = new Configuration();
protoConf.set(OozieClient.USER_NAME, getTestUser());
protoConf.set("hadoop.job.ugi", getTestUser() + "," + "group");
Configuration conf = new XConfiguration();
conf.set(OozieClient.APP_PATH, "appPath");
conf.set(OozieClient.USER_NAME, getTestUser());
conf.set("test.dir", getTestCaseDir());
conf.set("partition1", getHCatURI("db1", "table1", "dt=02").toString());
conf.set("partition2", getHCatURI("db1", "table1", "dt=05").toString());
LiteWorkflowApp def = new LiteWorkflowApp("name", "<workflow-app/>", new StartNodeDef(LiteWorkflowStoreService.LiteControlNodeHandler.class, "end")).addNode(new EndNodeDef("end", LiteWorkflowStoreService.LiteControlNodeHandler.class));
LiteWorkflowInstance job = new LiteWorkflowInstance(def, conf, "wfId");
WorkflowJobBean wf = new WorkflowJobBean();
wf.setId(job.getId());
wf.setAppName("name");
wf.setAppPath("appPath");
wf.setUser(getTestUser());
wf.setGroup("group");
wf.setWorkflowInstance(job);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
protoConf.writeXml(baos);
wf.setProtoActionConf(baos.toString());
WorkflowActionBean action = new WorkflowActionBean();
action.setId("actionId");
action.setName("actionName");
ELEvaluator eval = Services.get().get(ELService.class).createEvaluator("workflow");
DagELFunctions.configureEvaluator(eval, wf, action);
assertEquals(true, (boolean) eval.evaluate("${hcat:exists(wf:conf('partition1'))}", Boolean.class));
assertEquals(false, (boolean) eval.evaluate("${hcat:exists(wf:conf('partition2'))}", Boolean.class));
dropTable("db1", "table1", true);
dropDatabase("db1", true);
}
Aggregations