Skip to content

Commit

Permalink
HBASE-24671 Add excludefile and designatedfile options to graceful_st…
Browse files Browse the repository at this point in the history
…op.sh

Closes #2013

Signed-off-by: Viraj Jasani <vjasani@apache.org>
  • Loading branch information
ZhaoBQ authored and virajjasani committed Jul 5, 2020
1 parent a7a0e1a commit fe2ae80
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 11 deletions.
26 changes: 22 additions & 4 deletions bin/graceful_stop.sh
Expand Up @@ -22,7 +22,8 @@
# Turn off the balancer before running this script.
function usage {
echo "Usage: graceful_stop.sh [--config <conf-dir>] [-e] [--restart [--reload]] [--thrift] \
[--rest] [-nob |--nobalancer ] <hostname>"
[--rest] [-n |--noack] [--maxthreads <number of threads>] [--movetimeout <timeout in seconds>] \
[-nob |--nobalancer] [-d |--designatedfile <file path>] [-x |--excludefile <file path>] <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"
Expand All @@ -34,8 +35,11 @@ moving regions"
exit with error. Default value is INT_MAX."
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"
echo " nob| nobalancer Do not manage balancer states. This is only used as optimization in \
echo " nob|nobalancer Do not manage balancer states. This is only used as optimization in \
rolling_restart.sh to avoid multiple calls to hbase shell"
echo " d|designatedfile xx Designated file with <hostname:port> per line as unload targets"
echo " x|excludefile xx Exclude file should have <hostname:port> per line. We do not unload \
regions to hostnames given in exclude file"
exit 1
}

Expand All @@ -57,6 +61,8 @@ movetimeout=2147483647
maxthreads=1
failfast=
nob=false
designatedfile=
excludefile=
while [ $# -gt 0 ]
do
case "$1" in
Expand All @@ -69,6 +75,8 @@ do
--maxthreads) shift; maxthreads=$1; shift;;
--movetimeout) shift; movetimeout=$1; shift;;
--nobalancer | -nob) nob=true; shift;;
--designatedfile | -d) shift; designatedfile=$1; shift;;
--excludefile | -x) shift; excludefile=$1; shift;;
--) shift; break;;
-*) usage ;;
*) break;; # terminate while loop
Expand Down Expand Up @@ -110,10 +118,20 @@ else
log "Previous balancer state was $HBASE_BALANCER_STATE"
fi

unload_args="--filename $filename --maxthreads $maxthreads $noack --operation unload \
--timeout $movetimeout --regionserverhost $hostname"

if [ "$designatedfile" != "" ]; then
unload_args="$unload_args --designatedfile $designatedfile"
fi

if [ "$excludefile" != "" ]; then
unload_args="$unload_args --excludefile $excludefile"
fi

log "Unloading $hostname region(s)"
HBASE_NOEXEC=true "$bin"/hbase --config ${HBASE_CONF_DIR} org.apache.hadoop.hbase.util.RegionMover \
--filename $filename --maxthreads $maxthreads $noack --operation "unload" --timeout $movetimeout \
--regionserverhost $hostname
$unload_args
log "Unloaded $hostname region(s)"

# Stop the server(s). Have to put hostname into its own little file for hbase-daemons.sh
Expand Down
20 changes: 13 additions & 7 deletions src/main/asciidoc/_chapters/ops_mgt.adoc
Expand Up @@ -1385,13 +1385,19 @@ Here is its usage:

----
$ ./bin/graceful_stop.sh
Usage: graceful_stop.sh [--config &conf-dir>] [--restart] [--reload] [--thrift] [--rest] &hostname>
thrift If we should stop/start thrift before/after the hbase stop/start
rest If we should stop/start rest before/after the hbase stop/start
restart If we should restart after graceful stop
reload Move offloaded regions back on to the stopped server
debug Move offloaded regions back on to the stopped server
hostname Hostname of server we are to stop
Usage: graceful_stop.sh [--config <conf-dir>] [-e] [--restart [--reload]] [--thrift] [--rest] [-n |--noack] [--maxthreads <number of threads>] [--movetimeout <timeout in seconds>] [-nob |--nobalancer] [-d |--designatedfile <file path>] [-x |--excludefile <file path>] <hostname>
thrift If we should stop/start thrift before/after the hbase stop/start
rest If we should stop/start rest before/after the hbase stop/start
restart If we should restart after graceful stop
reload Move offloaded regions back on to the restarted server
n|noack Enable noAck mode in RegionMover. This is a best effort mode for moving regions
maxthreads xx Limit the number of threads used by the region mover. Default value is 1.
movetimeout xx Timeout for moving regions. If regions are not moved by the timeout value,exit with error. Default value is INT_MAX.
hostname Hostname of server we are to stop
e|failfast Set -e so exit immediately if any command exits with non-zero status
nob|nobalancer Do not manage balancer states. This is only used as optimization in rolling_restart.sh to avoid multiple calls to hbase shell
d|designatedfile xx Designated file with <hostname:port> per line as unload targets
x|excludefile xx Exclude file should have <hostname:port> per line. We do not unload regions to hostnames given in exclude file
----

To decommission a loaded RegionServer, run the following: +$
Expand Down

0 comments on commit fe2ae80

Please sign in to comment.