HBASE-19844 Shell should support to flush by regionserver

Signed-off-by: tedyu <yuzhihong@gmail.com>
This commit is contained in:
Reid Chan 2018-02-13 14:32:16 +08:00 committed by tedyu
parent ba402b1e7b
commit 8e8e1e5a1b
3 changed files with 24 additions and 6 deletions

View File

@ -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

View File

@ -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

View File

@ -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
#-------------------------------------------------------------------------------