Search in sources :

Example 26 with ActionExecutorException

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

the class TestJavaActionExecutor method testCredentialsInvalid.

public void testCredentialsInvalid() throws Exception {
    String workflowXml = "<workflow-app xmlns='uri:oozie:workflow:0.2.5' name='pig-wf'>" + "<credentials>" + "<credential name='abcname' type='abc'>" + "<property>" + "<name>property1</name>" + "<value>value1</value>" + "</property>" + "<property>" + "<name>property2</name>" + "<value>value2</value>" + "</property>" + "<property>" + "<name>${property3}</name>" + "<value>${value3}</value>" + "</property>" + "</credential>" + "</credentials>" + "<start to='pig1' />" + "<action name='pig1' cred='abcname'>" + "<pig>" + "</pig>" + "<ok to='end' />" + "<error to='fail' />" + "</action>" + "<kill name='fail'>" + "<message>Pig failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>" + "</kill>" + "<end name='end' />" + "</workflow-app>";
    JavaActionExecutor ae = new JavaActionExecutor();
    WorkflowJobBean wfBean = addRecordToWfJobTable("test1", workflowXml);
    WorkflowActionBean action = (WorkflowActionBean) wfBean.getActions().get(0);
    action.setType(ae.getType());
    action.setCred("invalidabcname");
    String actionXml = "<pig>" + "<job-tracker>${jobTracker}</job-tracker>" + "<name-node>${nameNode}</name-node>" + "<prepare>" + "<delete path='outputdir' />" + "</prepare>" + "<configuration>" + "<property>" + "<name>mapred.compress.map.output</name>" + "<value>true</value>" + "</property>" + "<property>" + "<name>mapred.job.queue.name</name>" + "<value>${queueName}</value>" + "</property>" + "</configuration>" + "<script>org/apache/oozie/examples/pig/id.pig</script>" + "<param>INPUT=${inputDir}</param>" + "<param>OUTPUT=${outputDir}/pig-output</param>" + "</pig>";
    action.setConf(actionXml);
    Context context = new Context(wfBean, action);
    Element actionXmlconf = XmlUtils.parseXml(action.getConf());
    // action job configuration
    Configuration actionConf = ae.createBaseHadoopConf(context, actionXmlconf);
    try {
        // Setting the credential properties in launcher conf should fail
        ae.setCredentialPropertyToActionConf(context, action, actionConf);
    } catch (ActionExecutorException e) {
        assertEquals(e.getErrorCode(), "JA021");
    }
}
Also used : 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 27 with ActionExecutorException

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

the class TestJavaActionExecutor method testFilesystemScheme.

public void testFilesystemScheme() throws Exception {
    try {
        String actionXml = "<java>" + "<job-tracker>" + getJobTrackerUri() + "</job-tracker>" + "<name-node>" + getNameNodeUri() + "</name-node>" + "<main-class>" + LauncherMainTester.class.getName() + "</main-class>" + "</java>";
        Element eActionXml = XmlUtils.parseXml(actionXml);
        Context context = createContext(actionXml, null);
        Path appPath = new Path("localfs://namenode:port/mydir");
        JavaActionExecutor ae = new JavaActionExecutor();
        Configuration conf = ae.createBaseHadoopConf(context, eActionXml);
        Services.get().destroy();
        setSystemProperty(HadoopAccessorService.SUPPORTED_FILESYSTEMS, "hdfs,viewfs");
        new Services().init();
        ae.setupActionConf(conf, context, eActionXml, appPath);
        fail("Supposed to throw exception due to unsupported fs scheme - localfs");
    } catch (ActionExecutorException ae) {
        assertTrue(ae.getMessage().contains("E0904"));
        assertTrue(ae.getMessage().contains("Scheme [localfs] not supported"));
    }
}
Also used : Path(org.apache.hadoop.fs.Path) 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)

Example 28 with ActionExecutorException

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

the class TestFsActionExecutor method testvalidateSameNN.

public void testvalidateSameNN() throws Exception {
    FsActionExecutor ae = new FsActionExecutor();
    ae.validateSameNN(new Path("hdfs://x/bla"), new Path("hdfs://x/foo"));
    try {
        ae.validateSameNN(new Path("hdfs://x/bla"), new Path("viefs://x/bla"));
        fail();
    } catch (ActionExecutorException ex) {
        assertEquals("FS007", ex.getErrorCode());
    }
    try {
        ae.validateSameNN(new Path("hdfs://x/bla"), new Path("hdfs://y/bla"));
        fail();
    } catch (ActionExecutorException ex) {
        assertEquals("FS007", ex.getErrorCode());
    }
}
Also used : Path(org.apache.hadoop.fs.Path) ActionExecutorException(org.apache.oozie.action.ActionExecutorException)

Example 29 with ActionExecutorException

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

the class TestFsActionExecutor method testValidatePath.

