You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zh...@apache.org on 2018/02/15 04:33:39 UTC
[13/30] hbase git commit: HBASE-19844 Shell should support to flush
by regionserver
HBASE-19844 Shell should support to flush by regionserver
Signed-off-by: tedyu <yu...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/8e8e1e5a
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/8e8e1e5a
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/8e8e1e5a
Branch: refs/heads/HBASE-19064
Commit: 8e8e1e5a1bbb240a6f4a71bc8b0271d31da633b3
Parents: ba402b1
Author: Reid Chan <re...@outlook.com>
Authored: Tue Feb 13 14:32:16 2018 +0800
Committer: tedyu <yu...@gmail.com>
Committed: Tue Feb 13 08:20:54 2018 -0800
----------------------------------------------------------------------
hbase-shell/src/main/ruby/hbase/admin.rb | 21 +++++++++++++++-----
.../src/main/ruby/shell/commands/flush.rb | 5 ++++-
hbase-shell/src/test/ruby/hbase/admin_test.rb | 4 ++++
3 files changed, 24 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/8e8e1e5a/hbase-shell/src/main/ruby/hbase/admin.rb
----------------------------------------------------------------------
diff --git a/hbase-shell/src/main/ruby/hbase/admin.rb b/hbase-shell/src/main/ruby/hbase/admin.rb
index 0102118..f524380 100644
--- a/hbase-shell/src/main/ruby/hbase/admin.rb
+++ b/hbase-shell/src/main/ruby/hbase/admin.rb
@@ -50,12 +50,17 @@ module Hbase
end
#----------------------------------------------------------------------------------------------
- # Requests a table or region flush
- def flush(table_or_region_name)
- @admin.flushRegion(table_or_region_name.to_java_bytes)
- rescue java.lang.IllegalArgumentException => e
+ # Requests a table or region or region server flush
+ def flush(name)
+ @admin.flushRegion(name.to_java_bytes)
+ rescue java.lang.IllegalArgumentException
# Unknown region. Try table.
- @admin.flush(TableName.valueOf(table_or_region_name))
+ begin
+ @admin.flush(TableName.valueOf(name))
+ rescue java.lang.IllegalArgumentException
+ # Unknown table. Try region server.
+ @admin.flushRegionServer(ServerName.valueOf(name))
+ end
end
#----------------------------------------------------------------------------------------------
@@ -1286,5 +1291,11 @@ module Hbase
end
@admin.clearDeadServers(servers).to_a
end
+
+ #----------------------------------------------------------------------------------------------
+ # List live region servers
+ def list_liveservers
+ @admin.getClusterStatus.getServers.to_a
+ end
end
end
http://git-wip-us.apache.org/repos/asf/hbase/blob/8e8e1e5a/hbase-shell/src/main/ruby/shell/commands/flush.rb
----------------------------------------------------------------------
diff --git a/hbase-shell/src/main/ruby/shell/commands/flush.rb b/hbase-shell/src/main/ruby/shell/commands/flush.rb
index 4165b84..1f6b310 100644
--- a/hbase-shell/src/main/ruby/shell/commands/flush.rb
+++ b/hbase-shell/src/main/ruby/shell/commands/flush.rb
@@ -23,11 +23,14 @@ module Shell
def help
<<-EOF
Flush all regions in passed table or pass a region row to
-flush an individual region. For example:
+flush an individual region or a region server name whose format
+is 'host,port,startcode', to flush all its regions.
+For example:
hbase> flush 'TABLENAME'
hbase> flush 'REGIONNAME'
hbase> flush 'ENCODED_REGIONNAME'
+ hbase> flush 'REGION_SERVER_NAME'
EOF
end
http://git-wip-us.apache.org/repos/asf/hbase/blob/8e8e1e5a/hbase-shell/src/test/ruby/hbase/admin_test.rb
----------------------------------------------------------------------
diff --git a/hbase-shell/src/test/ruby/hbase/admin_test.rb b/hbase-shell/src/test/ruby/hbase/admin_test.rb
index cbeb8b6..929484c 100644
--- a/hbase-shell/src/test/ruby/hbase/admin_test.rb
+++ b/hbase-shell/src/test/ruby/hbase/admin_test.rb
@@ -101,6 +101,10 @@ module Hbase
define_test "flush should work" do
command(:flush, 'hbase:meta')
+ servers = admin.list_liveservers
+ servers.each do |s|
+ command(:flush, s.toString)
+ end
end
#-------------------------------------------------------------------------------