Search in sources :

Example 26 with WorkflowAction

use of org.apache.oozie.client.WorkflowAction in project oozie by apache.

the class JavaActionExecutor method end.

@Override
public void end(Context context, WorkflowAction action) throws ActionExecutorException {
    LOG.info("Action ended with external status [{0}]", action.getExternalStatus());
    try {
        String externalStatus = action.getExternalStatus();
        WorkflowAction.Status status = externalStatus.equals(SUCCEEDED) ? WorkflowAction.Status.OK : WorkflowAction.Status.ERROR;
        context.setEndData(status, getActionSignal(status));
    } catch (Exception ex) {
        throw convertException(ex);
    } finally {
        try {
            FileSystem actionFs = context.getAppFileSystem();
            cleanUpActionDir(actionFs, context);
        } catch (Exception ex) {
            throw convertException(ex);
        }
    }
}
Also used : WorkflowAction(org.apache.oozie.client.WorkflowAction) FileSystem(org.apache.hadoop.fs.FileSystem) URISyntaxException(java.net.URISyntaxException) JDOMException(org.jdom.JDOMException) HadoopAccessorException(org.apache.oozie.service.HadoopAccessorException) FileNotFoundException(java.io.FileNotFoundException) ActionExecutorException(org.apache.oozie.action.ActionExecutorException) ConnectException(java.net.ConnectException) ELEvaluationException(org.apache.oozie.util.ELEvaluationException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) RemoteException(org.apache.hadoop.ipc.RemoteException) AccessControlException(org.apache.hadoop.security.AccessControlException)

Example 27 with WorkflowAction

use of org.apache.oozie.client.WorkflowAction in project oozie by apache.

the class TestJavaActionExecutor method testGlobalConfigurationWithActionDefaults.

public void testGlobalConfigurationWithActionDefaults() throws Exception {
    try {
        String workflowUri = helper.createTestWorkflowXml(getWorkflowGlobalXml(), helper.getJavaActionXml(""));
        LocalOozie.start();
        final OozieClient wfClient = LocalOozie.getClient();
        Properties conf = wfClient.createConfiguration();
        conf.setProperty(OozieClient.APP_PATH, workflowUri);
        conf.setProperty(OozieClient.USER_NAME, getTestUser());
        conf.setProperty("appName", "var-app-name");
        final String jobId = wfClient.submit(conf);
        wfClient.start(jobId);
        WorkflowJob workflow = wfClient.getJobInfo(jobId);
        waitFor(20 * 1000, new Predicate() {

            @Override
            public boolean evaluate() throws Exception {
                WorkflowAction javaAction = helper.getJavaAction(wfClient.getJobInfo(jobId));
                return javaAction != null && !javaAction.getStatus().equals("PREP");
            }
        });
        final WorkflowAction workflowAction = helper.getJavaAction(workflow);
        Element eConf = XmlUtils.parseXml(workflowAction.getConf());
        Element element = eConf.getChild("configuration", eConf.getNamespace());
        Configuration actionConf = new XConfiguration(new StringReader(XmlUtils.prettyPrint(element).toString()));
        assertEquals("Config value set in <global> section is not propagated correctly", "foo2", actionConf.get("action.foo"));
    } finally {
        LocalOozie.stop();
    }
}
Also used : OozieClient(org.apache.oozie.client.OozieClient) XConfiguration(org.apache.oozie.util.XConfiguration) Configuration(org.apache.hadoop.conf.Configuration) XConfiguration(org.apache.oozie.util.XConfiguration) WorkflowAction(org.apache.oozie.client.WorkflowAction) Element(org.jdom.Element) StringReader(java.io.StringReader) Properties(java.util.Properties) WorkflowJob(org.apache.oozie.client.WorkflowJob) ActionExecutorException(org.apache.oozie.action.ActionExecutorException) IOException(java.io.IOException)

Example 28 with WorkflowAction

