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 @@ -308,8 +308,17 @@ def enable(table_name)
308308 #----------------------------------------------------------------------------------------------
309309 # Enables all tables matching the given regex
310310 def enable_all ( regex )
311- regex = regex . to_s
312- @admin . enableTables ( Pattern . compile ( regex ) )
311+ pattern = Pattern . compile ( regex . to_s )
312+ failed = java . util . ArrayList . new
313+ @admin . listTableNames ( pattern ) . each do |table_name |
314+ begin
315+ @admin . enableTable ( table_name )
316+ rescue java . io . IOException => e
317+ puts "table:#{ table_name } , error:#{ e . toString } "
318+ failed . add ( table_name )
319+ end
320+ end
321+ failed
313322 end
314323
315324 #----------------------------------------------------------------------------------------------
@@ -324,7 +333,16 @@ def disable(table_name)
324333 # Disables all tables matching the given regex
325334 def disable_all ( regex )
326335 pattern = Pattern . compile ( regex . to_s )
327- @admin . disableTables ( pattern ) . map { |t | t . getTableName . getNameAsString }
336+ failed = java . util . ArrayList . new
337+ @admin . listTableNames ( pattern ) . each do |table_name |
338+ begin
339+ @admin . disableTable ( table_name )
340+ rescue java . io . IOException => e
341+ puts "table:#{ table_name } , error:#{ e . toString } "
342+ failed . add ( table_name )
343+ end
344+ end
345+ failed
328346 end
329347
330348 #---------------------------------------------------------------------------------------------
Original file line number Diff line number Diff line change @@ -406,6 +406,22 @@ def teardown
406406
407407 #-------------------------------------------------------------------------------
408408
409+ define_test 'enable and disable tables by regex' do
410+ @t1 = 't1'
411+ @t2 = 't11'
412+ @regex = 't1.*'
413+ command ( :create , @t1 , 'f' )
414+ command ( :create , @t2 , 'f' )
415+ admin . disable_all ( @regex )
416+ assert ( command ( :is_disabled , @t1 ) )
417+ assert ( command ( :is_disabled , @t2 ) )
418+ admin . enable_all ( @regex )
419+ assert ( command ( :is_enabled , @t1 ) )
420+ assert ( command ( :is_enabled , @t2 ) )
421+ end
422+
423+ #-------------------------------------------------------------------------------
424+
409425 define_test "list_regions should fail for disabled table" do
410426 drop_test_table ( @create_test_name )
411427 admin . create ( @create_test_name , 'a' )
You can’t perform that action at this time.
0 commit comments