HADOOP-15026. Rebase ResourceEstimator start/stop scripts for branch-2. (Rui Li via Subru).
This commit is contained in:
parent
46a740a82e
commit
5991c218a0
|
@ -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
|
|
@ -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 "$@"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue