Search in sources :

Example 36 with ActionExecutorException

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);
}
Also used : Path(org.apache.hadoop.fs.Path) FileStatus(org.apache.hadoop.fs.FileStatus) FileSystem(org.apache.hadoop.fs.FileSystem) ActionExecutorException(org.apache.oozie.action.ActionExecutorException)

Example 37 with ActionExecutorException

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;
}
Also used : Path(org.apache.hadoop.fs.Path) Configuration(org.apache.hadoop.conf.Configuration) Element(org.jdom.Element) ActionExecutorException(org.apache.oozie.action.ActionExecutorException) List(java.util.List) ArrayList(java.util.ArrayList) Namespace(org.jdom.Namespace)

Example 38 with ActionExecutorException

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;
}
Also used : Path(org.apache.hadoop.fs.Path) Configuration(org.apache.hadoop.conf.Configuration) Element(org.jdom.Element) ActionExecutorException(org.apache.oozie.action.ActionExecutorException) List(java.util.List) ArrayList(java.util.ArrayList) Namespace(org.jdom.Namespace)

Example 39 with ActionExecutorException

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);
    }
}
Also used : 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 40 with ActionExecutorException

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

Aggregations

ActionExecutorException (org.apache.oozie.action.ActionExecutorException)75 Path (org.apache.hadoop.fs.Path)41 IOException (java.io.IOException)39 Element (org.jdom.Element)28 URISyntaxException (java.net.URISyntaxException)27 FileSystem (org.apache.hadoop.fs.FileSystem)25 HadoopAccessorException (org.apache.oozie.service.HadoopAccessorException)24 XConfiguration (org.apache.oozie.util.XConfiguration)23 Configuration (org.apache.hadoop.conf.Configuration)20 AccessControlException (org.apache.hadoop.security.AccessControlException)20 Namespace (org.jdom.Namespace)13 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)12 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)12 JDOMException (org.jdom.JDOMException)12 FileNotFoundException (java.io.FileNotFoundException)10 ELEvaluationException (org.apache.oozie.util.ELEvaluationException)10 ConnectException (java.net.ConnectException)9 UnknownHostException (java.net.UnknownHostException)9 RemoteException (org.apache.hadoop.ipc.RemoteException)9 ArrayList (java.util.ArrayList)8