public void testValidatePath() throws Exception {
    FsActionExecutor ae = new FsActionExecutor();
    ae.validatePath(new Path("hdfs://x/bla"), true);
    ae.validatePath(new Path("bla"), false);
    try {
        ae.validatePath(new Path("hdfs://x/bla"), false);
        fail();
    } catch (ActionExecutorException ex) {
        assertEquals("FS002", ex.getErrorCode());
    }
    try {
        ae.validatePath(new Path("bla"), true);
        fail();
    } catch (ActionExecutorException ex) {
        assertEquals("FS001", ex.getErrorCode());
    }
    // testing schemes supported
    Services.get().destroy();
    setSystemProperty(HadoopAccessorService.SUPPORTED_FILESYSTEMS, "hdfs,viewfs");
    new Services().init();
    try {
        ae.validatePath(new Path("viewfs://bla"), true);
    } catch (ActionExecutorException ex) {
        fail("viewfs is a supported scheme. This should not throw exception");
    }
    try {
        ae.validatePath(new Path("file://bla"), true);
        fail("file is not a supported scheme. This should throw exception");
    } catch (ActionExecutorException ex) {
        assertTrue(ex.getMessage().contains("E0904"));
    }
}
Also used : Path(org.apache.hadoop.fs.Path) Services(org.apache.oozie.service.Services) ActionExecutorException(org.apache.oozie.action.ActionExecutorException)

Example 30 with ActionExecutorException

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

the class TestFsActionExecutor method testRecovery.

public void testRecovery() throws Exception {
    FsActionExecutor ae = new FsActionExecutor();
    FileSystem fs = getFileSystem();
    Path mkdir = new Path(getFsTestCaseDir(), "mkdir");
    Path delete = new Path(getFsTestCaseDir(), "delete");
    fs.mkdirs(delete);
    Path source = new Path(getFsTestCaseDir(), "source");
    fs.mkdirs(source);
    Path target = new Path(new Path(getFsTestCaseDir(), "target").toUri().getPath());
    Path chmod1 = new Path(getFsTestCaseDir(), "chmod1");
    fs.mkdirs(chmod1);
    Path child1 = new Path(chmod1, "child1");
    fs.mkdirs(child1);
    Path chmod2 = new Path(getFsTestCaseDir(), "chmod2");
    fs.mkdirs(chmod2);
    Path child2 = new Path(chmod2, "child2");
    fs.mkdirs(child2);
    String actionXml = MessageFormat.format("<fs>" + "<mkdir path=''{0}''/>" + "<delete path=''{1}''/>" + "<move source=''{2}'' target=''{3}''/>" + "<chmod path=''{4}'' permissions=''111''/>" + "<chmod path=''{5}'' permissions=''222'' dir-files=''false''/>" + "</fs>", mkdir, delete, source.toUri().getPath(), target, chmod1, chmod2);
    String id = "ID" + System.currentTimeMillis();
    Context context = createContext(actionXml);
    ((WorkflowJobBean) context.getWorkflow()).setId(id);
    ((WorkflowActionBean) context.getWorkflow().getActions().get(0)).setJobId(id);
    ((WorkflowActionBean) context.getWorkflow().getActions().get(0)).setId(id + "-FS");
    WorkflowAction action = context.getAction();
    assertFalse(fs.exists(ae.getRecoveryPath(context)));
    try {
        ae.start(context, action);
    } catch (ActionExecutorException ex) {
        if (!ex.getErrorCode().equals("FS001")) {
            throw ex;
        }
    }
    assertTrue(fs.exists(mkdir));
    assertFalse(fs.exists(delete));
    assertTrue(fs.exists(ae.getRecoveryPath(context)));
    actionXml = MessageFormat.format("<fs>" + "<mkdir path=''{0}''/>" + "<delete path=''{1}''/>" + "<move source=''{2}'' target=''{3}''/>" + "<chmod path=''{4}'' permissions=''-rwxrwxrwx''/>" + "<chmod path=''{5}'' permissions=''-rwxrwx---'' dir-files=''false''/>" + "</fs>", mkdir, delete, source, target, chmod1, chmod2);
    context = createContext(actionXml);
    ((WorkflowJobBean) context.getWorkflow()).setId(id);
    ((WorkflowActionBean) context.getWorkflow().getActions().get(0)).setJobId(id);
    ((WorkflowActionBean) context.getWorkflow().getActions().get(0)).setId(id + "-FS");
    action = context.getAction();
    ae.start(context, action);
    ae.check(context, context.getAction());
    assertEquals("OK", context.getAction().getExternalStatus());
    assertNull(context.getAction().getData());
    ae.end(context, context.getAction());
    assertEquals(WorkflowAction.Status.OK, context.getAction().getStatus());
    assertFalse(fs.exists(ae.getRecoveryPath(context)));
    assertTrue(fs.exists(mkdir));
    assertFalse(fs.exists(delete));
    assertFalse(fs.exists(source));
    assertTrue(fs.exists(target));
    assertEquals("rwxrwxrwx", fs.getFileStatus(chmod1).getPermission().toString());
    assertNotSame("rwxrwxrwx", fs.getFileStatus(child1).getPermission().toString());
    assertEquals("rwxrwx---", fs.getFileStatus(chmod2).getPermission().toString());
    assertNotSame("rwxrwx---", fs.getFileStatus(child2).getPermission().toString());
}
Also used : Path(org.apache.hadoop.fs.Path) WorkflowAction(org.apache.oozie.client.WorkflowAction) FileSystem(org.apache.hadoop.fs.FileSystem) ActionExecutorException(org.apache.oozie.action.ActionExecutorException) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) WorkflowActionBean(org.apache.oozie.WorkflowActionBean)

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