Search in sources :

Example 16 with XConfiguration

use of org.apache.oozie.util.XConfiguration in project oozie by apache.

the class TestLiteWorkflowAppService method testCreateprotoConf.

public void testCreateprotoConf() throws Exception {
    Services services = new Services();
    try {
        services.init();
        Reader reader = IOUtils.getResourceAsReader("wf-schema-valid.xml", -1);
        Writer writer = new FileWriter(new File(getTestCaseDir(), "workflow.xml"));
        IOUtils.copyCharStream(reader, writer);
        createTestCaseSubDir("lib");
        writer = new FileWriter(new File(getTestCaseDir(), "lib/maputil.jar"));
        writer.write("bla bla");
        writer.close();
        writer = new FileWriter(new File(getTestCaseDir(), "lib/reduceutil.so"));
        writer.write("bla bla");
        writer.close();
        createTestCaseSubDir("scripts");
        writer = new FileWriter(new File(getTestCaseDir(), "scripts/myscript.sh"));
        writer.write("bla bla");
        writer.close();
        WorkflowAppService wps = Services.get().get(WorkflowAppService.class);
        Configuration jobConf = new XConfiguration();
        jobConf.set(OozieClient.APP_PATH, getTestCaseFileUri("workflow.xml"));
        jobConf.set(OozieClient.USER_NAME, getTestUser());
        Configuration protoConf = wps.createProtoActionConf(jobConf, true);
        assertEquals(getTestUser(), protoConf.get(OozieClient.USER_NAME));
        assertEquals(2, protoConf.getStrings(WorkflowAppService.APP_LIB_PATH_LIST).length);
        List<String> found = new ArrayList<String>();
        found.add(protoConf.getStrings(WorkflowAppService.APP_LIB_PATH_LIST)[0]);
        found.add(protoConf.getStrings(WorkflowAppService.APP_LIB_PATH_LIST)[1]);
        List<String> expected = new ArrayList<String>();
        expected.add(getTestCaseFileUri("lib/reduceutil.so"));
        expected.add(getTestCaseFileUri("lib/maputil.jar"));
        Collections.sort(found);
        Collections.sort(expected);
        for (int i = 0; i < expected.size(); i++) {
            assert (new URI(expected.get(i)).equals(new URI(found.get(i))));
        }
        Assert.assertTrue(!new URI(found.get(0)).equals(new URI(found.get(1))));
    } finally {
        services.destroy();
    }
}
Also used : XConfiguration(org.apache.oozie.util.XConfiguration) Configuration(org.apache.hadoop.conf.Configuration) FileWriter(java.io.FileWriter) ArrayList(java.util.ArrayList) Reader(java.io.Reader) URI(java.net.URI) XConfiguration(org.apache.oozie.util.XConfiguration) File(java.io.File) FileWriter(java.io.FileWriter) Writer(java.io.Writer)

Example 17 with XConfiguration

use of org.apache.oozie.util.XConfiguration in project oozie by apache.

the class TestLiteWorkflowAppService method testReadDefinition.

public void testReadDefinition() throws Exception {
    Services services = new Services();
    try {
        services.init();
        Reader reader = IOUtils.getResourceAsReader("wf-schema-valid.xml", -1);
        Writer writer = new FileWriter(new File(getTestCaseDir(), "workflow.xml"));
        IOUtils.copyCharStream(reader, writer);
        Configuration conf = new XConfiguration();
        WorkflowAppService wps = services.get(WorkflowAppService.class);
        String wfDef = wps.readDefinition(getTestCaseFileUri("workflow.xml"), getTestUser(), conf);
        assertNotNull(reader.toString(), wfDef);
    } finally {
        services.destroy();
    }
}
Also used : XConfiguration(org.apache.oozie.util.XConfiguration) XConfiguration(org.apache.oozie.util.XConfiguration) Configuration(org.apache.hadoop.conf.Configuration) FileWriter(java.io.FileWriter) Reader(java.io.Reader) File(java.io.File) FileWriter(java.io.FileWriter) Writer(java.io.Writer)

Example 18 with XConfiguration

use of org.apache.oozie.util.XConfiguration in project oozie by apache.

the class TestLiteWorkflowAppService method testExtSchema.

