From 3da77d9705631220c80ecc61cf6f50cf47edb158 Mon Sep 17 00:00:00 2001 From: Roey Shem Tov Date: Sun, 5 Aug 2018 23:47:16 +0300 Subject: [PATCH 1/2] [OOZIE-3320] Oozie ShellAction should support absolute bash file path --- .../apache/oozie/action/hadoop/ShellActionExecutor.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/apache/oozie/action/hadoop/ShellActionExecutor.java b/core/src/main/java/org/apache/oozie/action/hadoop/ShellActionExecutor.java index 9591cd9547..ba03fa48d5 100644 --- a/core/src/main/java/org/apache/oozie/action/hadoop/ShellActionExecutor.java +++ b/core/src/main/java/org/apache/oozie/action/hadoop/ShellActionExecutor.java @@ -54,7 +54,13 @@ Configuration setupActionConf(Configuration actionConf, Context context, Element Namespace ns = actionXml.getNamespace(); String exec = actionXml.getChild("exec", ns).getTextTrim(); - String execName = new Path(exec).getName(); + String execName; + String localFilePrefix = "file://"; + // When exec starts with 'file://' refer it as local file. + if (exec.startsWith(localFilePrefix)) + execName = exec.substring(localFilePrefix.length()); + else + execName = new Path(exec).getName(); actionConf.set(ShellMain.CONF_OOZIE_SHELL_EXEC, execName); // Setting Shell command's arguments From 37c51162052271f61c473fe547c7f208cbc362b3 Mon Sep 17 00:00:00 2001 From: Roey Shem Tov Date: Thu, 9 Aug 2018 19:01:57 +0300 Subject: [PATCH 2/2] [OOZIE-3320] fix: Oozie ShellAction should support absolute bash file path --- .../action/hadoop/ShellActionExecutor.java | 37 +++++++++++++------ 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/core/src/main/java/org/apache/oozie/action/hadoop/ShellActionExecutor.java b/core/src/main/java/org/apache/oozie/action/hadoop/ShellActionExecutor.java index ba03fa48d5..a1847a3cbf 100644 --- a/core/src/main/java/org/apache/oozie/action/hadoop/ShellActionExecutor.java +++ b/core/src/main/java/org/apache/oozie/action/hadoop/ShellActionExecutor.java @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -54,13 +54,7 @@ Configuration setupActionConf(Configuration actionConf, Context context, Element Namespace ns = actionXml.getNamespace(); String exec = actionXml.getChild("exec", ns).getTextTrim(); - String execName; - String localFilePrefix = "file://"; - // When exec starts with 'file://' refer it as local file. - if (exec.startsWith(localFilePrefix)) - execName = exec.substring(localFilePrefix.length()); - else - execName = new Path(exec).getName(); + String execName = resolveExecutable(exec); actionConf.set(ShellMain.CONF_OOZIE_SHELL_EXEC, execName); // Setting Shell command's arguments @@ -101,7 +95,7 @@ Configuration setupActionConf(Configuration actionConf, Context context, Element * @throws ActionExecutorException */ protected void setListInConf(String tag, Element actionXml, Configuration actionConf, String key, - boolean checkKeyValue) throws ActionExecutorException { + boolean checkKeyValue) throws ActionExecutorException { String[] strTagValue = null; Namespace ns = actionXml.getNamespace(); @SuppressWarnings("unchecked") @@ -120,6 +114,7 @@ protected void setListInConf(String tag, Element actionXml, Configuration action /** * Check if the key=value pair is appropriately formatted + * * @param pair * @throws ActionExecutorException */ @@ -156,4 +151,24 @@ private void updateProperty(Configuration conf, String propertyName, String appe } } + /** + * This method extract the exec name from exec tag. + * + * @param exec + * @return + */ + private String resolveExecutable(String exec) { + String localFilePrefix = "file://"; + String execName; + + // When exec starts with 'file://' refer it as local file. + if (exec.startsWith(localFilePrefix)) { + execName = exec.substring(localFilePrefix.length()); + } else { + execName = new Path(exec).getName(); + } + return execName; + + } + }