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);
}
}
}
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();
}
}
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();
}
}
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));
}
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);
}
Aggregations