You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ns...@apache.org on 2011/10/11 04:00:40 UTC
svn commit: r1181347 - in /hbase/branches/0.89/bin: hbase-daemon.sh
stop-hbase.sh
Author: nspiegelberg
Date: Tue Oct 11 02:00:40 2011
New Revision: 1181347
URL: http://svn.apache.org/viewvc?rev=1181347&view=rev
Log:
HBASE-2871: Make "start|stop" commands symmetric for Master & Cluster
Modified:
hbase/branches/0.89/bin/hbase-daemon.sh
hbase/branches/0.89/bin/stop-hbase.sh
Modified: hbase/branches/0.89/bin/hbase-daemon.sh
URL: http://svn.apache.org/viewvc/hbase/branches/0.89/bin/hbase-daemon.sh?rev=1181347&r1=1181346&r2=1181347&view=diff
==============================================================================
--- hbase/branches/0.89/bin/hbase-daemon.sh (original)
+++ hbase/branches/0.89/bin/hbase-daemon.sh Tue Oct 11 02:00:40 2011
@@ -132,13 +132,12 @@ case $startStop in
(stop)
if [ -f $pid ]; then
+ # kill -0 == see if the PID exists
if kill -0 `cat $pid` > /dev/null 2>&1; then
echo -n stopping $command
- echo "`date` Stopping $command" >> $loglog
if [ "$command" = "master" ]; then
- nohup nice -n $HBASE_NICENESS "$HBASE_HOME"/bin/hbase \
- --config "${HBASE_CONF_DIR}" \
- $command $startStop "$@" > "$logout" 2>&1 < /dev/null &
+ echo "`date` Killing $command" >> $loglog
+ kill -9 `cat $pid` > /dev/null 2>&1
else
echo "`date` Killing $command" >> $loglog
kill `cat $pid` > /dev/null 2>&1
@@ -150,7 +149,7 @@ case $startStop in
echo
else
retval=$?
- echo no $command to stop because kill of pid `cat $pid` failed with status $retval
+ echo no $command to stop because kill -0 of pid `cat $pid` failed with status $retval
fi
else
echo no $command to stop because no pid file $pid
Modified: hbase/branches/0.89/bin/stop-hbase.sh
URL: http://svn.apache.org/viewvc/hbase/branches/0.89/bin/stop-hbase.sh?rev=1181347&r1=1181346&r2=1181347&view=diff
==============================================================================
--- hbase/branches/0.89/bin/stop-hbase.sh (original)
+++ hbase/branches/0.89/bin/stop-hbase.sh Tue Oct 11 02:00:40 2011
@@ -29,7 +29,34 @@ bin=`cd "$bin">/dev/null; pwd`
. "$bin"/hbase-config.sh
-"$bin"/hbase-daemon.sh --config "${HBASE_CONF_DIR}" stop master
+# variables needed for stop command
+if [ "$HBASE_LOG_DIR" = "" ]; then
+ export HBASE_LOG_DIR="$HBASE_HOME/logs"
+fi
+mkdir -p "$HBASE_LOG_DIR"
+
+if [ "$HBASE_IDENT_STRING" = "" ]; then
+ export HBASE_IDENT_STRING="$USER"
+fi
+
+export HBASE_LOGFILE=hbase-$HBASE_IDENT_STRING-master-$HOSTNAME.log
+logout=$HBASE_LOG_DIR/hbase-$HBASE_IDENT_STRING-master-$HOSTNAME.out
+loglog="${HBASE_LOG_DIR}/${HBASE_LOGFILE}"
+pid=${HBASE_PID_DIR:-/tmp}/hbase-$HBASE_IDENT_STRING-master.pid
+
+echo -n stopping hbase
+echo "`date` Stopping hbase (via master)" >> $loglog
+
+nohup nice -n ${HBASE_NICENESS:-0} "$HBASE_HOME"/bin/hbase \
+ --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
+
+# distributed == false means that the HMaster will kill ZK when it exits
distMode=`$bin/hbase org.apache.hadoop.hbase.HBaseConfTool hbase.cluster.distributed`
if [ "$distMode" == 'true' ]
then