hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r1494449 - /hbase/trunk/bin/graceful_stop.sh
Date Wed, 19 Jun 2013 04:42:15 GMT
Author: stack
Date: Wed Jun 19 04:42:15 2013
New Revision: 1494449

URL: http://svn.apache.org/r1494449
Log:
HBASE-8716 Fixups/Improvements for graceful_stop.sh/region_mover.rb

Modified:
    hbase/trunk/bin/graceful_stop.sh

Modified: hbase/trunk/bin/graceful_stop.sh
URL: http://svn.apache.org/viewvc/hbase/trunk/bin/graceful_stop.sh?rev=1494449&r1=1494448&r2=1494449&view=diff
==============================================================================
--- hbase/trunk/bin/graceful_stop.sh (original)
+++ hbase/trunk/bin/graceful_stop.sh Wed Jun 19 04:42:15 2013
@@ -23,13 +23,14 @@
 # Move regions off a server then stop it.  Optionally restart and reload.
 # Turn off the balancer before running this script.
 function usage {
-  echo "Usage: graceful_stop.sh [--config <conf-dir>] [--restart [--reload]] [--thrift]
[--rest] <hostname>"
+  echo "Usage: graceful_stop.sh [--config <conf-dir>] [-d] [-e] [--restart [--reload]]
[--thrift] [--rest] <hostname>"
   echo " thrift      If we should stop/start thrift before/after the hbase stop/start"
   echo " rest        If we should stop/start rest before/after the hbase stop/start"
   echo " restart     If we should restart after graceful stop"
-  echo "   reload      Move offloaded regions back on to the restarted server"
-  echo " debug       Print helpful debug information"
+  echo " reload      Move offloaded regions back on to the restarted server"
+  echo " d|debug     Print helpful debug information"
   echo " hostname    Hostname of server we are to stop"
+  echo " e|failfast  Set -e so exit immediately if any command exits with non-zero status"
   exit 1
 }
 
@@ -47,6 +48,7 @@ reload=
 debug=
 thrift=
 rest=
+failfast=
 while [ $# -gt 0 ]
 do
   case "$1" in
@@ -54,7 +56,10 @@ do
     --rest)  rest=true; shift;;
     --restart)  restart=true; shift;;
     --reload)   reload=true; shift;;
-    --debug)    debug="--debug"; shift;;
+    --failfast) ;&
+    -e)  failfast=true; shift;;
+    --debug)  ;&
+    -d)  debug="--debug"; shift;;
     --) shift; break;;
     -*) usage ;;
     *)  break;;	# terminate while loop
@@ -66,44 +71,65 @@ if [ $# -lt 1 ]; then
   usage
 fi
 
+# Emit a log line w/ iso8901 date prefixed
+log() {
+  echo `date +%Y-%m-%dT%H:%M:%S` $1
+}
+
+# See if we should set fail fast before we do anything.
+if [ "$failfast" != "" ]; then
+  log "Set failfast, will exit immediately if any command exits with non-zero status"
+  set -e
+fi
+
 hostname=$1
 filename="/tmp/$hostname"
-# Run the region mover script.
-echo "Disabling balancer! (if required)"
+
+log "Disabling load balancer"
 HBASE_BALANCER_STATE=`echo 'balance_switch false' | "$bin"/hbase --config ${HBASE_CONF_DIR}
shell | tail -3 | head -1`
-echo "Previous balancer state was $HBASE_BALANCER_STATE"
-echo "Unloading $hostname region(s)"
+log "Previous balancer state was $HBASE_BALANCER_STATE"
+
+log "Unloading $hostname region(s)"
 HBASE_NOEXEC=true "$bin"/hbase --config ${HBASE_CONF_DIR} org.jruby.Main "$bin"/region_mover.rb
--file=$filename $debug unload $hostname
-echo "Unloaded $hostname region(s)"
-# Stop the server. Have to put hostname into its own little file for hbase-daemons.sh
+log "Unloaded $hostname region(s)"
+
+# Stop the server(s). Have to put hostname into its own little file for hbase-daemons.sh
 hosts="/tmp/$(basename $0).$$.tmp"
 echo $hostname >> $hosts
 if [ "$thrift" != "" ]; then
+  log "Stopping thrift"
   "$bin"/hbase-daemons.sh --config ${HBASE_CONF_DIR} --hosts ${hosts} stop thrift
 fi
 if [ "$rest" != "" ]; then
+  log "Stopping rest"
   "$bin"/hbase-daemons.sh --config ${HBASE_CONF_DIR} --hosts ${hosts} stop rest
 fi
+log "Stopping regionserver"
 "$bin"/hbase-daemons.sh --config ${HBASE_CONF_DIR} --hosts ${hosts} stop regionserver
+
 if [ "$restart" != "" ]; then
+  log "Restarting regionserver"
   "$bin"/hbase-daemons.sh --config ${HBASE_CONF_DIR} --hosts ${hosts} start regionserver
   if [ "$thrift" != "" ]; then
+    log "Restarting thrift"
     # -b 0.0.0.0 says listen on all interfaces rather than just default.
     "$bin"/hbase-daemons.sh --config ${HBASE_CONF_DIR} --hosts ${hosts} start thrift -b 0.0.0.0
   fi
   if [ "$rest" != "" ]; then
+    log "Restarting rest"
     "$bin"/hbase-daemons.sh --config ${HBASE_CONF_DIR} --hosts ${hosts} start rest
   fi
   if [ "$reload" != "" ]; then
-    echo "Reloading $hostname region(s)"
+    log "Reloading $hostname region(s)"
     HBASE_NOEXEC=true "$bin"/hbase --config ${HBASE_CONF_DIR} org.jruby.Main "$bin"/region_mover.rb
--file=$filename $debug load $hostname
-    echo "Reloaded $hostname region(s)"
+    log "Reloaded $hostname region(s)"
   fi
 fi
 
+# Restore balancer state
 if [ $HBASE_BALANCER_STATE != "false" ]; then
-  echo "Restoring balancer state to " $HBASE_BALANCER_STATE
-  echo "balance_switch $HBASE_BALANCER_STATE" | "$bin"/hbase --config ${HBASE_CONF_DIR} shell
&> /dev/null
+  log "Restoring balancer state to " $HBASE_BALANCER_STATE
+  log "balance_switch $HBASE_BALANCER_STATE" | "$bin"/hbase --config ${HBASE_CONF_DIR} shell
&> /dev/null
 fi
 
 # Cleanup tmp files.



Mime
View raw message