Search in sources :

Example 31 with ActionExecutorException

use of org.apache.oozie.action.ActionExecutorException in project oozie by apache.

the class TestFsActionExecutor method testChmodRelativePath.

public void testChmodRelativePath() throws Exception {
    FsActionExecutor ae = new FsActionExecutor();
    FileSystem fs = getFileSystem();
    Context context = createContext("<fs/>");
    Path basePath = new Path(getFsTestCaseDir(), "2010");
    createTestDirForChmod(basePath, fs);
    Path globPath = new Path(basePath + "/1[0-1]");
    Path relativePath = new Path(globPath.toUri().getPath());
    Path nameNode = new Path(globPath.toUri().getScheme() + "://" + globPath.toUri().getAuthority());
    ae.chmod(context, null, nameNode, relativePath, "-rwx------", false, false);
    assertEquals("rwx------", fs.getFileStatus(new Path(basePath, "10")).getPermission().toString());
    assertEquals("rwx------", fs.getFileStatus(new Path(basePath, "11")).getPermission().toString());
    assertEquals("rwxrwxrwx", fs.getFileStatus(new Path(basePath, "12")).getPermission().toString());
    assertEquals("rwxrwxrwx", fs.getFileStatus(new Path(basePath + "/10/dir1")).getPermission().toString());
    assertEquals("rwxrwxrwx", fs.getFileStatus(new Path(basePath + "/10/dir2")).getPermission().toString());
    assertEquals("rwxrwxrwx", fs.getFileStatus(new Path(basePath + "/11/dir3")).getPermission().toString());
    assertEquals("rw-rw-rw-", fs.getFileStatus(new Path(basePath + "/10/dir1/file1")).getPermission().toString());
    try {
        ae.chmod(context, null, null, relativePath, "-rwx-----", false, false);
        fail();
    } catch (ActionExecutorException e) {
        assertEquals(e.getErrorCode(), "FS001");
    }
    fs.delete(basePath, true);
}
Also used : Path(org.apache.hadoop.fs.Path) FileSystem(org.apache.hadoop.fs.FileSystem) ActionExecutorException(org.apache.oozie.action.ActionExecutorException)

Example 32 with ActionExecutorException

use of org.apache.oozie.action.ActionExecutorException in project oozie by apache.

the class TestDecisionActionExecutor method testDecision.

public void testDecision() throws Exception {
    new Services().init();
    try {
        ActionExecutor decision = new DecisionActionExecutor();
        assertEquals(DecisionActionExecutor.ACTION_TYPE, decision.getType());
        WorkflowActionBean action = new WorkflowActionBean();
        action.setConf("<switch xmlns='uri:oozie:workflow:0.1'>" + "<case to='a'>true</case>" + "<case to='b'>true</case>" + "<case to='c'>false</case>" + "<default to='d'/></switch>");
        decision.start(new Context(action), action);
        assertEquals(WorkflowAction.Status.DONE, action.getStatus());
        decision.end(new Context(action), action);
        assertEquals(WorkflowAction.Status.OK, action.getStatus());
        assertEquals("a", action.getExternalStatus());
        action.setConf("<switch xmlns='uri:oozie:workflow:0.1'>" + "<case to='a'>false</case>" + "<case to='b'>true</case>" + "<case to='c'>false</case>" + "<default to='d'/></switch>");
        decision.start(new Context(action), action);
        assertEquals(WorkflowAction.Status.DONE, action.getStatus());
        decision.end(new Context(action), action);
        assertEquals(WorkflowAction.Status.OK, action.getStatus());
        assertEquals("b", action.getExternalStatus());
        action.setConf("<switch xmlns='uri:oozie:workflow:0.1'>" + "<case to='a'>false</case>" + "<case to='b'>false</case>" + "<case to='c'>false</case>" + "<default to='d'/></switch>");
        decision.start(new Context(action), action);
        assertEquals(WorkflowAction.Status.DONE, action.getStatus());
        decision.end(new Context(action), action);
        assertEquals(WorkflowAction.Status.OK, action.getStatus());
        assertEquals("d", action.getExternalStatus());
        try {
            action.setConf("<wrong>" + "<case to='a'>false</case>" + "<case to='b'>false</case>" + "<case to='c'>false</case>" + "<default to='d'/></switch>");
            decision.start(new Context(action), action);
            fail();
        } catch (ActionExecutorException ex) {
            assertEquals(ActionExecutorException.ErrorType.FAILED, ex.getErrorType());
            assertEquals(DecisionActionExecutor.XML_ERROR, ex.getErrorCode());
        } catch (Exception ex) {
            fail();
        }
    } finally {
        Services.get().destroy();
    }
}
Also used : Services(org.apache.oozie.service.Services) ActionExecutor(org.apache.oozie.action.ActionExecutor) ActionExecutorException(org.apache.oozie.action.ActionExecutorException) WorkflowActionBean(org.apache.oozie.WorkflowActionBean) URISyntaxException(java.net.URISyntaxException) ActionExecutorException(org.apache.oozie.action.ActionExecutorException) IOException(java.io.IOException)