use of org.apache.oozie.client.WorkflowAction in project oozie by apache.

the class TestJavaActionExecutor method testResourceManagerInGlobalConfigurationCanBeOverridenWithJobTrackerInAction.

public void testResourceManagerInGlobalConfigurationCanBeOverridenWithJobTrackerInAction() throws Exception {
    try {
        final String global = "<global>" + "<resource-manager>RM</resource-manager>" + "</global>";
        final String workflowUri = helper.createTestWorkflowXml(global, helper.getJavaActionXml(""));
        LocalOozie.start();
        final OozieClient wfClient = LocalOozie.getClient();
        final Properties conf = wfClient.createConfiguration();
        conf.setProperty(OozieClient.APP_PATH, workflowUri);
        conf.setProperty(OozieClient.USER_NAME, getTestUser());
        conf.setProperty("appName", "var-app-name");
        final String jobId = wfClient.submit(conf);
        wfClient.start(jobId);
        WorkflowJob workflow = wfClient.getJobInfo(jobId);
        waitFor(20 * 1000, new Predicate() {

            @Override
            public boolean evaluate() throws Exception {
                WorkflowAction javaAction = helper.getJavaAction(wfClient.getJobInfo(jobId));
                return javaAction != null && !javaAction.getStatus().equals("PREP");
            }
        });
        final WorkflowAction workflowAction = helper.getJavaAction(workflow);
        final String actualConfig = workflowAction.getConf();
        final String actualJobTrackerURI = XmlUtils.parseXml(actualConfig).getChildTextNormalize("job-tracker", null);
        assertEquals(getJobTrackerUri(), actualJobTrackerURI);
    } finally {
        LocalOozie.stop();
    }
}
Also used : OozieClient(org.apache.oozie.client.OozieClient) WorkflowAction(org.apache.oozie.client.WorkflowAction) Properties(java.util.Properties) WorkflowJob(org.apache.oozie.client.WorkflowJob) ActionExecutorException(org.apache.oozie.action.ActionExecutorException) IOException(java.io.IOException)

Example 29 with WorkflowAction

use of org.apache.oozie.client.WorkflowAction in project oozie by apache.

the class TestSharelibConfigs method launchJavaActionAndValidateSharelibValues.

private void launchJavaActionAndValidateSharelibValues(String globalConfig, String localConfig, String oozieSharelibForJavaPropertyValue, String oozieSharelibPropertyValue) throws Exception {
    final String workflowUri = helper.createTestWorkflowXml(globalConfig, helper.getJavaActionXml(localConfig));
    final OozieClient wfClient = LocalOozie.getClient();
    final Properties conf = wfClient.createConfiguration();
    conf.setProperty(OozieClient.APP_PATH, workflowUri);
    conf.setProperty(OozieClient.USER_NAME, getTestUser());
    conf.setProperty("appName", "var-app-name");
    conf.setProperty(OozieClient.USE_SYSTEM_LIBPATH, "true");
    final String jobId = wfClient.submit(conf);
    wfClient.start(jobId);
    WorkflowJob workflow = wfClient.getJobInfo(jobId);
    waitFor(20 * 1000, new Predicate() {

        @Override
        public boolean evaluate() throws Exception {
            WorkflowAction javaAction = helper.getJavaAction(wfClient.getJobInfo(jobId));
            return javaAction != null && !javaAction.getStatus().equals("PREP");
        }
    });
    final XConfiguration actionConf = getJavaActionConfiguration(workflow);
    assertThat("Configuration priorities are incorrect! Global/local configs are not overwriting each other.", actionConf.get(LauncherAM.OOZIE_LAUNCHER_SHARELIB_PROPERTY), is(oozieSharelibPropertyValue));
    assertThat("Configuration priorities are incorrect! Global/local configs are not overwriting each other.", actionConf.get("oozie.action.sharelib.for.java"), is(oozieSharelibForJavaPropertyValue));
}
Also used : OozieClient(org.apache.oozie.client.OozieClient) XConfiguration(org.apache.oozie.util.XConfiguration) WorkflowAction(org.apache.oozie.client.WorkflowAction) Properties(java.util.Properties) WorkflowJob(org.apache.oozie.client.WorkflowJob) IOException(java.io.IOException)

Example 30 with WorkflowAction

use of org.apache.oozie.client.WorkflowAction in project oozie by apache.

the class TestShellActionExecutor method testShellScriptHadoopConfDirWithNoL4J.

/**
 * Test if a shell script could run successfully with {@link ShellMain#CONF_OOZIE_SHELL_SETUP_HADOOP_CONF_DIR} enabled.
 * Run with {@link ShellMain#CONF_OOZIE_SHELL_SETUP_HADOOP_CONF_DIR_WRITE_LOG4J_PROPERTIES} disabled.
 *
 * @throws Exception
 */
public void testShellScriptHadoopConfDirWithNoL4J() throws Exception {
    FileSystem fs = getFileSystem();
    // Create the script file with canned shell command
    Path script = new Path(getAppPath(), SHELL_SCRIPTNAME);
    Writer w = new OutputStreamWriter(fs.create(script));
    w.write(SHELL_SCRIPT_LOG4J_EXISTENCE_CHECKER);
    w.close();
    // Create sample Shell action xml
    String actionXml = "<shell>" + "<job-tracker>" + getJobTrackerUri() + "</job-tracker>" + "<name-node>" + getNameNodeUri() + "</name-node>" + "<configuration>" + "<property><name>oozie.action.shell.setup.hadoop.conf.dir</name><value>true</value></property>" + "<property><name>oozie.action.shell.setup.hadoop.conf.dir.write.log4j.properties" + "</name><value>false</value></property>" + "</configuration>" + "<exec>" + SHELL_EXEC + "</exec>" + "<argument>" + SHELL_PARAM + "</argument>" + "<argument>" + SHELL_SCRIPTNAME + "</argument>" + "<file>" + script.toString() + "#" + script.getName() + "</file>" + "<capture-output/>" + "</shell>";
    // Submit and verify the job's status
    WorkflowAction action = _testSubmit(actionXml, true, "");
    String log4jExists = PropertiesUtils.stringToProperties(action.getData()).getProperty("L4J_EXISTS");
    Assert.assertNull("Expected no log4j.properties file to exist", log4jExists);
}
Also used : Path(org.apache.hadoop.fs.Path) WorkflowAction(org.apache.oozie.client.WorkflowAction) FileSystem(org.apache.hadoop.fs.FileSystem) OutputStreamWriter(java.io.OutputStreamWriter) Writer(java.io.Writer) OutputStreamWriter(java.io.OutputStreamWriter)

Aggregations

WorkflowAction (org.apache.oozie.client.WorkflowAction)41 FileSystem (org.apache.hadoop.fs.FileSystem)9 Path (org.apache.hadoop.fs.Path)8 IOException (java.io.IOException)6 ActionExecutorException (org.apache.oozie.action.ActionExecutorException)6 WorkflowJob (org.apache.oozie.client.WorkflowJob)6 Writer (java.io.Writer)5 Properties (java.util.Properties)5 OozieClient (org.apache.oozie.client.OozieClient)5 XConfiguration (org.apache.oozie.util.XConfiguration)5 OutputStreamWriter (java.io.OutputStreamWriter)4 Configuration (org.apache.hadoop.conf.Configuration)3 Element (org.jdom.Element)3 File (java.io.File)2 Reader (java.io.Reader)2 StringReader (java.io.StringReader)2 URISyntaxException (java.net.URISyntaxException)2 AccessControlException (org.apache.hadoop.security.AccessControlException)2 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)2 HadoopAccessorException (org.apache.oozie.service.HadoopAccessorException)2