public void testExtSchema() throws Exception {
    setSystemProperty(SchemaService.WF_CONF_EXT_SCHEMAS, "wf-ext-schema.xsd");
    setSystemProperty("oozie.service.ActionService.executor.ext.classes", TestActionExecutor.class.getName());
    Services services = new Services();
    try {
        services.init();
        Reader reader = IOUtils.getResourceAsReader("wf-ext-schema-valid.xml", -1);
        Writer writer = new FileWriter(new File(getTestCaseDir(), "workflow.xml"));
        IOUtils.copyCharStream(reader, writer);
        WorkflowAppService wps = services.get(WorkflowAppService.class);
        Configuration jobConf = new XConfiguration();
        jobConf.set(OozieClient.APP_PATH, getTestCaseFileUri("workflow.xml"));
        jobConf.set(OozieClient.USER_NAME, getTestUser());
        LiteWorkflowApp app = (LiteWorkflowApp) wps.parseDef(jobConf);
        assertNotNull(app);
        assertEquals("test-wf", app.getName());
        reader = IOUtils.getResourceAsReader("wf-ext-schema-invalid.xml", -1);
        writer = new FileWriter(new File(getTestCaseDir(), "workflow.xml"));
        IOUtils.copyCharStream(reader, writer);
        try {
            wps.parseDef(jobConf);
            fail();
        } catch (WorkflowException ex) {
        // nop
        }
    } finally {
        services.destroy();
    }
}
Also used : XConfiguration(org.apache.oozie.util.XConfiguration) XConfiguration(org.apache.oozie.util.XConfiguration) Configuration(org.apache.hadoop.conf.Configuration) LiteWorkflowApp(org.apache.oozie.workflow.lite.LiteWorkflowApp) FileWriter(java.io.FileWriter) WorkflowException(org.apache.oozie.workflow.WorkflowException) Reader(java.io.Reader) File(java.io.File) FileWriter(java.io.FileWriter) Writer(java.io.Writer)

Example 19 with XConfiguration

use of org.apache.oozie.util.XConfiguration in project oozie by apache.

the class TestLiteWorkflowAppService method testCreateprotoConfWithLibPath.

public void testCreateprotoConfWithLibPath() throws Exception {
    Services services = new Services();
    try {
        services.init();
        Reader reader = IOUtils.getResourceAsReader("wf-schema-valid.xml", -1);
        Writer writer = new FileWriter(new File(getTestCaseDir(), "workflow.xml"));
        IOUtils.copyCharStream(reader, writer);
        createTestCaseSubDir("lib");
        writer = new FileWriter(new File(getTestCaseDir(), "lib/maputil.jar"));
        writer.write("bla bla");
        writer.close();
        writer = new FileWriter(new File(getTestCaseDir(), "lib/reduceutil.so"));
        writer.write("bla bla");
        writer.close();
        createTestCaseSubDir("libx");
        writer = new FileWriter(new File(getTestCaseDir(), "libx/maputilx.jar"));
        writer.write("bla bla");
        writer.close();
        WorkflowAppService wps = Services.get().get(WorkflowAppService.class);
        Configuration jobConf = new XConfiguration();
        jobConf.set(OozieClient.APP_PATH, getTestCaseFileUri("workflow.xml"));
        jobConf.set(OozieClient.LIBPATH, getTestCaseFileUri("libx"));
        jobConf.set(OozieClient.USER_NAME, getTestUser());
        Configuration protoConf = wps.createProtoActionConf(jobConf, true);
        assertEquals(getTestUser(), protoConf.get(OozieClient.USER_NAME));
        assertEquals(3, protoConf.getStrings(WorkflowAppService.APP_LIB_PATH_LIST).length);
        List<String> found = new ArrayList<String>();
        found.add(protoConf.getStrings(WorkflowAppService.APP_LIB_PATH_LIST)[0]);
        found.add(protoConf.getStrings(WorkflowAppService.APP_LIB_PATH_LIST)[1]);
        found.add(protoConf.getStrings(WorkflowAppService.APP_LIB_PATH_LIST)[2]);
        List<String> expected = new ArrayList<String>();
        expected.add(getTestCaseFileUri("lib/reduceutil.so"));
        expected.add(getTestCaseFileUri("lib/maputil.jar"));
        expected.add(getTestCaseFileUri("libx/maputilx.jar"));
        Collections.sort(found);
        Collections.sort(expected);
        assertEquals(expected.size(), found.size());
        for (int i = 0; i < expected.size(); i++) {
            assert (new URI(expected.get(i)).equals(new URI(found.get(i))));
        }
    } finally {
        services.destroy();
    }
}
Also used : XConfiguration(org.apache.oozie.util.XConfiguration) Configuration(org.apache.hadoop.conf.Configuration) FileWriter(java.io.FileWriter) ArrayList(java.util.ArrayList) Reader(java.io.Reader) URI(java.net.URI) XConfiguration(org.apache.oozie.util.XConfiguration) File(java.io.File) FileWriter(java.io.FileWriter) Writer(java.io.Writer)

Example 20 with XConfiguration

use of org.apache.oozie.util.XConfiguration in project oozie by apache.

the class TestLiteWorkflowAppService method testCreateprotoConfWithMulipleLibPath.

