use of com.google.cloud.servicedirectory.v1.Namespace in project oozie by apache.
the class PigActionExecutor method setupActionConf.
@Override
Configuration setupActionConf(Configuration actionConf, Context context, Element actionXml, Path appPath) throws ActionExecutorException {
super.setupActionConf(actionConf, context, actionXml, appPath);
Namespace ns = actionXml.getNamespace();
String script = actionXml.getChild("script", ns).getTextTrim();
String pigName = new Path(script).getName();
@SuppressWarnings("unchecked") List<Element> params = actionXml.getChildren("param", ns);
String[] strParams = new String[params.size()];
for (int i = 0; i < params.size(); i++) {
strParams[i] = params.get(i).getTextTrim();
}
String[] strArgs = null;
@SuppressWarnings("unchecked") List<Element> eArgs = actionXml.getChildren("argument", ns);
if (eArgs != null && eArgs.size() > 0) {
strArgs = new String[eArgs.size()];
for (int i = 0; i < eArgs.size(); i++) {
strArgs[i] = eArgs.get(i).getTextTrim();
}
}
setPigScript(actionConf, pigName, strParams, strArgs);
return actionConf;
}
use of com.google.cloud.servicedirectory.v1.Namespace in project oozie by apache.
the class ShellActionExecutor method setupActionConf.
@Override
Configuration setupActionConf(Configuration actionConf, Context context, Element actionXml, Path appPath) throws ActionExecutorException {
super.setupActionConf(actionConf, context, actionXml, appPath);
Namespace ns = actionXml.getNamespace();
String exec = actionXml.getChild("exec", ns).getTextTrim();
String execName = new Path(exec).getName();
actionConf.set(ShellMain.CONF_OOZIE_SHELL_EXEC, execName);
// Setting Shell command's arguments
setListInConf("argument", actionXml, actionConf, ShellMain.CONF_OOZIE_SHELL_ARGS, false);
// Setting Shell command's environment variable key=value
setListInConf("env-var", actionXml, actionConf, ShellMain.CONF_OOZIE_SHELL_ENVS, true);
// Setting capture output flag
actionConf.setBoolean(ShellMain.CONF_OOZIE_SHELL_CAPTURE_OUTPUT, actionXml.getChild("capture-output", ns) != null);
// Setting if ShellMain should setup HADOOP_CONF_DIR
boolean setupHadoopConfDir = actionConf.getBoolean(ShellMain.CONF_OOZIE_SHELL_SETUP_HADOOP_CONF_DIR, ConfigurationService.getBoolean(ShellMain.CONF_OOZIE_SHELL_SETUP_HADOOP_CONF_DIR));
actionConf.setBoolean(ShellMain.CONF_OOZIE_SHELL_SETUP_HADOOP_CONF_DIR, setupHadoopConfDir);
// Setting to control if ShellMain should write log4j.properties
boolean writeL4J = actionConf.getBoolean(ShellMain.CONF_OOZIE_SHELL_SETUP_HADOOP_CONF_DIR_WRITE_LOG4J_PROPERTIES, ConfigurationService.getBoolean(ShellMain.CONF_OOZIE_SHELL_SETUP_HADOOP_CONF_DIR_WRITE_LOG4J_PROPERTIES));
actionConf.setBoolean(ShellMain.CONF_OOZIE_SHELL_SETUP_HADOOP_CONF_DIR_WRITE_LOG4J_PROPERTIES, writeL4J);
// Setting of content of log4j.properties, if to be written
if (writeL4J) {
String l4jContent = actionConf.get(ShellMain.CONF_OOZIE_SHELL_SETUP_HADOOP_CONF_DIR_LOG4J_CONTENT, ConfigurationService.get(ShellMain.CONF_OOZIE_SHELL_SETUP_HADOOP_CONF_DIR_LOG4J_CONTENT));
actionConf.set(ShellMain.CONF_OOZIE_SHELL_SETUP_HADOOP_CONF_DIR_LOG4J_CONTENT, l4jContent);
}
return actionConf;
}
use of com.google.cloud.servicedirectory.v1.Namespace in project oozie by apache.
the class TestCoordSubmitXCommand method testDuplicateDatasetNameInIncludeFile.
/**
* https://issues.apache.org/jira/browse/OOZIE-1211
* If a datasets include file has a dataset name as in one defined in coordinator.xml,
* the one in coordinator.xml should be honored.
* http://oozie.apache.org/docs/3.3.1/CoordinatorFunctionalSpec.html#a10.1.1._Dataset_Names_Collision_Resolution
*
* @throws Exception
*/
public void testDuplicateDatasetNameInIncludeFile() throws Exception {
Configuration conf = new XConfiguration();
final File includePathFile = new File(getTestCaseDir(), "include1.xml");
final String URI_TEMPLATE_INCLUDE_XML = "file:///tmp/include_xml/workflows/${YEAR}/${DAY}";
final String URI_TEMPLATE_COORD_XML = "file:///tmp/coord_xml/workflows/${YEAR}/${DAY}";
String includeXml = "<datasets> " + "<dataset name=\"B\" frequency=\"${coord:days(7)}\" initial-instance=\"2009-02-01T01:00Z\" timezone=\"UTC\">" + "<uri-template>" + URI_TEMPLATE_INCLUDE_XML + "</uri-template>" + "</dataset> " + "</datasets>";
writeToFile(includeXml, includePathFile);
File appPathFile = new File(getTestCaseDir(), "coordinator.xml");
String appXml = "<coordinator-app name=\"${appName}-foo\" frequency=\"${coord:days(1)}\" start=\"2009-02-01T01:00Z\" " + "end=\"2009-02-03T23:59Z\" timezone=\"UTC\" xmlns=\"uri:oozie:coordinator:0.2\">" + "<controls> " + "<execution>LIFO</execution>" + "</controls>" + "<datasets> " + "<include>" + includePathFile.toURI() + "</include>" + "<dataset name=\"B\" frequency=\"${coord:days(7)}\" initial-instance=\"2009-02-01T01:00Z\" timezone=\"UTC\">" + "<uri-template>" + URI_TEMPLATE_COORD_XML + "</uri-template>" + "</dataset> " + "</datasets>" + " <input-events> " + "<data-in name=\"inputB\" dataset=\"B\"> <instance>${coord:latest(0)}</instance> </data-in> " + "</input-events> " + "<action>" + "<workflow>" + "<app-path>hdfs:///tmp/workflows/</app-path> " + "<configuration>" + "<property> <name>inputB</name> <value>${coord:dataIn('inputB')}</value> </property> " + "</configuration>" + "</workflow>" + "</action>" + " </coordinator-app>";
writeToFile(appXml, appPathFile);
conf.set(OozieClient.COORDINATOR_APP_PATH, appPathFile.toURI().toString());
conf.set(OozieClient.USER_NAME, getTestUser());
conf.set("appName", "var-app-name");
CoordSubmitXCommand sc = new CoordSubmitXCommand(conf);
String jobId = sc.call();
assertEquals(jobId.substring(jobId.length() - 2), "-C");
CoordinatorJobBean job = checkCoordJobs(jobId);
assertNotNull(job);
Element processedJobXml = XmlUtils.parseXml(job.getJobXml());
Namespace namespace = processedJobXml.getNamespace();
@SuppressWarnings("unchecked") List<Element> datasetElements = processedJobXml.getChild("input-events", namespace).getChild("data-in", namespace).getChildren("dataset", namespace);
assertTrue("<dataset> should not be duplicate", datasetElements.size() == 1);
assertEquals(URI_TEMPLATE_COORD_XML, datasetElements.get(0).getChildText("uri-template", namespace));
assertFalse("<uri-template> should not contain one from the include file", job.getJobXml().contains(URI_TEMPLATE_INCLUDE_XML));
}
use of com.google.cloud.servicedirectory.v1.Namespace in project oozie by apache.
the class TestCoordSubmitXCommand method testBasicSubmitWithIncludeFile.
/**
* Basic submit with include file
* @throws Exception
*/
public void testBasicSubmitWithIncludeFile() throws Exception {
Configuration conf = new XConfiguration();
final File includePathFile = new File(getTestCaseDir(), "include1.xml");
final String URI_TEMPLATE_INCLUDE_XML = "file:///tmp/include_xml/workflows/${YEAR}/${DAY}";
final String URI_TEMPLATE_COORD_XML = "file:///tmp/coord_xml/workflows/${YEAR}/${DAY}";
String includeXml = "<datasets> " + "<dataset name=\"A\" frequency=\"${coord:days(7)}\" initial-instance=\"2009-02-01T01:00Z\" timezone=\"UTC\">" + "<uri-template>" + URI_TEMPLATE_INCLUDE_XML + "</uri-template>" + "</dataset> " + "</datasets>";
writeToFile(includeXml, includePathFile);
File appPathFile = new File(getTestCaseDir(), "coordinator.xml");
String appXml = "<coordinator-app name=\"${appName}-foo\" frequency=\"${coord:days(1)}\" start=\"2009-02-01T01:00Z\" " + "end=\"2009-02-03T23:59Z\" timezone=\"UTC\" xmlns=\"uri:oozie:coordinator:0.2\">" + "<controls> " + "<execution>LIFO</execution>" + "</controls>" + "<datasets> " + "<include>" + includePathFile.toURI() + "</include>" + "<dataset name=\"B\" frequency=\"${coord:days(7)}\" initial-instance=\"2009-02-01T01:00Z\" timezone=\"UTC\">" + "<uri-template>" + URI_TEMPLATE_COORD_XML + "</uri-template>" + "</dataset> " + "</datasets>" + " <input-events> " + "<data-in name=\"inputA\" dataset=\"A\"> <instance>${coord:latest(0)}</instance> </data-in> " + "<data-in name=\"inputB\" dataset=\"B\"> <instance>${coord:latest(0)}</instance> </data-in> " + "</input-events> " + "<action>" + "<workflow>" + "<app-path>hdfs:///tmp/workflows/</app-path> " + "<configuration>" + "<property> <name>inputA</name> <value>${coord:dataIn('inputB')}</value> </property> " + "</configuration>" + "</workflow>" + "</action>" + " </coordinator-app>";
writeToFile(appXml, appPathFile);
conf.set(OozieClient.COORDINATOR_APP_PATH, appPathFile.toURI().toString());
conf.set(OozieClient.USER_NAME, getTestUser());
conf.set("appName", "var-app-name");
CoordSubmitXCommand sc = new CoordSubmitXCommand(conf);
String jobId = sc.call();
assertEquals(jobId.substring(jobId.length() - 2), "-C");
CoordinatorJobBean job = checkCoordJobs(jobId);
assertNotNull(job);
Element processedJobXml = XmlUtils.parseXml(job.getJobXml());
Namespace namespace = processedJobXml.getNamespace();
@SuppressWarnings("unchecked") List<Element> datainElements = processedJobXml.getChild("input-events", namespace).getChildren("data-in", namespace);
assertTrue("<data-in> should be 2. One from coordinator.xml and the other from the include file", datainElements.size() == 2);
assertEquals(URI_TEMPLATE_INCLUDE_XML, datainElements.get(0).getChild("dataset", namespace).getChildText("uri-template", namespace));
assertEquals(URI_TEMPLATE_COORD_XML, datainElements.get(1).getChild("dataset", namespace).getChildText("uri-template", namespace));
}
use of com.google.cloud.servicedirectory.v1.Namespace in project oozie by apache.
the class TestCoordUpdateXCommand method testCoordDefinitionChangeError.
// test fail... error in coord definition
public void testCoordDefinitionChangeError() throws Exception {
Configuration conf = new XConfiguration();
File appPathFile1 = new File(getTestCaseDir(), "coordinator.xml");
String jobId = setupCoord(conf, "coord-multiple-input-instance3.xml");
CoordinatorJobBean job = getCoordJobs(jobId);
Element processedJobXml = XmlUtils.parseXml(job.getJobXml());
Namespace namespace = processedJobXml.getNamespace();
String text = ((Element) processedJobXml.getChild("input-events", namespace).getChild("data-in", namespace).getChildren("instance", namespace).get(0)).getText();
assertEquals(text, "${coord:latest(0)}");
Reader reader = IOUtils.getResourceAsReader("coord-multiple-input-instance1.xml", -1);
Writer writer = new OutputStreamWriter(new FileOutputStream(appPathFile1), StandardCharsets.UTF_8);
IOUtils.copyCharStream(reader, writer);
conf.set(OozieClient.COORDINATOR_APP_PATH, appPathFile1.toURI().toString());
job = getCoordJobs(jobId);
CoordUpdateXCommand update = new CoordUpdateXCommand(false, conf, jobId);
try {
update.call();
fail(" should not come here");
} catch (Exception e) {
assertTrue(e.getMessage().contains("E1021: Coord Action Input Check Error"));
}
}
Aggregations