use of com.google.cloud.servicedirectory.v1.Namespace in project oozie by apache.
the class ForTestingActionExecutor method end.
public void end(Context context, WorkflowAction action) throws ActionExecutorException {
Element eConf = getConfiguration(action.getConf());
Namespace ns = eConf.getNamespace();
String error = eConf.getChild("error", ns).getText().trim();
if ("end.transient".equals(error)) {
throw new ActionExecutorException(ActionExecutorException.ErrorType.TRANSIENT, TEST_ERROR, "end");
}
if ("end.non-transient".equals(error)) {
throw new ActionExecutorException(ActionExecutorException.ErrorType.NON_TRANSIENT, TEST_ERROR, "end");
}
if ("end.error".equals(error)) {
throw new ActionExecutorException(ActionExecutorException.ErrorType.ERROR, TEST_ERROR, "end");
}
String signalValue = eConf.getChild("signal-value", ns).getText().trim();
String externalStatus = action.getExternalStatus();
WorkflowAction.Status status = null;
if (externalStatus.equals("ok")) {
status = WorkflowAction.Status.OK;
} else {
status = WorkflowAction.Status.ERROR;
}
if (signalValue.equals("based_on_action_status")) {
signalValue = status.toString();
}
boolean callSetEndData = true;
Element setEndData = eConf.getChild("avoid-set-end-data", ns);
if (null != setEndData) {
if (setEndData.getText().trim().equals("true")) {
callSetEndData = false;
}
}
if (callSetEndData) {
context.setEndData(status, signalValue);
}
}
use of com.google.cloud.servicedirectory.v1.Namespace in project oozie by apache.
the class TestSubmitMRXCommand method testWFXmlGenerationNewConfigProps.
public void testWFXmlGenerationNewConfigProps() throws Exception {
try {
Configuration conf = new Configuration(false);
conf.set(XOozieClient.NN, "new_NN");
conf.set(XOozieClient.RM, "new_JT");
conf.set("mapred.mapper.class", "TestMapper");
conf.set("mapred.reducer.class", "TestReducer");
conf.set("mapred.input.dir", "testInput");
conf.set("mapred.output.dir", "testOutput");
conf.set(OozieClient.LIBPATH, "libpath");
conf.set("mapreduce.job.user.name", "test_user");
SubmitMRXCommand submitMRCmd = new SubmitMRXCommand(conf);
String xml = submitMRCmd.getWorkflowXml(conf);
// verifying is a valid WF
WorkflowAppService wps = Services.get().get(WorkflowAppService.class);
wps.parseDef(xml, conf);
Element wfE = XmlUtils.parseXml(xml);
Namespace ns = wfE.getNamespace();
Element actionE = wfE.getChild("action", ns).getChild("map-reduce", ns);
Element nnE = actionE.getChild("name-node", ns);
assertEquals(nnE.getTextTrim(), "new_NN");
Element jtE = actionE.getChild("job-tracker", ns);
assertEquals(jtE.getTextTrim(), "new_JT");
} catch (Exception e) {
fail("should have passed");
}
}
use of com.google.cloud.servicedirectory.v1.Namespace in project oozie by apache.
the class JavaActionExecutor method createLauncherConf.
@SuppressWarnings("unchecked")
Configuration createLauncherConf(FileSystem actionFs, Context context, WorkflowAction action, Element actionXml, Configuration actionConf) throws ActionExecutorException {
try {
// app path could be a file
Path appPathRoot = new Path(context.getWorkflow().getAppPath());
if (actionFs.isFile(appPathRoot)) {
appPathRoot = appPathRoot.getParent();
}
// launcher job configuration
Configuration launcherJobConf = createBaseHadoopConf(context, actionXml);
// cancel delegation token on a launcher job which stays alive till child job(s) finishes
// otherwise (in mapred action), doesn't cancel not to disturb running child job
launcherJobConf.setBoolean("mapreduce.job.complete.cancel.delegation.tokens", true);
setupLauncherConf(launcherJobConf, actionXml, appPathRoot, context);
// Properties for when a launcher job's AM gets restarted
if (ConfigurationService.getBoolean(HADOOP_YARN_KILL_CHILD_JOBS_ON_AMRESTART)) {
// launcher time filter is required to prune the search of launcher tag.
// Setting coordinator action nominal time as launcher time as it child job cannot launch before nominal
// time. Workflow created time is good enough when workflow is running independently or workflow is
// rerunning from failed node.
long launcherTime = System.currentTimeMillis();
String coordActionNominalTime = context.getProtoActionConf().get(CoordActionStartXCommand.OOZIE_COORD_ACTION_NOMINAL_TIME);
if (coordActionNominalTime != null) {
launcherTime = Long.parseLong(coordActionNominalTime);
} else if (context.getWorkflow().getCreatedTime() != null) {
launcherTime = context.getWorkflow().getCreatedTime().getTime();
}
String actionYarnTag = getActionYarnTag(getWorkflowConf(context), context.getWorkflow(), action);
LauncherHelper.setupYarnRestartHandling(launcherJobConf, actionConf, actionYarnTag, launcherTime);
} else {
LOG.info(MessageFormat.format("{0} is set to false, not setting YARN restart properties", HADOOP_YARN_KILL_CHILD_JOBS_ON_AMRESTART));
}
String actionShareLibProperty = actionConf.get(ACTION_SHARELIB_FOR + getType());
if (actionShareLibProperty != null) {
launcherJobConf.set(ACTION_SHARELIB_FOR + getType(), actionShareLibProperty);
}
setLibFilesArchives(context, actionXml, appPathRoot, launcherJobConf);
// Inject Oozie job information if enabled.
injectJobInfo(launcherJobConf, actionConf, context, action);
injectLauncherCallback(context, launcherJobConf);
String jobId = context.getWorkflow().getId();
String actionId = action.getId();
Path actionDir = context.getActionDir();
String recoveryId = context.getRecoveryId();
// Getting the prepare XML from the action XML
Namespace ns = actionXml.getNamespace();
Element prepareElement = actionXml.getChild("prepare", ns);
String prepareXML = "";
if (prepareElement != null) {
if (prepareElement.getChildren().size() > 0) {
prepareXML = XmlUtils.prettyPrint(prepareElement).toString().trim();
}
}
checkAndDeduplicate(actionConf);
LauncherHelper.setupLauncherInfo(launcherJobConf, jobId, actionId, actionDir, recoveryId, actionConf, prepareXML);
// Set the launcher Main Class
LauncherHelper.setupMainClass(launcherJobConf, getLauncherMain(launcherJobConf, actionXml));
LauncherHelper.setupLauncherURIHandlerConf(launcherJobConf);
LauncherHelper.setupMaxOutputData(launcherJobConf, getMaxOutputData(actionConf));
LauncherHelper.setupMaxExternalStatsSize(launcherJobConf, maxExternalStatsSize);
LauncherHelper.setupMaxFSGlob(launcherJobConf, maxFSGlobMax);
List<Element> list = actionXml.getChildren("arg", ns);
String[] args = new String[list.size()];
for (int i = 0; i < list.size(); i++) {
args[i] = list.get(i).getTextTrim();
}
LauncherHelper.setupMainArguments(launcherJobConf, args);
// backward compatibility flag - see OOZIE-2872
boolean nullArgsAllowed = ConfigurationService.getBoolean(LauncherAMUtils.CONF_OOZIE_NULL_ARGS_ALLOWED);
launcherJobConf.setBoolean(LauncherAMUtils.CONF_OOZIE_NULL_ARGS_ALLOWED, nullArgsAllowed);
// Make mapred.child.java.opts and mapreduce.map.java.opts equal, but give values from the latter priority; also append
// <java-opt> and <java-opts> and give those highest priority
StringBuilder opts = new StringBuilder(launcherJobConf.get(HADOOP_CHILD_JAVA_OPTS, ""));
if (launcherJobConf.get(HADOOP_MAP_JAVA_OPTS) != null) {
opts.append(" ").append(launcherJobConf.get(HADOOP_MAP_JAVA_OPTS));
}
List<Element> javaopts = actionXml.getChildren("java-opt", ns);
// Either one or more <java-opt> element or one <java-opts> can be present since oozie-workflow-0.4
if (!javaopts.isEmpty()) {
for (Element opt : javaopts) {
opts.append(" ").append(opt.getTextTrim());
}
} else {
Element opt = actionXml.getChild("java-opts", ns);
if (opt != null) {
opts.append(" ").append(opt.getTextTrim());
}
}
launcherJobConf.set(HADOOP_CHILD_JAVA_OPTS, opts.toString().trim());
launcherJobConf.set(HADOOP_MAP_JAVA_OPTS, opts.toString().trim());
injectLauncherTimelineServiceEnabled(launcherJobConf, actionConf);
// properties from action that are needed by the launcher (e.g. QUEUE NAME, ACLs)
// maybe we should add queue to the WF schema, below job-tracker
actionConfToLauncherConf(actionConf, launcherJobConf);
checkAndDeduplicate(launcherJobConf);
return launcherJobConf;
} catch (Exception ex) {
throw convertException(ex);
}
}
use of com.google.cloud.servicedirectory.v1.Namespace in project oozie by apache.
the class SqoopActionExecutor 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();
try {
Element e = actionXml.getChild("configuration", ns);
if (e != null) {
String strConf = XmlUtils.prettyPrint(e).toString();
XConfiguration inlineConf = new XConfiguration(new StringReader(strConf));
XConfiguration.copy(inlineConf, actionConf);
checkForDisallowedProps(inlineConf, "inline configuration");
}
} catch (IOException ex) {
throw convertException(ex);
}
List<String> argList = new ArrayList<>();
// Build a list of arguments from either a tokenized <command> string or a list of <arg>
if (actionXml.getChild("command", ns) != null) {
String command = actionXml.getChild("command", ns).getTextTrim();
argList = splitCommand(actionConf, command);
} else {
@SuppressWarnings("unchecked") List<Element> eArgs = (List<Element>) actionXml.getChildren("arg", ns);
for (Element elem : eArgs) {
argList.add(elem.getTextTrim());
}
}
// "sqoop --option", as that's entirely invalid.
if (argList.size() > 1 && argList.get(0).equalsIgnoreCase(SQOOP) && !argList.get(1).startsWith("-")) {
XLog.getLog(getClass()).info("Found a redundant 'sqoop' prefixing the command. Removing it.");
argList.remove(0);
}
setSqoopCommand(actionConf, argList.toArray(new String[argList.size()]));
return actionConf;
}
use of com.google.cloud.servicedirectory.v1.Namespace in project oozie by apache.
the class SqoopActionExecutor method evaluateConfigurationProperty.
// Return the value of the specified configuration property
private String evaluateConfigurationProperty(Element actionConf, String key, String defaultValue) throws ActionExecutorException {
try {
if (actionConf != null) {
Namespace ns = actionConf.getNamespace();
Element e = actionConf.getChild("configuration", ns);
if (e != null) {
String strConf = XmlUtils.prettyPrint(e).toString();
XConfiguration inlineConf = new XConfiguration(new StringReader(strConf));
return inlineConf.get(key, defaultValue);
}
}
return defaultValue;
} catch (IOException ex) {
throw convertException(ex);
}
}
Aggregations