You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by nk...@apache.org on 2013/02/22 12:33:12 UTC
svn commit: r1448997 - in /hbase/trunk/bin: hbase-common.sh hbase-daemon.sh
stop-hbase.sh
Author: nkeywal
Date: Fri Feb 22 11:33:11 2013
New Revision: 1448997
URL: http://svn.apache.org/r1448997
Log:
HBASE-7838 HBase regionserver never stoping when running hbase-daemon.sh stop regionserver (Damien Hardy) - addendum
Added:
hbase/trunk/bin/hbase-common.sh
Modified:
hbase/trunk/bin/hbase-daemon.sh
hbase/trunk/bin/stop-hbase.sh
Added: hbase/trunk/bin/hbase-common.sh
URL: http://svn.apache.org/viewvc/hbase/trunk/bin/hbase-common.sh?rev=1448997&view=auto
==============================================================================
--- hbase/trunk/bin/hbase-common.sh (added)
+++ hbase/trunk/bin/hbase-common.sh Fri Feb 22 11:33:11 2013
@@ -0,0 +1,40 @@
+##
+# 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.
+##
+
+#Shared function to wait for a process end. Take the pid and the command name as parameters
+waitForProcessEnd() {
+ pidKilled=$1
+ commandName=$2
+ processedAt=`date +%s`
+ while kill -0 $pidKilled > /dev/null 2>&1;
+ do
+ echo -n "."
+ sleep 1;
+ # if process persists more than $HBASE_STOP_TIMEOUT (default 1200 sec) no mercy
+ if [ $(( `date +%s` - $processedAt )) -gt ${HBASE_STOP_TIMEOUT:-1200} ]; then
+ break;
+ fi
+ done
+ # process still there : kill -9
+ if kill -0 $pidKilled > /dev/null 2>&1; then
+ echo -n force stopping $commandName with kill -9 $pidKilled
+ kill -9 $pidKilled > /dev/null 2>&1
+ fi
+ # Add a CR after we're done w/ dots.
+ echo
+}
Modified: hbase/trunk/bin/hbase-daemon.sh
URL: http://svn.apache.org/viewvc/hbase/trunk/bin/hbase-daemon.sh?rev=1448997&r1=1448996&r2=1448997&view=diff
==============================================================================
--- hbase/trunk/bin/hbase-daemon.sh (original)
+++ hbase/trunk/bin/hbase-daemon.sh Fri Feb 22 11:33:11 2013
@@ -29,6 +29,8 @@
# HBASE_PID_DIR The pid files are stored. /tmp by default.
# HBASE_IDENT_STRING A string representing this instance of hadoop. $USER by default
# HBASE_NICENESS The scheduling priority for daemons. Defaults to 0.
+# HBASE_STOP_TIMEOUT Time, in seconds, after which we kill -9 the server if it has not stopped.
+# Default 1200 seconds.
#
# Modelled after $HADOOP_HOME/bin/hadoop-daemon.sh
@@ -46,6 +48,7 @@ bin=`dirname "${BASH_SOURCE-$0}"`
bin=`cd "$bin">/dev/null; pwd`
. "$bin"/hbase-config.sh
+. "$bin"/hbase-common.sh
# get arguments
startStop=$1
@@ -235,28 +238,13 @@ case $startStop in
rm -f "$HBASE_START_FILE"
if [ -f $pid ]; then
pidToKill=`cat $pid`
- processedAt=`date +%s`
# kill -0 == see if the PID exists
if kill -0 $pidToKill > /dev/null 2>&1; then
echo -n stopping $command
echo "`date` Terminating $command" >> $loglog
kill $pidToKill > /dev/null 2>&1
- while kill -0 $pidToKill > /dev/null 2>&1;
- do
- echo -n "."
- sleep 1;
- # if process persists more than $HBASE_STOP_TIMEOUT (default 1200 sec) no mercy
- if [ $(( `date +%s` - $processedAt )) -gt ${HBASE_STOP_TIMEOUT:-1200} ]; then
- break;
- fi
- done
- # process still there : kill kill
- if kill -0 $pidToKill > /dev/null 2>&1; then
- echo -n force stopping $command
- kill -9 $pidToKill > /dev/null 2>&1
- fi
+ waitForProcessEnd $pidToKill $command
rm $pid
- echo
else
retval=$?
echo no $command to stop because kill -0 of pid $pidToKill failed with status $retval
Modified: hbase/trunk/bin/stop-hbase.sh
URL: http://svn.apache.org/viewvc/hbase/trunk/bin/stop-hbase.sh?rev=1448997&r1=1448996&r2=1448997&view=diff
==============================================================================
--- hbase/trunk/bin/stop-hbase.sh (original)
+++ hbase/trunk/bin/stop-hbase.sh Fri Feb 22 11:33:11 2013
@@ -28,6 +28,7 @@ bin=`dirname "${BASH_SOURCE-$0}"`
bin=`cd "$bin">/dev/null; pwd`
. "$bin"/hbase-config.sh
+. "$bin"/hbase-common.sh
# variables needed for stop command
if [ "$HBASE_LOG_DIR" = "" ]; then
@@ -52,13 +53,10 @@ nohup nice -n ${HBASE_NICENESS:-0} "$HBA
--config "${HBASE_CONF_DIR}" \
master stop "$@" > "$logout" 2>&1 < /dev/null &
-while kill -0 `cat $pid` > /dev/null 2>&1; do
- echo -n "."
- sleep 1;
-done
+waitForProcessEnd `cat $pid` 'stop-master-command'
+
rm -f $pid
-# Add a CR after we're done w/ dots.
-echo
+
# distributed == false means that the HMaster will kill ZK when it exits
# HBASE-6504 - only take the first line of the output in case verbose gc is on