Bläddra i källkod

HADOOP-13111. convert hadoop gridmix to be dynamic

Allen Wittenauer 9 år sedan
förälder
incheckning
9708a237d3

+ 8 - 0
hadoop-assemblies/src/main/resources/assemblies/hadoop-tools.xml

@@ -125,6 +125,14 @@
         <include>*-sources.jar</include>
         <include>*-sources.jar</include>
       </includes>
       </includes>
     </fileSet>
     </fileSet>
+    <fileSet>
+      <directory>../hadoop-gridmix/src/main/shellprofile.d</directory>
+      <includes>
+        <include>*</include>
+      </includes>
+      <outputDirectory>/libexec/shellprofile.d</outputDirectory>
+      <fileMode>0755</fileMode>
+    </fileSet>
     <fileSet>
     <fileSet>
       <directory>../hadoop-rumen/target</directory>
       <directory>../hadoop-rumen/target</directory>
       <outputDirectory>/share/hadoop/${hadoop.component}/sources</outputDirectory>
       <outputDirectory>/share/hadoop/${hadoop.component}/sources</outputDirectory>

+ 1 - 7
hadoop-common-project/hadoop-common/src/main/bin/hadoop

@@ -38,7 +38,6 @@ function hadoop_usage
   hadoop_add_subcommand "dtutil" "operations related to delegation tokens"
   hadoop_add_subcommand "dtutil" "operations related to delegation tokens"
   hadoop_add_subcommand "envvars" "display computed Hadoop environment variables"
   hadoop_add_subcommand "envvars" "display computed Hadoop environment variables"
   hadoop_add_subcommand "fs" "run a generic filesystem user client"
   hadoop_add_subcommand "fs" "run a generic filesystem user client"
-  hadoop_add_subcommand "gridmix" "submit a mix of synthetic job, modeling a profiled from production load"
   hadoop_add_subcommand "jar <jar>" "run a jar file. NOTE: please use \"yarn jar\" to launch YARN applications, not this command."
   hadoop_add_subcommand "jar <jar>" "run a jar file. NOTE: please use \"yarn jar\" to launch YARN applications, not this command."
   hadoop_add_subcommand "jnipath" "prints the java.library.path"
   hadoop_add_subcommand "jnipath" "prints the java.library.path"
   hadoop_add_subcommand "kerbname" "show auth_to_local principal conversion"
   hadoop_add_subcommand "kerbname" "show auth_to_local principal conversion"
@@ -132,11 +131,6 @@ function hadoopcmd_case
     fs)
     fs)
       HADOOP_CLASSNAME=org.apache.hadoop.fs.FsShell
       HADOOP_CLASSNAME=org.apache.hadoop.fs.FsShell
     ;;
     ;;
-    gridmix)
-      CLASS=org.apache.hadoop.mapred.gridmix.Gridmix
-      hadoop_add_to_classpath_tools hadoop-rumen
-      hadoop_add_to_classpath_tools hadoop-gridmix
-    ;;
     jar)
     jar)
       if [[ -n "${YARN_OPTS}" ]] || [[ -n "${YARN_CLIENT_OPTS}" ]]; then
       if [[ -n "${YARN_OPTS}" ]] || [[ -n "${YARN_CLIENT_OPTS}" ]]; then
         hadoop_error "WARNING: Use \"yarn jar\" to launch YARN applications."
         hadoop_error "WARNING: Use \"yarn jar\" to launch YARN applications."
@@ -268,4 +262,4 @@ if [[ -n "${HADOOP_SUBCMD_SUPPORTDAEMONIZATION}" ]]; then
 else
 else
   # shellcheck disable=SC2086
   # shellcheck disable=SC2086
   hadoop_java_exec "${HADOOP_SUBCMD}" "${HADOOP_CLASSNAME}" "${HADOOP_SUBCMD_ARGS[@]}"
   hadoop_java_exec "${HADOOP_SUBCMD}" "${HADOOP_CLASSNAME}" "${HADOOP_SUBCMD_ARGS[@]}"
-fi
+fi

+ 36 - 0
hadoop-tools/hadoop-gridmix/src/main/shellprofile.d/hadoop-gridmix.sh

@@ -0,0 +1,36 @@
+#!/usr/bin/env bash
+
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file 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
+#
+# 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.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+if ! declare -f hadoop_subcommand_gridmix >/dev/null 2>/dev/null; then
+
+  if [[ "${HADOOP_SHELL_EXECNAME}" = hadoop ]]; then
+    hadoop_add_subcommand "gridmix" "submit a mix of synthetic job, modeling a profiled from production load"
+  fi
+
+## @description  gridmix command for hadoop
+## @audience     public
+## @stability    stable
+## @replaceable  yes
+function hadoop_subcommand_gridmix
+{
+  # shellcheck disable=SC2034
+  HADOOP_CLASSNAME=org.apache.hadoop.mapred.gridmix.Gridmix
+  hadoop_add_to_classpath_tools hadoop-rumen
+  hadoop_add_to_classpath_tools hadoop-gridmix
+}
+
+fi