hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r1299983 - /hbase/trunk/bin/rolling-restart.sh
Date Tue, 13 Mar 2012 06:30:15 GMT
Author: stack
Date: Tue Mar 13 06:30:15 2012
New Revision: 1299983

URL: http://svn.apache.org/viewvc?rev=1299983&view=rev
Log:
HBASE-5314 racefully rolling restart region servers in rolling-restart.sh

Modified:
    hbase/trunk/bin/rolling-restart.sh

Modified: hbase/trunk/bin/rolling-restart.sh
URL: http://svn.apache.org/viewvc/hbase/trunk/bin/rolling-restart.sh?rev=1299983&r1=1299982&r2=1299983&view=diff
==============================================================================
--- hbase/trunk/bin/rolling-restart.sh (original)
+++ hbase/trunk/bin/rolling-restart.sh Tue Mar 13 06:30:15 2012
@@ -34,7 +34,7 @@
 #
 # Modelled after $HADOOP_HOME/bin/slaves.sh.
 
-usage="Usage: $0 [--config <hbase-confdir>] [--rs-only] [--master-only]"
+usage="Usage: $0 [--config <hbase-confdir>] [--rs-only] [--master-only] [--graceful]"
 
 bin=`dirname "$0"`
 bin=`cd "$bin">/dev/null; pwd`
@@ -56,16 +56,24 @@ function usage() {
 
 RR_RS=1
 RR_MASTER=1
+RR_GRACEFUL=0
 
 for x in "$@" ; do
   case "$x" in
     --rs-only|-r)
       RR_RS=1
       RR_MASTER=0
+      RR_GRACEFUL=0
       ;;
     --master-only)
       RR_RS=0
       RR_MASTER=1
+      RR_GRACEFUL=0
+      ;;
+    --graceful)
+      RR_RS=0
+      RR_MASTER=0
+      RR_GRACEFUL=1
       ;;
     *)
       echo Bad argument: $x
@@ -84,6 +92,9 @@ if [ "$distMode" == 'false' ]; then
   fi
   "$bin"/hbase-daemon.sh restart master
 else 
+  zparent=`$bin/hbase org.apache.hadoop.hbase.util.HBaseConfTool zookeeper.znode.parent`
+  if [ "$zparent" == "null" ]; then zparent="/hbase"; fi
+
   if [ $RR_MASTER -eq 1 ]; then
     # stop all masters before re-start to avoid races for master znode
     "$bin"/hbase-daemon.sh --config "${HBASE_CONF_DIR}" stop master 
@@ -91,8 +102,6 @@ else 
       --hosts "${HBASE_BACKUP_MASTERS}" stop master-backup
 
     # make sure the master znode has been deleted before continuing
-    zparent=`$bin/hbase org.apache.hadoop.hbase.util.HBaseConfTool zookeeper.znode.parent`
-    if [ "$zparent" == "null" ]; then zparent="/hbase"; fi
     zmaster=`$bin/hbase org.apache.hadoop.hbase.util.HBaseConfTool zookeeper.znode.master`
     if [ "$zmaster" == "null" ]; then zmaster="master"; fi
     zmaster=$zparent/$zmaster
@@ -136,4 +145,17 @@ else 
     "$bin"/hbase-daemons.sh --config "${HBASE_CONF_DIR}" \
       --hosts "${HBASE_REGIONSERVERS}" restart regionserver
   fi
+
+  if [ $RR_GRACEFUL -eq 1 ]; then
+    # gracefully restart all online regionservers
+    online_regionservers=`$bin/hbase zkcli ls $zparent/rs 2>&1 | tail -1 | sed "s/\[//"
| sed "s/\]//"`
+    for rs in $online_regionservers
+    do
+        rs_parts=(${rs//,/ })
+        hostname=${rs_parts[0]}
+        echo "Gracefully restarting: $hostname"
+        "$bin"/graceful_stop.sh --config "${HBASE_CONF_DIR}" --restart --reload --debug "$hostname"
+        sleep 1
+    done
+  fi
 fi



Mime
View raw message