Skip to content

Commit e911bb7

Browse files
Karthik PalanisamyApache9
authored andcommitted
HBASE-23134 Enable_all and Disable_all table by Regex fail from Shell (#698)
Signed-off-by: Duo Zhang <zhangduo@apache.org>
1 parent ff52994 commit e911bb7

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

hbase-shell/src/main/ruby/hbase/admin.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -327,15 +327,15 @@ def enable(table_name)
327327
def enable_all(regex)
328328
pattern = Pattern.compile(regex.to_s)
329329
failed = java.util.ArrayList.new
330-
admin.listTableNames(pattern).each do |table_name|
330+
@admin.listTableNames(pattern).each do |table_name|
331331
begin
332-
admin.enableTable(table_name)
332+
@admin.enableTable(table_name)
333333
rescue java.io.IOException => e
334334
puts "table:#{table_name}, error:#{e.toString}"
335335
failed.add(table_name)
336336
end
337337
end
338-
@failed
338+
failed
339339
end
340340

341341
#----------------------------------------------------------------------------------------------
@@ -351,15 +351,15 @@ def disable(table_name)
351351
def disable_all(regex)
352352
pattern = Pattern.compile(regex.to_s)
353353
failed = java.util.ArrayList.new
354-
admin.listTableNames(pattern).each do |table_name|
354+
@admin.listTableNames(pattern).each do |table_name|
355355
begin
356-
admin.disableTable(table_name)
356+
@admin.disableTable(table_name)
357357
rescue java.io.IOException => e
358358
puts "table:#{table_name}, error:#{e.toString}"
359359
failed.add(table_name)
360360
end
361361
end
362-
@failed
362+
failed
363363
end
364364

365365
#---------------------------------------------------------------------------------------------

hbase-shell/src/test/ruby/hbase/admin_test.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,22 @@ def teardown
418418

419419
#-------------------------------------------------------------------------------
420420

421+
define_test 'enable and disable tables by regex' do
422+
@t1 = 't1'
423+
@t2 = 't11'
424+
@regex = 't1.*'
425+
command(:create, @t1, 'f')
426+
command(:create, @t2, 'f')
427+
admin.disable_all(@regex)
428+
assert(command(:is_disabled, @t1))
429+
assert(command(:is_disabled, @t2))
430+
admin.enable_all(@regex)
431+
assert(command(:is_enabled, @t1))
432+
assert(command(:is_enabled, @t2))
433+
end
434+
435+
#-------------------------------------------------------------------------------
436+
421437
define_test "list_regions should fail for disabled table" do
422438
drop_test_table(@create_test_name)
423439
admin.create(@create_test_name, 'a')

0 commit comments

Comments
 (0)