Example 33 with ActionExecutorException

use of org.apache.oozie.action.ActionExecutorException in project oozie by apache.

the class TestEmailActionExecutor method testLocalFileAttachmentError.

public void testLocalFileAttachmentError() throws Exception {
    File attachFile1 = new File(getTestCaseDir() + File.separator + "attachment1.txt");
    String content1 = "this is attachment content in file1";
    File attachFile2 = new File(getTestCaseDir() + File.separator + "attachment2.txt");
    String content2 = "this is attachment content in file2";
    BufferedWriter output = new BufferedWriter(new FileWriter(attachFile1));
    output.write(content1);
    output.close();
    output = new BufferedWriter(new FileWriter(attachFile2));
    output.write(content2);
    output.close();
    StringBuilder tag = new StringBuilder();
    tag.append("file://").append(attachFile1.getAbsolutePath()).append(",file://").append(attachFile2.getAbsolutePath());
    // local file not attached to email (for security reason)
    try {
        assertAttachment(tag.toString(), 0, content1, content2);
        fail();
    } catch (ActionExecutorException e) {
        assertEquals("EM008", e.getErrorCode());
    }
}
Also used : FileWriter(java.io.FileWriter) ActionExecutorException(org.apache.oozie.action.ActionExecutorException) File(java.io.File) BufferedWriter(java.io.BufferedWriter)

Example 34 with ActionExecutorException

use of org.apache.oozie.action.ActionExecutorException in project oozie by apache.

the class TestMapReduceActionExecutor method testSetupMethods.

