use of org.apache.oozie.action.ActionExecutorException in project oozie by apache.
the class FsELFunctions method fs_exists.
/**
* Return if a path exists.
*
* @param pathUri file system path uri.
* @return <code>true</code> if the path exists, <code>false</code> if it does not.
* @throws Exception
*/
public static boolean fs_exists(String pathUri) throws Exception {
Path path = new Path(pathUri);
FileSystem fs = getFileSystem(path.toUri());
FileStatus[] pathArr;
try {
pathArr = fs.globStatus(path, new FSPathFilter());
} catch (ReachingGlobMaxException e) {
throw new ActionExecutorException(ActionExecutorException.ErrorType.ERROR, "FS013", "too many globbed files/dirs to do FS operation");
}
return (pathArr != null && pathArr.length > 0);
}
use of org.apache.oozie.action.ActionExecutorException in project oozie by apache.
the class Hive2ActionExecutor method setupActionConf.
@Override
@SuppressWarnings("unchecked")
Configuration setupActionConf(Configuration actionConf, Context context, Element actionXml, Path appPath) throws ActionExecutorException {
Configuration conf = super.setupActionConf(actionConf, context, actionXml, appPath);
Namespace ns = actionXml.getNamespace();
String jdbcUrl = actionXml.getChild("jdbc-url", ns).getTextTrim();
conf.set(HIVE2_JDBC_URL, jdbcUrl);
String password = null;
Element passwordElement = actionXml.getChild("password", ns);
if (passwordElement != null) {
password = actionXml.getChild("password", ns).getTextTrim();
conf.set(HIVE2_PASSWORD, password);
}
Element queryElement = actionXml.getChild("query", ns);
Element scriptElement = actionXml.getChild("script", ns);
if (scriptElement != null) {
String script = scriptElement.getTextTrim();
String scriptName = new Path(script).getName();
this.addScriptToCache = true;
conf.set(HIVE2_SCRIPT, scriptName);
} else if (queryElement != null) {
// Unable to use getTextTrim due to https://issues.apache.org/jira/browse/HIVE-8182
String query = queryElement.getText();
conf.set(HIVE2_QUERY, query);
} else {
throw new ActionExecutorException(ActionExecutorException.ErrorType.ERROR, "INVALID_ARGUMENTS", "Hive 2 action requires one of <script> or <query> to be set. Neither were found.");
}
List<Element> params = (List<Element>) actionXml.getChildren("param", ns);
String[] strParams = new String[params.size()];
for (int i = 0; i < params.size(); i++) {
strParams[i] = params.get(i).getTextTrim();
}
ActionUtils.setStrings(conf, HIVE2_PARAMS, strParams);
String[] strArgs = null;
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();
}
}
ActionUtils.setStrings(conf, HIVE2_ARGS, strArgs);
return conf;
}
use of org.apache.oozie.action.ActionExecutorException in project oozie by apache.
the class HiveActionExecutor method setupActionConf.
@Override
@SuppressWarnings("unchecked")
Configuration setupActionConf(Configuration actionConf, Context context, Element actionXml, Path appPath) throws ActionExecutorException {
Configuration conf = super.setupActionConf(actionConf, context, actionXml, appPath);
Namespace ns = actionXml.getNamespace();
Element scriptElement = actionXml.getChild("script", ns);
Element queryElement = actionXml.getChild("query", ns);
if (scriptElement != null) {
String script = scriptElement.getTextTrim();
String scriptName = new Path(script).getName();
this.addScriptToCache = true;
conf.set(HIVE_SCRIPT, scriptName);
} else if (queryElement != null) {
// Unable to use getTextTrim due to https://issues.apache.org/jira/browse/HIVE-8182
String query = queryElement.getText();
conf.set(HIVE_QUERY, query);
} else {
throw new ActionExecutorException(ActionExecutorException.ErrorType.ERROR, "INVALID_ARGUMENTS", "Hive action requires one of <script> or <query> to be set. Neither were found.");
}
List<Element> params = (List<Element>) actionXml.getChildren("param", ns);
String[] strParams = new String[params.size()];
for (int i = 0; i < params.size(); i++) {
strParams[i] = params.get(i).getTextTrim();
}
ActionUtils.setStrings(conf, HIVE_PARAMS, strParams);
String[] strArgs = null;
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();
}
}
ActionUtils.setStrings(conf, HIVE_ARGS, strArgs);
return conf;
}
use of org.apache.oozie.action.ActionExecutorException in project oozie by apache.
the class JavaActionExecutor method start.
@Override
public void start(Context context, WorkflowAction action) throws ActionExecutorException {
LogUtils.setLogInfo(action);
try {
LOG.info("Starting action. Getting Action File System");
FileSystem actionFs = context.getAppFileSystem();
LOG.debug("Preparing action Dir through copying " + context.getActionDir());
prepareActionDir(actionFs, context);
LOG.debug("Action Dir is ready. Submitting the action ");
submitLauncher(actionFs, context, action);
LOG.debug("Action submit completed. Performing check ");
check(context, action);
LOG.debug("Action check is done after submission");
} catch (Exception ex) {
throw convertException(ex);
}
}
use of org.apache.oozie.action.ActionExecutorException 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);
}
}
}
Aggregations