You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2010/08/04 07:27:09 UTC

svn commit: r982123 - in /hbase/trunk: CHANGES.txt bin/hbase-daemon.sh bin/stop-hbase.sh

Author: stack
Date: Wed Aug  4 05:27:09 2010
New Revision: 982123

URL: http://svn.apache.org/viewvc?rev=982123&view=rev
Log:
HBASE-2871 Make 'start|stop' commands symmetric for Master & Cluster

Modified:
    hbase/trunk/CHANGES.txt
    hbase/trunk/bin/hbase-daemon.sh
    hbase/trunk/bin/stop-hbase.sh

Modified: hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/trunk/CHANGES.txt?rev=982123&r1=982122&r2=982123&view=diff
==============================================================================
--- hbase/trunk/CHANGES.txt (original)
+++ hbase/trunk/CHANGES.txt Wed Aug  4 05:27:09 2010
@@ -466,6 +466,8 @@ Release 0.21.0 - Unreleased
    HBASE-2892  Replication metrics aren't updated
    HBASE-2461  Split doesn't handle IOExceptions when creating new region
                reference files
+   HBASE-2871  Make "start|stop" commands symmetric for Master & Cluster
+               (Nicolas Spiegelberg via Stack)
 
   IMPROVEMENTS
    HBASE-1760  Cleanup TODOs in HTable

Modified: hbase/trunk/bin/hbase-daemon.sh
URL: http://svn.apache.org/viewvc/hbase/trunk/bin/hbase-daemon.sh?rev=982123&r1=982122&r2=982123&view=diff
==============================================================================
--- hbase/trunk/bin/hbase-daemon.sh (original)
+++ hbase/trunk/bin/hbase-daemon.sh Wed Aug  4 05:27:09 2010
@@ -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/trunk/bin/stop-hbase.sh
URL: http://svn.apache.org/viewvc/hbase/trunk/bin/stop-hbase.sh?rev=982123&r1=982122&r2=982123&view=diff
==============================================================================
--- hbase/trunk/bin/stop-hbase.sh (original)
+++ hbase/trunk/bin/stop-hbase.sh Wed Aug  4 05:27:09 2010
@@ -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