use of org.osate.aadl2.Namespace in project oozie by apache.
the class TestCoordUpdateXCommand method testCoordFromBundleJobChangeDefinition.
public void testCoordFromBundleJobChangeDefinition() throws Exception {
final XConfiguration jobConf = new XConfiguration();
String coordJobId = setUpBundleAndGetCoordID(jobConf);
CoordinatorJobBean job = getCoordJobs(coordJobId);
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:latest(0)}");
final Path coordPath1 = new Path(getFsTestCaseDir(), "coord1");
writeCoordXml(coordPath1, "coord-multiple-input-instance4.xml");
Configuration newConf = new Configuration();
newConf.set(OozieClient.USER_NAME, getTestUser());
CoordUpdateXCommand update = new CoordUpdateXCommand(false, newConf, coordJobId);
update.call();
job = getCoordJobs(coordJobId);
processedJobXml = XmlUtils.parseXml(job.getJobXml());
namespace = processedJobXml.getNamespace();
text = ((Element) processedJobXml.getChild("input-events", namespace).getChild("data-in", namespace).getChildren("instance", namespace).get(0)).getText();
assertEquals(text, "${coord:future(0, 1)}");
}
use of org.osate.aadl2.Namespace in project oozie by apache.
the class TestLiteWorkflowAppParser method extractConfig.
private XConfiguration extractConfig(LiteWorkflowApp app, String actionNode) throws Exception {
String confXML = app.getNode(actionNode).getConf();
Element confElement = XmlUtils.parseXml(confXML);
Namespace ns = confElement.getNamespace();
String configSection = XmlUtils.prettyPrint(confElement.getChild("configuration", ns)).toString();
XConfiguration xconf = new XConfiguration(new StringReader(configSection));
return xconf;
}
use of org.osate.aadl2.Namespace in project oozie by apache.
the class TestSubmitMRXCommand method testWFXmlGeneration.
public void testWFXmlGeneration() throws Exception {
Configuration conf = new Configuration(false);
conf.set(XOozieClient.RM, "jobtracker");
conf.set(XOozieClient.NN, "namenode");
conf.set(OozieClient.LIBPATH, "libpath");
conf.set("mapred.mapper.class", "A.Mapper");
conf.set("mapred.reducer.class", "A.Reducer");
conf.set(XOozieClient.FILES, "/user/oozie/input1.txt,/user/oozie/input2.txt#my.txt");
conf.set(XOozieClient.ARCHIVES, "/user/oozie/udf1.jar,/user/oozie/udf2.jar#my.jar");
SubmitMRXCommand submitMRCmd = new SubmitMRXCommand(conf);
String xml = submitMRCmd.getWorkflowXml(conf);
XLog.getLog(getClass()).info("xml = " + xml);
// verifying is a valid WF
WorkflowAppService wps = Services.get().get(WorkflowAppService.class);
wps.parseDef(xml, conf);
Element wfE = XmlUtils.parseXml(xml);
Namespace ns = wfE.getNamespace();
Element actionE = wfE.getChild("action", ns).getChild("map-reduce", ns);
Element confE = actionE.getChild("configuration", ns);
Map<String, String> props = new HashMap<String, String>();
for (Object prop : confE.getChildren("property", ns)) {
Element propE = (Element) prop;
String name = propE.getChild("name", ns).getTextTrim();
String value = propE.getChild("value", ns).getTextTrim();
props.put(name, value);
}
Map<String, String> expected = new HashMap<String, String>();
expected.put("mapred.mapper.class", "A.Mapper");
expected.put("mapred.reducer.class", "A.Reducer");
for (Map.Entry<String, String> entry : expected.entrySet()) {
assertEquals(entry.getValue(), expected.get(entry.getKey()));
}
assertEquals("/user/oozie/input1.txt#input1.txt", ((Element) actionE.getChildren("file", ns).get(0)).getTextTrim());
assertEquals("/user/oozie/input2.txt#my.txt", ((Element) actionE.getChildren("file", ns).get(1)).getTextTrim());
assertEquals("/user/oozie/udf1.jar#udf1.jar", ((Element) actionE.getChildren("archive", ns).get(0)).getTextTrim());
assertEquals("/user/oozie/udf2.jar#my.jar", ((Element) actionE.getChildren("archive", ns).get(1)).getTextTrim());
}
use of org.osate.aadl2.Namespace in project oozie by apache.
the class TestActionStartXCommand method testActionReuseWfJobAppPath.
public void testActionReuseWfJobAppPath() throws Exception {
JPAService jpaService = Services.get().get(JPAService.class);
WorkflowJobBean job = this.addRecordToWfJobTableWithCustomAppPath(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
WorkflowActionBean action = this.addRecordToWfActionTableWithAppPathConfig(job.getId(), "1", WorkflowAction.Status.PREP);
WorkflowActionGetJPAExecutor wfActionGetCmd = new WorkflowActionGetJPAExecutor(action.getId());
new ActionStartXCommand(action.getId(), "map-reduce").call();
action = jpaService.execute(wfActionGetCmd);
assertNotNull(action.getExternalId());
Element actionXml = XmlUtils.parseXml(action.getConf());
Namespace ns = actionXml.getNamespace();
Element configElem = actionXml.getChild("configuration", ns);
String strConf = XmlUtils.prettyPrint(configElem).toString();
XConfiguration inlineConf = new XConfiguration(new StringReader(strConf));
String workDir = inlineConf.get("work.dir", null);
assertNotNull(workDir);
assertFalse(workDir.contains("workflow.xml"));
}
use of org.osate.aadl2.Namespace in project oozie by apache.
the class TestHiveActionExecutor method testActionConfLoadDefaultResources.
public void testActionConfLoadDefaultResources() throws Exception {
ConfigurationService.setBoolean("oozie.service.HadoopAccessorService.action.configurations.load.default.resources", false);
Path inputDir = new Path(getFsTestCaseDir(), INPUT_DIRNAME);
Path outputDir = new Path(getFsTestCaseDir(), OUTPUT_DIRNAME);
FileSystem fs = getFileSystem();
Path script = new Path(getAppPath(), HIVE_SCRIPT_FILENAME);
Writer scriptWriter = new OutputStreamWriter(fs.create(script), StandardCharsets.UTF_8);
scriptWriter.write(getHiveScript(inputDir.toString(), outputDir.toString()));
scriptWriter.close();
Writer dataWriter = new OutputStreamWriter(fs.create(new Path(inputDir, DATA_FILENAME)), StandardCharsets.UTF_8);
dataWriter.write(SAMPLE_DATA_TEXT);
dataWriter.close();
Context context = createContext(getActionScriptXml());
Namespace ns = Namespace.getNamespace("uri:oozie:hive-action:0.2");
submitAction(context, ns);
FSDataInputStream os = fs.open(new Path(context.getActionDir(), LauncherAMUtils.ACTION_CONF_XML));
XConfiguration conf = new XConfiguration();
conf.addResource(os);
assertNull(conf.get("oozie.HadoopAccessorService.created"));
}
Aggregations