From a396ae773a0f7dbcd6f54fc8133b7a9dc30d8431 Mon Sep 17 00:00:00 2001 From: Apekshit Sharma Date: Tue, 28 Jun 2016 16:55:09 -0700 Subject: [PATCH] HBASE-16044 Fix 'hbase shell' output parsing in graceful_stop.sh Change-Id: I94b2f665105837d31281be66d620b6152c3bc9d1 --- bin/graceful_stop.sh | 2 +- bin/rolling-restart.sh | 2 +- hbase-shell/src/main/ruby/shell/commands/balance_switch.rb | 4 +++- hbase-shell/src/main/ruby/shell/commands/balancer_enabled.rb | 4 +++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/bin/graceful_stop.sh b/bin/graceful_stop.sh index 8d08cc9adb9..89e3dd939c2 100755 --- a/bin/graceful_stop.sh +++ b/bin/graceful_stop.sh @@ -106,7 +106,7 @@ if [ "$nob" == "true" ]; then HBASE_BALANCER_STATE=false else log "Disabling load balancer" - HBASE_BALANCER_STATE=$(echo 'balance_switch false' | "$bin"/hbase --config "${HBASE_CONF_DIR}" shell | tail -3 | head -1) + HBASE_BALANCER_STATE=$(echo 'balance_switch false' | "$bin"/hbase --config "${HBASE_CONF_DIR}" shell -n | tail -1) log "Previous balancer state was $HBASE_BALANCER_STATE" fi diff --git a/bin/rolling-restart.sh b/bin/rolling-restart.sh index 530b76ba346..9ac4d64b823 100755 --- a/bin/rolling-restart.sh +++ b/bin/rolling-restart.sh @@ -189,7 +189,7 @@ else zkrs="$zparent/$zkrs" online_regionservers=`$bin/hbase zkcli ls $zkrs 2>&1 | tail -1 | sed "s/\[//" | sed "s/\]//"` echo "Disabling load balancer" - HBASE_BALANCER_STATE=$(echo 'balance_switch false' | "$bin"/hbase --config "${HBASE_CONF_DIR}" shell | tail -3 | head -1) + HBASE_BALANCER_STATE=$(echo 'balance_switch false' | "$bin"/hbase --config "${HBASE_CONF_DIR}" shell -n | tail -1) echo "Previous balancer state was $HBASE_BALANCER_STATE" for rs in $online_regionservers diff --git a/hbase-shell/src/main/ruby/shell/commands/balance_switch.rb b/hbase-shell/src/main/ruby/shell/commands/balance_switch.rb index 107d26748fa..4076cf61e93 100644 --- a/hbase-shell/src/main/ruby/shell/commands/balance_switch.rb +++ b/hbase-shell/src/main/ruby/shell/commands/balance_switch.rb @@ -31,7 +31,9 @@ EOF end def command(enableDisable) - formatter.row([admin.balance_switch(enableDisable)? "true" : "false"]) + prev_state = admin.balance_switch(enableDisable)? "true" : "false" + formatter.row(["Previous balancer state : #{prev_state}"]) + prev_state end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/balancer_enabled.rb b/hbase-shell/src/main/ruby/shell/commands/balancer_enabled.rb index 6a75ab54fe7..c3d7a2b404b 100644 --- a/hbase-shell/src/main/ruby/shell/commands/balancer_enabled.rb +++ b/hbase-shell/src/main/ruby/shell/commands/balancer_enabled.rb @@ -30,7 +30,9 @@ EOF end def command() - formatter.row([admin.balancer_enabled?.to_s]) + state = admin.balancer_enabled? + formatter.row([state.to_s]) + state end end end