From 7c48f57f61666afa3162ced76846376c2029b9df Mon Sep 17 00:00:00 2001 From: "yoshida.shinya" Date: Mon, 6 Jun 2022 15:20:02 +0900 Subject: [PATCH 1/2] HBASE-27086 Fix graceful_stop cannot take previous balancer status by incompatibility of hbase shell prompt --- bin/graceful_stop.sh | 2 +- hbase-shell/src/main/ruby/jar-bootstrap.rb | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/bin/graceful_stop.sh b/bin/graceful_stop.sh index fc18239830b2..ff8fac90b6f2 100755 --- a/bin/graceful_stop.sh +++ b/bin/graceful_stop.sh @@ -115,7 +115,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 -n | tail -1) + HBASE_BALANCER_STATE=$(echo 'balance_switch false' | "$bin"/hbase --config "${HBASE_CONF_DIR}" shell -n | tail -2 | head -1) log "Previous balancer state was $HBASE_BALANCER_STATE" fi diff --git a/hbase-shell/src/main/ruby/jar-bootstrap.rb b/hbase-shell/src/main/ruby/jar-bootstrap.rb index 917817fc59f9..7d1e33c1f4fc 100644 --- a/hbase-shell/src/main/ruby/jar-bootstrap.rb +++ b/hbase-shell/src/main/ruby/jar-bootstrap.rb @@ -203,7 +203,10 @@ def debug? IRB.conf[:IRB_NAME] = 'hbase' IRB.conf[:AP_NAME] = 'hbase' -IRB.conf[:PROMPT_MODE] = :CUSTOM +if IRB.conf[:PROMPT_MODE] != :NULL + # When prompt mode is :NULL, hbase shell is started with pipe for stdin, so prompt isn't necessary + IRB.conf[:PROMPT_MODE] = :CUSTOM +end IRB.conf[:BACK_TRACE_LIMIT] = 0 unless full_backtrace # Create a workspace we'll use across sessions. From a1eccaa174157f0c68217996f37a51472ded66bd Mon Sep 17 00:00:00 2001 From: "yoshida.shinya" Date: Thu, 9 Jun 2022 18:49:25 +0900 Subject: [PATCH 2/2] Change condition to use :CUSTOM prompt mode to only when interactive is enabled --- hbase-shell/src/main/ruby/jar-bootstrap.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hbase-shell/src/main/ruby/jar-bootstrap.rb b/hbase-shell/src/main/ruby/jar-bootstrap.rb index 7d1e33c1f4fc..4ea6d6139d60 100644 --- a/hbase-shell/src/main/ruby/jar-bootstrap.rb +++ b/hbase-shell/src/main/ruby/jar-bootstrap.rb @@ -203,8 +203,7 @@ def debug? IRB.conf[:IRB_NAME] = 'hbase' IRB.conf[:AP_NAME] = 'hbase' -if IRB.conf[:PROMPT_MODE] != :NULL - # When prompt mode is :NULL, hbase shell is started with pipe for stdin, so prompt isn't necessary +if interactive IRB.conf[:PROMPT_MODE] = :CUSTOM end IRB.conf[:BACK_TRACE_LIMIT] = 0 unless full_backtrace