public void testSetupMethods() throws Exception {
    MapReduceActionExecutor ae = new MapReduceActionExecutor();
    List<Class<?>> classes = Arrays.<Class<?>>asList(StreamingMain.class);
    assertEquals(classes, ae.getLauncherClasses());
    Element actionXml = XmlUtils.parseXml("<map-reduce>" + "<job-tracker>" + getJobTrackerUri() + "</job-tracker>" + "<name-node>" + getNameNodeUri() + "</name-node>" + "<configuration>" + "<property><name>mapred.input.dir</name><value>IN</value></property>" + "<property><name>mapred.output.dir</name><value>OUT</value></property>" + "</configuration>" + "</map-reduce>");
    XConfiguration protoConf = new XConfiguration();
    protoConf.set(WorkflowAppService.HADOOP_USER, getTestUser());
    WorkflowJobBean wf = createBaseWorkflow(protoConf, "mr-action");
    WorkflowActionBean action = (WorkflowActionBean) wf.getActions().get(0);
    action.setType(ae.getType());
    Context context = new Context(wf, action);
    Configuration conf = ae.createBaseHadoopConf(context, actionXml);
    ae.setupActionConf(conf, context, actionXml, getFsTestCaseDir());
    assertEquals("IN", conf.get("mapred.input.dir"));
    Configuration launcherJobConf = ae.createLauncherConf(getFileSystem(), context, action, actionXml, conf);
    assertEquals(false, launcherJobConf.getBoolean("mapreduce.job.complete.cancel.delegation.tokens", true));
    assertEquals(true, conf.getBoolean("mapreduce.job.complete.cancel.delegation.tokens", false));
    // Enable uber jars to test that MapReduceActionExecutor picks up the oozie.mapreduce.uber.jar property correctly
    Services serv = Services.get();
    boolean originalUberJarDisabled = serv.getConf().getBoolean("oozie.action.mapreduce.uber.jar.enable", false);
    serv.getConf().setBoolean("oozie.action.mapreduce.uber.jar.enable", true);
    actionXml = createUberJarActionXML(getNameNodeUri() + "/app/job.jar", "");
    conf = ae.createBaseHadoopConf(context, actionXml);
    ae.setupActionConf(conf, context, actionXml, getFsTestCaseDir());
    // absolute path with namenode
    assertEquals(getNameNodeUri() + "/app/job.jar", conf.get(MapReduceMain.OOZIE_MAPREDUCE_UBER_JAR));
    actionXml = createUberJarActionXML("/app/job.jar", "");
    conf = ae.createBaseHadoopConf(context, actionXml);
    ae.setupActionConf(conf, context, actionXml, getFsTestCaseDir());
    // absolute path without namenode
    assertEquals(getNameNodeUri() + "/app/job.jar", conf.get(MapReduceMain.OOZIE_MAPREDUCE_UBER_JAR));
    actionXml = createUberJarActionXML("job.jar", "");
    conf = ae.createBaseHadoopConf(context, actionXml);
    ae.setupActionConf(conf, context, actionXml, getFsTestCaseDir());
    // relative path
    assertEquals(getFsTestCaseDir() + "/job.jar", conf.get(MapReduceMain.OOZIE_MAPREDUCE_UBER_JAR));
    actionXml = createUberJarActionXML("job.jar", "<streaming></streaming>");
    conf = ae.createBaseHadoopConf(context, actionXml);
    ae.setupActionConf(conf, context, actionXml, getFsTestCaseDir());
    // ignored for streaming
    assertEquals("", conf.get(MapReduceMain.OOZIE_MAPREDUCE_UBER_JAR));
    actionXml = createUberJarActionXML("job.jar", "<pipes></pipes>");
    conf = ae.createBaseHadoopConf(context, actionXml);
    ae.setupActionConf(conf, context, actionXml, getFsTestCaseDir());
    // ignored for pipes
    assertEquals("", conf.get("oozie.mapreduce.uber.jar"));
    actionXml = XmlUtils.parseXml("<map-reduce>" + "<job-tracker>" + getJobTrackerUri() + "</job-tracker>" + "<name-node>" + getNameNodeUri() + "</name-node>" + "</map-reduce>");
    conf = ae.createBaseHadoopConf(context, actionXml);
    ae.setupActionConf(conf, context, actionXml, getFsTestCaseDir());
    // doesn't resolve if not set
    assertNull(conf.get("oozie.mapreduce.uber.jar"));
    // Disable uber jars to test that MapReduceActionExecutor won't allow the oozie.mapreduce.uber.jar property
    serv.getConf().setBoolean("oozie.action.mapreduce.uber.jar.enable", false);
    try {
        actionXml = createUberJarActionXML(getNameNodeUri() + "/app/job.jar", "");
        conf = ae.createBaseHadoopConf(context, actionXml);
        ae.setupActionConf(conf, context, actionXml, getFsTestCaseDir());
        fail("ActionExecutorException expected because uber jars are disabled");
    } catch (ActionExecutorException aee) {
        assertEquals("MR003", aee.getErrorCode());
        assertEquals(ActionExecutorException.ErrorType.ERROR, aee.getErrorType());
        assertTrue(aee.getMessage().contains("oozie.action.mapreduce.uber.jar.enable"));
        assertTrue(aee.getMessage().contains("oozie.mapreduce.uber.jar"));
    }
    serv.getConf().setBoolean("oozie.action.mapreduce.uber.jar.enable", originalUberJarDisabled);
    actionXml = XmlUtils.parseXml("<map-reduce>" + "<job-tracker>" + getJobTrackerUri() + "</job-tracker>" + "<name-node>" + getNameNodeUri() + "</name-node>" + "<streaming>" + "<mapper>M</mapper>" + "<reducer>R</reducer>" + "<record-reader>RR</record-reader>" + "<record-reader-mapping>RRM1=1</record-reader-mapping>" + "<record-reader-mapping>RRM2=2</record-reader-mapping>" + "<env>e=E</env>" + "<env>ee=EE</env>" + "</streaming>" + "<configuration>" + "<property><name>mapred.input.dir</name><value>IN</value></property>" + "<property><name>mapred.output.dir</name><value>OUT</value></property>" + "</configuration>" + "</map-reduce>");
    conf = ae.createBaseHadoopConf(context, actionXml);
    ae.setupActionConf(conf, context, actionXml, getFsTestCaseDir());
    assertEquals("M", conf.get("oozie.streaming.mapper"));
    assertEquals("R", conf.get("oozie.streaming.reducer"));
    assertEquals("RR", conf.get("oozie.streaming.record-reader"));
    assertEquals("2", conf.get("oozie.streaming.record-reader-mapping.size"));
    assertEquals("2", conf.get("oozie.streaming.env.size"));
    actionXml = XmlUtils.parseXml("<map-reduce>" + "<job-tracker>" + getJobTrackerUri() + "</job-tracker>" + "<name-node>" + getNameNodeUri() + "</name-node>" + "<pipes>" + "<map>M</map>" + "<reduce>R</reduce>" + "<inputformat>IF</inputformat>" + "<partitioner>P</partitioner>" + "<writer>W</writer>" + "<program>PP</program>" + "</pipes>" + "<configuration>" + "<property><name>mapred.input.dir</name><value>IN</value></property>" + "<property><name>mapred.output.dir</name><value>OUT</value></property>" + "</configuration>" + "</map-reduce>");
    conf = ae.createBaseHadoopConf(context, actionXml);
    ae.setupActionConf(conf, context, actionXml, getFsTestCaseDir());
    assertEquals("M", conf.get("oozie.pipes.map"));
    assertEquals("R", conf.get("oozie.pipes.reduce"));
    assertEquals("IF", conf.get("oozie.pipes.inputformat"));
    assertEquals("P", conf.get("oozie.pipes.partitioner"));
    assertEquals("W", conf.get("oozie.pipes.writer"));
    assertEquals(getFsTestCaseDir() + "/PP", conf.get("oozie.pipes.program"));
}
Also used : XConfiguration(org.apache.oozie.util.XConfiguration) Services(org.apache.oozie.service.Services) Configuration(org.apache.hadoop.conf.Configuration) XConfiguration(org.apache.oozie.util.XConfiguration) Element(org.jdom.Element) ActionExecutorException(org.apache.oozie.action.ActionExecutorException) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) WorkflowActionBean(org.apache.oozie.WorkflowActionBean)

