HBASE-23134 Enable_all and Disable_all table by Regex fail from Shell (#698)
Signed-off-by: Duo Zhang <zhangduo@apache.org>
This commit is contained in:
parent
54083a7626
commit
3427999ff7
|
@ -308,8 +308,17 @@ module Hbase
|
||||||
#----------------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------------
|
||||||
# Enables all tables matching the given regex
|
# Enables all tables matching the given regex
|
||||||
def enable_all(regex)
|
def enable_all(regex)
|
||||||
regex = regex.to_s
|
pattern = Pattern.compile(regex.to_s)
|
||||||
@admin.enableTables(Pattern.compile(regex))
|
failed = java.util.ArrayList.new
|
||||||
|
@admin.listTableNames(pattern).each do |table_name|
|
||||||
|
begin
|
||||||
|
@admin.enableTable(table_name)
|
||||||
|
rescue java.io.IOException => e
|
||||||
|
puts "table:#{table_name}, error:#{e.toString}"
|
||||||
|
failed.add(table_name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
failed
|
||||||
end
|
end
|
||||||
|
|
||||||
#----------------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------------
|
||||||
|
@ -324,7 +333,16 @@ module Hbase
|
||||||
# Disables all tables matching the given regex
|
# Disables all tables matching the given regex
|
||||||
def disable_all(regex)
|
def disable_all(regex)
|
||||||
pattern = Pattern.compile(regex.to_s)
|
pattern = Pattern.compile(regex.to_s)
|
||||||
@admin.disableTables(pattern).map { |t| t.getTableName.getNameAsString }
|
failed = java.util.ArrayList.new
|
||||||
|
@admin.listTableNames(pattern).each do |table_name|
|
||||||
|
begin
|
||||||
|
@admin.disableTable(table_name)
|
||||||
|
rescue java.io.IOException => e
|
||||||
|
puts "table:#{table_name}, error:#{e.toString}"
|
||||||
|
failed.add(table_name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
failed
|
||||||
end
|
end
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -406,6 +406,22 @@ module Hbase
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
define_test 'enable and disable tables by regex' do
|
||||||
|
@t1 = 't1'
|
||||||
|
@t2 = 't11'
|
||||||
|
@regex = 't1.*'
|
||||||
|
command(:create, @t1, 'f')
|
||||||
|
command(:create, @t2, 'f')
|
||||||
|
admin.disable_all(@regex)
|
||||||
|
assert(command(:is_disabled, @t1))
|
||||||
|
assert(command(:is_disabled, @t2))
|
||||||
|
admin.enable_all(@regex)
|
||||||
|
assert(command(:is_enabled, @t1))
|
||||||
|
assert(command(:is_enabled, @t2))
|
||||||
|
end
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
|
||||||
define_test "list_regions should fail for disabled table" do
|
define_test "list_regions should fail for disabled table" do
|
||||||
drop_test_table(@create_test_name)
|
drop_test_table(@create_test_name)
|
||||||
admin.create(@create_test_name, 'a')
|
admin.create(@create_test_name, 'a')
|
||||||
|
|
Loading…
Reference in New Issue