Search in sources :

Example 41 with Namespace

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)}");
}
Also used : Path(org.apache.hadoop.fs.Path) XConfiguration(org.apache.oozie.util.XConfiguration) CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) XConfiguration(org.apache.oozie.util.XConfiguration) Configuration(org.apache.hadoop.conf.Configuration) Element(org.jdom2.Element) Namespace(org.jdom2.Namespace)

Example 42 with Namespace

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;
}
Also used : XConfiguration(org.apache.oozie.util.XConfiguration) Element(org.jdom2.Element) StringReader(java.io.StringReader) Namespace(org.jdom2.Namespace)

Example 43 with Namespace

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());
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) WorkflowAppService(org.apache.oozie.service.WorkflowAppService) HashMap(java.util.HashMap) Element(org.jdom2.Element) HashMap(java.util.HashMap) Map(java.util.Map) Namespace(org.jdom2.Namespace)

Example 44 with Namespace

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"));
}
Also used : XConfiguration(org.apache.oozie.util.XConfiguration) Element(org.jdom2.Element) StringReader(java.io.StringReader) WorkflowActionGetJPAExecutor(org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor) JPAService(org.apache.oozie.service.JPAService) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) WorkflowActionBean(org.apache.oozie.WorkflowActionBean) Namespace(org.jdom2.Namespace)

Example 45 with Namespace

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"));
}
Also used : Path(org.apache.hadoop.fs.Path) XConfiguration(org.apache.oozie.util.XConfiguration) FileSystem(org.apache.hadoop.fs.FileSystem) FSDataInputStream(org.apache.hadoop.fs.FSDataInputStream) OutputStreamWriter(java.io.OutputStreamWriter) Writer(java.io.Writer) OutputStreamWriter(java.io.OutputStreamWriter) Namespace(org.jdom2.Namespace)

Aggregations

Namespace (org.jdom2.Namespace)156 Element (org.jdom2.Element)128 IOException (java.io.IOException)34 HashMap (java.util.HashMap)24 List (java.util.List)24 Document (org.jdom2.Document)24 ArrayList (java.util.ArrayList)23 Attribute (org.jdom2.Attribute)21 XConfiguration (org.apache.oozie.util.XConfiguration)19 Map (java.util.Map)15 Configuration (org.apache.hadoop.conf.Configuration)15 StringReader (java.io.StringReader)14 ActionExecutorException (org.apache.oozie.action.ActionExecutorException)14 JDOMException (org.jdom2.JDOMException)14 Namespace.getNamespace (org.jdom2.Namespace.getNamespace)14 MigrationReport (com.mulesoft.tools.migration.step.category.MigrationReport)13 SAXBuilder (org.jdom2.input.SAXBuilder)13 File (java.io.File)12 Path (org.apache.hadoop.fs.Path)12 Optional (java.util.Optional)10