Example 35 with ActionExecutorException

use of org.apache.oozie.action.ActionExecutorException in project oozie by apache.

the class TestMapReduceActionExecutor method testMapReduceWithUberJarDisabled.

// With the oozie.action.mapreduce.uber.jar.enable property set to false, a workflow with an uber jar should fail
public void testMapReduceWithUberJarDisabled() throws Exception {
    Services serv = Services.get();
    boolean originalUberJarDisabled = serv.getConf().getBoolean("oozie.action.mapreduce.uber.jar.enable", false);
    try {
        serv.getConf().setBoolean("oozie.action.mapreduce.uber.jar.enable", false);
        _testMapReduceWithUberJar();
    } catch (ActionExecutorException aee) {
        assertEquals("MR003", aee.getErrorCode());
        assertEquals(ActionExecutorException.ErrorType.ERROR, aee.getErrorType());
        assertTrue(aee.getMessage().contains("oozie.action.mapreduce.uber.jar.enable"));
        assertTrue(aee.getMessage().contains("oozie.mapreduce.uber.jar"));
    } catch (Exception e) {
        throw e;
    } finally {
        serv.getConf().setBoolean("oozie.action.mapreduce.uber.jar.enable", originalUberJarDisabled);
    }
}
Also used : Services(org.apache.oozie.service.Services) ActionExecutorException(org.apache.oozie.action.ActionExecutorException) FileNotFoundException(java.io.FileNotFoundException) ActionExecutorException(org.apache.oozie.action.ActionExecutorException) IOException(java.io.IOException)

Aggregations

ActionExecutorException (org.apache.oozie.action.ActionExecutorException)75 Path (org.apache.hadoop.fs.Path)41 IOException (java.io.IOException)39 Element (org.jdom.Element)28 URISyntaxException (java.net.URISyntaxException)27 FileSystem (org.apache.hadoop.fs.FileSystem)25 HadoopAccessorException (org.apache.oozie.service.HadoopAccessorException)24 XConfiguration (org.apache.oozie.util.XConfiguration)23 Configuration (org.apache.hadoop.conf.Configuration)20 AccessControlException (org.apache.hadoop.security.AccessControlException)20 Namespace (org.jdom.Namespace)13 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)12 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)12 JDOMException (org.jdom.JDOMException)12 FileNotFoundException (java.io.FileNotFoundException)10 ELEvaluationException (org.apache.oozie.util.ELEvaluationException)10 ConnectException (java.net.ConnectException)9 UnknownHostException (java.net.UnknownHostException)9 RemoteException (org.apache.hadoop.ipc.RemoteException)9 ArrayList (java.util.ArrayList)8