Browse Source

HADOOP-13088. fix shellprofiles in hadoop-tools to allow replacement

Allen Wittenauer 9 years ago
parent
commit
754cf147c4

+ 10 - 4
hadoop-tools/hadoop-archive-logs/src/main/shellprofile.d/hadoop-archive-logs.sh

@@ -15,14 +15,18 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-if [[ "${HADOOP_SHELL_EXECNAME}" = mapred ]]; then
-  hadoop_add_subcommand "archive-logs" "combine aggregated logs into hadoop archives"
-fi
+if ! declare -f mapred_subcommand_archive-logs >/dev/null 2>/dev/null; then
+
+  if [[ "${HADOOP_SHELL_EXECNAME}" = mapred ]]; then
+    hadoop_add_subcommand "archive-logs" "combine aggregated logs into hadoop archives"
+  fi
+
+  # this can't be indented otherwise shelldocs won't get it
 
 ## @description  archive-logs command for mapred
 ## @audience     public
 ## @stability    stable
-## @replaceable  no
+## @replaceable  yes
 function mapred_subcommand_archive-logs
 {
   # shellcheck disable=SC2034
@@ -31,3 +35,5 @@ function mapred_subcommand_archive-logs
   hadoop_debug "Appending HADOOP_CLIENT_OPTS onto HADOOP_OPTS"
   HADOOP_OPTS="${HADOOP_OPTS} ${HADOOP_CLIENT_OPTS}"
 }
+
+fi

+ 25 - 8
hadoop-tools/hadoop-archives/src/main/shellprofile.d/hadoop-archives.sh

@@ -15,15 +15,18 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-if [[ "${HADOOP_SHELL_EXECNAME}" = hadoop
-   || "${HADOOP_SHELL_EXECNAME}" = mapred ]]; then
-  hadoop_add_subcommand "archive" "create a Hadoop archive"
-fi
+if ! declare -f hadoop_subcommand_archive >/dev/null 2>/dev/null; then
+
+  if [[ "${HADOOP_SHELL_EXECNAME}" = hadoop ]]; then
+    hadoop_add_subcommand "archive" "create a Hadoop archive"
+  fi
+
+  # this can't be indented otherwise shelldocs won't get it
 
 ## @description  archive command for hadoop (and mapred)
 ## @audience     public
 ## @stability    stable
-## @replaceable  no
+## @replaceable  yes
 function hadoop_subcommand_archive
 {
   # shellcheck disable=SC2034
@@ -31,11 +34,25 @@ function hadoop_subcommand_archive
   hadoop_add_to_classpath_tools hadoop-archives
 }
 
-## @description  archive-logs command for mapred (calls hadoop version)
+fi
+
+if ! declare -f mapred_subcommand_archive >/dev/null 2>/dev/null; then
+
+  if [[ "${HADOOP_SHELL_EXECNAME}" = mapred ]]; then
+    hadoop_add_subcommand "archive" "create a Hadoop archive"
+  fi
+
+  # this can't be indented otherwise shelldocs won't get it
+
+## @description  archive command for mapred (calls hadoop version)
 ## @audience     public
 ## @stability    stable
-## @replaceable  no
+## @replaceable  yes
 function mapred_subcommand_archive
 {
-  hadoop_subcommand_archive
+  # shellcheck disable=SC2034
+  HADOOP_CLASSNAME=org.apache.hadoop.tools.HadoopArchives
+  hadoop_add_to_classpath_tools hadoop-archives
 }
+
+fi

+ 26 - 7
hadoop-tools/hadoop-distcp/src/main/shellprofile.d/hadoop-distcp.sh

@@ -15,15 +15,18 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-if [[ "${HADOOP_SHELL_EXECNAME}" = hadoop
-   || "${HADOOP_SHELL_EXECNAME}" = mapred ]]; then
-  hadoop_add_subcommand "distcp" "copy file or directories recursively"
-fi
+if ! declare -f hadoop_subcommand_distcp >/dev/null 2>/dev/null; then
+
+  if [[ "${HADOOP_SHELL_EXECNAME}" = hadoop ]]; then
+    hadoop_add_subcommand "distcp" "copy file or directories recursively"
+  fi
+
+  # this can't be indented otherwise shelldocs won't get it
 
 ## @description  distcp command for hadoop
 ## @audience     public
 ## @stability    stable
-## @replaceable  no
+## @replaceable  yes
 function hadoop_subcommand_distcp
 {
   # shellcheck disable=SC2034
@@ -33,11 +36,27 @@ function hadoop_subcommand_distcp
   HADOOP_OPTS="${HADOOP_OPTS} ${HADOOP_CLIENT_OPTS}"
 }
 
+fi
+
+if ! declare -f mapred_subcommand_distcp >/dev/null 2>/dev/null; then
+
+  if [[ "${HADOOP_SHELL_EXECNAME}" = mapred ]]; then
+    hadoop_add_subcommand "distcp" "copy file or directories recursively"
+  fi
+
+  # this can't be indented otherwise shelldocs won't get it
+
 ## @description  distcp command for mapred (calls hadoop)
 ## @audience     public
 ## @stability    stable
-## @replaceable  no
+## @replaceable  yes
 function mapred_subcommand_distcp
 {
-  hadoop_subcommand_distcp
+  # shellcheck disable=SC2034
+  HADOOP_CLASSNAME=org.apache.hadoop.tools.DistCp
+  hadoop_add_to_classpath_tools hadoop-distcp
+  hadoop_debug "Appending HADOOP_CLIENT_OPTS onto HADOOP_OPTS"
+  HADOOP_OPTS="${HADOOP_OPTS} ${HADOOP_CLIENT_OPTS}"
 }
+
+fi

+ 10 - 4
hadoop-tools/hadoop-extras/src/main/shellprofile.d/hadoop-extras.sh

@@ -15,14 +15,18 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-if [[ "${HADOOP_SHELL_EXECNAME}" = hadoop ]]; then
-  hadoop_add_subcommand "distch" "distributed metadata changer"
-fi
+if ! declare -f hadoop_subcommand_distch >/dev/null 2>/dev/null; then
+
+  if [[ "${HADOOP_SHELL_EXECNAME}" = hadoop ]]; then
+    hadoop_add_subcommand "distch" "distributed metadata changer"
+  fi
+
+  # this can't be indented otherwise shelldocs won't get it
 
 ## @description  distch command for hadoop
 ## @audience     public
 ## @stability    stable
-## @replaceable  no
+## @replaceable  yes
 function hadoop_subcommand_distch
 {
   # shellcheck disable=SC2034
@@ -31,3 +35,5 @@ function hadoop_subcommand_distch
   hadoop_debug "Appending HADOOP_CLIENT_OPTS onto HADOOP_OPTS"
   HADOOP_OPTS="${HADOOP_OPTS} ${HADOOP_CLIENT_OPTS}"
 }
+
+fi