public void testCreateprotoConfWithMulipleLibPath() throws Exception {
    Services services = new Services();
    try {
        services.init();
        Reader reader = IOUtils.getResourceAsReader("wf-schema-valid.xml", -1);
        Writer writer = new FileWriter(new File(getTestCaseDir(), "workflow.xml"));
        IOUtils.copyCharStream(reader, writer);
        createTestCaseSubDir("lib");
        writer = new FileWriter(new File(getTestCaseDir(), "lib/maputil.jar"));
        writer.write("bla bla");
        writer.close();
        writer = new FileWriter(new File(getTestCaseDir(), "lib/reduceutil.so"));
        writer.write("bla bla");
        writer.close();
        createTestCaseSubDir("libx");
        writer = new FileWriter(new File(getTestCaseDir(), "libx/maputil_x.jar"));
        writer.write("bla bla");
        writer.close();
        createTestCaseSubDir("liby");
        writer = new FileWriter(new File(getTestCaseDir(), "liby/maputil_y1.jar"));
        writer.write("bla bla");
        writer.close();
        writer = new FileWriter(new File(getTestCaseDir(), "liby/maputil_y2.jar"));
        writer.write("bla bla");
        writer.close();
        createTestCaseSubDir("libz");
        writer = new FileWriter(new File(getTestCaseDir(), "libz/maputil_z.jar"));
        writer.write("bla bla");
        writer.close();
        WorkflowAppService wps = Services.get().get(WorkflowAppService.class);
        Configuration jobConf = new XConfiguration();
        jobConf.set(OozieClient.APP_PATH, getTestCaseFileUri("workflow.xml"));
        jobConf.setStrings(OozieClient.LIBPATH, getTestCaseFileUri("libx"), getTestCaseFileUri("liby"), getTestCaseFileUri("libz"));
        jobConf.set(OozieClient.USER_NAME, getTestUser());
        Configuration protoConf = wps.createProtoActionConf(jobConf, true);
        assertEquals(getTestUser(), protoConf.get(OozieClient.USER_NAME));
        assertEquals(6, protoConf.getStrings(WorkflowAppService.APP_LIB_PATH_LIST).length);
        List<String> found = new ArrayList<String>();
        found.add(protoConf.getStrings(WorkflowAppService.APP_LIB_PATH_LIST)[0]);
        found.add(protoConf.getStrings(WorkflowAppService.APP_LIB_PATH_LIST)[1]);
        found.add(protoConf.getStrings(WorkflowAppService.APP_LIB_PATH_LIST)[2]);
        found.add(protoConf.getStrings(WorkflowAppService.APP_LIB_PATH_LIST)[3]);
        found.add(protoConf.getStrings(WorkflowAppService.APP_LIB_PATH_LIST)[4]);
        found.add(protoConf.getStrings(WorkflowAppService.APP_LIB_PATH_LIST)[5]);
        List<String> expected = new ArrayList<String>();
        expected.add(getTestCaseFileUri("lib/reduceutil.so"));
        expected.add(getTestCaseFileUri("lib/maputil.jar"));
        expected.add(getTestCaseFileUri("libx/maputil_x.jar"));
        expected.add(getTestCaseFileUri("liby/maputil_y1.jar"));
        expected.add(getTestCaseFileUri("liby/maputil_y2.jar"));
        expected.add(getTestCaseFileUri("libz/maputil_z.jar"));
        Collections.sort(expected);
        Collections.sort(found);
        assertEquals(expected.size(), found.size());
        for (int i = 0; i < expected.size(); i++) {
            assert (new URI(expected.get(i)).equals(new URI(found.get(i))));
        }
    } finally {
        services.destroy();
    }
}
Also used : XConfiguration(org.apache.oozie.util.XConfiguration) Configuration(org.apache.hadoop.conf.Configuration) FileWriter(java.io.FileWriter) ArrayList(java.util.ArrayList) Reader(java.io.Reader) URI(java.net.URI) XConfiguration(org.apache.oozie.util.XConfiguration) File(java.io.File) FileWriter(java.io.FileWriter) Writer(java.io.Writer)

Aggregations

XConfiguration (org.apache.oozie.util.XConfiguration)373 Configuration (org.apache.hadoop.conf.Configuration)241 Path (org.apache.hadoop.fs.Path)106 StringReader (java.io.StringReader)97 File (java.io.File)92 IOException (java.io.IOException)78 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)75 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)70 CommandException (org.apache.oozie.command.CommandException)68 Element (org.jdom.Element)66 Writer (java.io.Writer)58 Date (java.util.Date)50 FileSystem (org.apache.hadoop.fs.FileSystem)48 FileWriter (java.io.FileWriter)45 Reader (java.io.Reader)43 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)37 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)36 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)28 OutputStream (java.io.OutputStream)27 FileOutputStream (java.io.FileOutputStream)25