File tree Expand file tree Collapse file tree 2 files changed +37
-3
lines changed Expand file tree Collapse file tree 2 files changed +37
-3
lines changed Original file line number Diff line number Diff line change @@ -309,8 +309,17 @@ def enable(table_name)
309309 #----------------------------------------------------------------------------------------------
310310 # Enables all tables matching the given regex
311311 def enable_all ( regex )
312- regex = regex . to_s
313- @admin . enableTables ( Pattern . compile ( regex ) )
312+ pattern = Pattern . compile ( regex . to_s )
313+ failed = java . util . ArrayList . new
314+ @admin . listTableNames ( pattern ) . each do |table_name |
315+ begin
316+ @admin . enableTable ( table_name )
317+ rescue java . io . IOException => e
318+ puts "table:#{ table_name } , error:#{ e . toString } "
319+ failed . add ( table_name )
320+ end
321+ end
322+ failed
314323 end
315324
316325 #----------------------------------------------------------------------------------------------
@@ -325,7 +334,16 @@ def disable(table_name)
325334 # Disables all tables matching the given regex
326335 def disable_all ( regex )
327336 pattern = Pattern . compile ( regex . to_s )
328- @admin . disableTables ( pattern ) . map { |t | t . getTableName . getNameAsString }
337+ failed = java . util . ArrayList . new
338+ @admin . listTableNames ( pattern ) . each do |table_name |
339+ begin
340+ @admin . disableTable ( table_name )
341+ rescue java . io . IOException => e
342+ puts "table:#{ table_name } , error:#{ e . toString } "
343+ failed . add ( table_name )
344+ end
345+ end
346+ failed
329347 end
330348
331349 #---------------------------------------------------------------------------------------------
Original file line number Diff line number Diff line change @@ -440,6 +440,22 @@ def teardown
440440
441441 #-------------------------------------------------------------------------------
442442
443+ define_test 'enable and disable tables by regex' do
444+ @t1 = 't1'
445+ @t2 = 't11'
446+ @regex = 't1.*'
447+ command ( :create , @t1 , 'f' )
448+ command ( :create , @t2 , 'f' )
449+ admin . disable_all ( @regex )
450+ assert ( command ( :is_disabled , @t1 ) )
451+ assert ( command ( :is_disabled , @t2 ) )
452+ admin . enable_all ( @regex )
453+ assert ( command ( :is_enabled , @t1 ) )
454+ assert ( command ( :is_enabled , @t2 ) )
455+ end
456+
457+ #-------------------------------------------------------------------------------
458+
443459 define_test "list_regions should fail for disabled table" do
444460 drop_test_table ( @create_test_name )
445461 admin . create ( @create_test_name , 'a' )
You can’t perform that action at this time.
0 commit comments