hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From su...@apache.org
Subject hadoop git commit: HADOOP-15026. Rebase ResourceEstimator start/stop scripts for branch-2. (Rui Li via Subru).
Date Thu, 09 Nov 2017 08:32:48 GMT
Repository: hadoop
Updated Branches:
  refs/heads/branch-2 46a740a82 -> 5991c218a


HADOOP-15026. Rebase ResourceEstimator start/stop scripts for branch-2. (Rui Li via Subru).


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/5991c218
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/5991c218
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/5991c218

Branch: refs/heads/branch-2
Commit: 5991c218a0cd72fc6a2b10ef77729ee6181c9443
Parents: 46a740a
Author: Subru Krishnan <subu@apache.org>
Authored: Thu Nov 9 00:32:34 2017 -0800
Committer: Subru Krishnan <subu@apache.org>
Committed: Thu Nov 9 00:32:34 2017 -0800

----------------------------------------------------------------------
 .../src/main/bin/estimator-daemon.sh            | 79 ++++++++++++++++++++
 .../src/main/bin/estimator.sh                   | 52 +++++--------
 .../src/main/bin/start-estimator.sh             | 30 +-------
 .../src/main/bin/stop-estimator.sh              | 29 +------
 4 files changed, 104 insertions(+), 86 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/5991c218/hadoop-tools/hadoop-resourceestimator/src/main/bin/estimator-daemon.sh
----------------------------------------------------------------------
diff --git a/hadoop-tools/hadoop-resourceestimator/src/main/bin/estimator-daemon.sh b/hadoop-tools/hadoop-resourceestimator/src/main/bin/estimator-daemon.sh
new file mode 100755
index 0000000..34a98c0
--- /dev/null
+++ b/hadoop-tools/hadoop-resourceestimator/src/main/bin/estimator-daemon.sh
@@ -0,0 +1,79 @@
+#!/usr/bin/env bash
+#
+#  Licensed 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. See accompanying LICENSE file.
+#
+
+bin=$(dirname "${BASH_SOURCE-$0}")
+bin=$(cd "$bin" || exit; pwd)
+
+# get arguments
+startStop=$1
+shift
+command=$1
+shift
+
+pid=/tmp/hadoop-dogtail-estimator.pid
+
+LOG_DIR=$bin/../../../../../logs
+if [ ! -w "$LOG_DIR" ] ; then
+  mkdir -p "$LOG_DIR"
+fi
+
+log=$LOG_DIR/hadoop-resourceestimator.out
+
+case $startStop in
+
+  (start)
+
+    if [ -f $pid ]; then
+      # shellcheck disable=SC2046
+      if kill -0 $(cat $pid) > /dev/null 2>&1; then
+        echo "$command running as process $(cat $pid).  Stop it first."
+        exit 1
+      fi
+    fi
+
+    echo "starting $command, logging to $log"
+    bin/estimator.sh "$@" > "$log" 2>&1 < /dev/null &
+    echo $! > $pid
+    sleep 1
+    head "$log"
+    ;;
+
+  (stop)
+
+    if [ -f $pid ]; then
+      TARGET_PID=$(cat $pid)
+      # shellcheck disable=SC2086
+      if kill -0 $TARGET_PID > /dev/null 2>&1; then
+        kill "$TARGET_PID"
+        sleep 5
+        # shellcheck disable=SC2086
+        if kill -0 $TARGET_PID > /dev/null 2>&1; then
+          echo "$command did not stop gracefully after 5 seconds: killing with kill -9"
+          "kill -9 $TARGET_PID"
+        fi
+      else
+        echo "no $command to stop"
+      fi
+      rm -f $pid
+    else
+      echo "no $command to stop"
+    fi
+    ;;
+
+  (*)
+    exit 1
+    ;;
+
+esac
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/hadoop/blob/5991c218/hadoop-tools/hadoop-resourceestimator/src/main/bin/estimator.sh
----------------------------------------------------------------------
diff --git a/hadoop-tools/hadoop-resourceestimator/src/main/bin/estimator.sh b/hadoop-tools/hadoop-resourceestimator/src/main/bin/estimator.sh
index 3e1ec27..e48238c 100644
--- a/hadoop-tools/hadoop-resourceestimator/src/main/bin/estimator.sh
+++ b/hadoop-tools/hadoop-resourceestimator/src/main/bin/estimator.sh
@@ -13,32 +13,21 @@
 #  limitations under the License. See accompanying LICENSE file.
 #
 
-## @audience     public
-## @stability    stable
-function hadoop_usage()
-{
-  echo "Usage: estimator.sh"
- #hadoop-daemon.sh. need both start and stop, status (query the status). run as background
process.
-}
+bin=$(dirname "${BASH_SOURCE-$0}")
+bin=$(cd "$bin" || exit; pwd)
 
-## @audience     public
-## @stability    stable
-function calculate_classpath
-{
-  hadoop_add_client_opts
-  hadoop_add_to_classpath_tools hadoop-resourceestimator
-}
+# some Java parameters
+if [ "$JAVA_HOME" != "" ]; then
+  #echo "run java in $JAVA_HOME"
+  JAVA_HOME=$JAVA_HOME
+fi
 
-## @audience     public
-## @stability    stable
-function resourceestimatorcmd_case
-{
-  # shellcheck disable=SC2034
-  HADOOP_SUBCMD_SUPPORTDAEMONIZATION="true"
-  # shellcheck disable=SC2034
-  HADOOP_CLASSNAME='org.apache.hadoop.resourceestimator.service.ResourceEstimatorServer'
-}
+if [ "$JAVA_HOME" = "" ]; then
+  echo "Error: JAVA_HOME is not set."
+  exit 1
+fi
 
+JAVA=$JAVA_HOME/bin/java
 # let's locate libexec...
 if [[ -n "${HADOOP_HOME}" ]]; then
   HADOOP_DEFAULT_LIBEXEC_DIR="${HADOOP_HOME}/libexec"
@@ -49,8 +38,6 @@ else
 fi
 
 HADOOP_LIBEXEC_DIR="${HADOOP_LIBEXEC_DIR:-$HADOOP_DEFAULT_LIBEXEC_DIR}"
-# shellcheck disable=SC2034
-HADOOP_NEW_CONFIG=true
 if [[ -f "${HADOOP_LIBEXEC_DIR}/hadoop-config.sh" ]]; then
   # shellcheck source=./hadoop-common-project/hadoop-common/src/main/bin/hadoop-config.sh
   . "${HADOOP_LIBEXEC_DIR}/hadoop-config.sh"
@@ -58,14 +45,9 @@ else
   echo "ERROR: Cannot execute ${HADOOP_LIBEXEC_DIR}/hadoop-config.sh." 2>&1
   exit 1
 fi
+# shellcheck disable=SC2125
+CLASSPATH=${CLASSPATH}:$bin/../../lib/*
 
-# get arguments
-HADOOP_SUBCMD=$1
-shift
-
-HADOOP_SUBCMD_ARGS=("$@")
-
-resourceestimatorcmd_case "${HADOOP_SUBCMD}" "${HADOOP_SUBCMD_ARGS[@]}"
-
-calculate_classpath
-hadoop_generic_java_subcmd_handler
+CLASS=org.apache.hadoop.resourceestimator.service.ResourceEstimatorServer
+# shellcheck disable=SC2086
+exec "$JAVA" -Dproc_$COMMAND -classpath "$CLASSPATH" $CLASS "$@"

http://git-wip-us.apache.org/repos/asf/hadoop/blob/5991c218/hadoop-tools/hadoop-resourceestimator/src/main/bin/start-estimator.sh
----------------------------------------------------------------------
diff --git a/hadoop-tools/hadoop-resourceestimator/src/main/bin/start-estimator.sh b/hadoop-tools/hadoop-resourceestimator/src/main/bin/start-estimator.sh
index bf4328a..59cb674 100644
--- a/hadoop-tools/hadoop-resourceestimator/src/main/bin/start-estimator.sh
+++ b/hadoop-tools/hadoop-resourceestimator/src/main/bin/start-estimator.sh
@@ -13,30 +13,8 @@
 #  limitations under the License. See accompanying LICENSE file.
 #
 
-# let's locate libexec...
-if [[ -n "${HADOOP_HOME}" ]]; then
-  HADOOP_DEFAULT_LIBEXEC_DIR="${HADOOP_HOME}/libexec"
-else
-  this="${BASH_SOURCE-$0}"
-  bin=$(cd -P -- "$(dirname -- "${this}")" >/dev/null && pwd -P)
-  HADOOP_DEFAULT_LIBEXEC_DIR="${bin}/../../../../../libexec"
-fi
+echo "starting resource estimator service"
 
-HADOOP_LIBEXEC_DIR="${HADOOP_LIBEXEC_DIR:-$HADOOP_DEFAULT_LIBEXEC_DIR}"
-# shellcheck disable=SC2034
-HADOOP_NEW_CONFIG=true
-if [[ -f "${HADOOP_LIBEXEC_DIR}/hadoop-config.sh" ]]; then
-  # shellcheck source=./hadoop-common-project/hadoop-common/src/main/bin/hadoop-config.sh
-  . "${HADOOP_LIBEXEC_DIR}/hadoop-config.sh"
-else
-  echo "ERROR: Cannot execute ${HADOOP_LIBEXEC_DIR}/hadoop-config.sh." 2>&1
-  exit 1
-fi
-
-# start resource estimator
-echo "Starting resource estimator"
-hadoop_uservar_su estimator resourceestimator "bin/estimator.sh" \
-    --config "${HADOOP_CONF_DIR}" \
-    --daemon start \
-    resourceestimator
-(( HADOOP_JUMBO_RETCOUNTER=HADOOP_JUMBO_RETCOUNTER + $? ))
+bin=$(dirname "${BASH_SOURCE-$0}")
+bin=$(cd "$bin" || exit; pwd)
+"$bin"/estimator-daemon.sh start estimator

http://git-wip-us.apache.org/repos/asf/hadoop/blob/5991c218/hadoop-tools/hadoop-resourceestimator/src/main/bin/stop-estimator.sh
----------------------------------------------------------------------
diff --git a/hadoop-tools/hadoop-resourceestimator/src/main/bin/stop-estimator.sh b/hadoop-tools/hadoop-resourceestimator/src/main/bin/stop-estimator.sh
index e78c798..7552c9e 100644
--- a/hadoop-tools/hadoop-resourceestimator/src/main/bin/stop-estimator.sh
+++ b/hadoop-tools/hadoop-resourceestimator/src/main/bin/stop-estimator.sh
@@ -13,30 +13,9 @@
 #  limitations under the License. See accompanying LICENSE file.
 #
 
-# let's locate libexec...
-if [[ -n "${HADOOP_HOME}" ]]; then
-  HADOOP_DEFAULT_LIBEXEC_DIR="${HADOOP_HOME}/libexec"
-else
-  this="${BASH_SOURCE-$0}"
-  bin=$(cd -P -- "$(dirname -- "${this}")" >/dev/null && pwd -P)
-  HADOOP_DEFAULT_LIBEXEC_DIR="${bin}/../../../../../libexec"
-fi
+echo "stopping resource estimator service"
 
-HADOOP_LIBEXEC_DIR="${HADOOP_LIBEXEC_DIR:-$HADOOP_DEFAULT_LIBEXEC_DIR}"
-# shellcheck disable=SC2034
-HADOOP_NEW_CONFIG=true
-if [[ -f "${HADOOP_LIBEXEC_DIR}/hadoop-config.sh" ]]; then
-  # shellcheck source=./hadoop-common-project/hadoop-common/src/main/bin/hadoop-config.sh
-  . "${HADOOP_LIBEXEC_DIR}/hadoop-config.sh"
-else
-  echo "ERROR: Cannot execute ${HADOOP_LIBEXEC_DIR}/hadoop-config.sh." 2>&1
-  exit 1
-fi
+bin=$(dirname "${BASH_SOURCE-$0}")
+bin=$(cd "$bin" || exit; pwd)
 
-# stop resource estimator
-echo "Stopping resource estimator"
-hadoop_uservar_su estimator resourceestimator "bin/estimator.sh" \
-    --config "${HADOOP_CONF_DIR}" \
-    --daemon stop \
-    resourceestimator
-(( HADOOP_JUMBO_RETCOUNTER=HADOOP_JUMBO_RETCOUNTER + $? ))
+"$bin"/estimator-daemon.sh stop estimator


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message