You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by wc...@apache.org on 2019/10/09 13:01:24 UTC

[hbase] branch branch-2.1 updated: HBASE-23138 Drop_all table by regex fail (#704)

This is an automated email from the ASF dual-hosted git repository.

wchevreuil pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-2.1 by this push:
     new af6e777  HBASE-23138 Drop_all table by regex fail (#704)
af6e777 is described below

commit af6e777f36c150a1b1b9ee6d4c539819fa977bef
Author: Karthik Palanisamy <kp...@hortonworks.com>
AuthorDate: Wed Oct 9 03:50:19 2019 -0700

    HBASE-23138 Drop_all table by regex fail (#704)
    
    Signed-off-by: Wellington Chevreuil <wc...@apache.org>
    (cherry picked from commit d237106ae698d3632b9f26f1ea2f1b4fa41811c3)
---
 hbase-shell/src/main/ruby/hbase/admin.rb      | 10 +++++++++-
 hbase-shell/src/test/ruby/hbase/admin_test.rb |  4 ++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/hbase-shell/src/main/ruby/hbase/admin.rb b/hbase-shell/src/main/ruby/hbase/admin.rb
index b98cce0..8709b23 100644
--- a/hbase-shell/src/main/ruby/hbase/admin.rb
+++ b/hbase-shell/src/main/ruby/hbase/admin.rb
@@ -359,7 +359,15 @@ module Hbase
     # Drops a table
     def drop_all(regex)
       pattern = Pattern.compile(regex.to_s)
-      failed = @admin.deleteTables(pattern).map { |t| t.getTableName.getNameAsString }
+      failed = java.util.ArrayList.new
+      @admin.listTableNames(pattern).each do |table_name|
+        begin
+          @admin.deleteTable(table_name)
+        rescue java.io.IOException => e
+          puts puts "table:#{table_name}, error:#{e.toString}"
+          failed.add(table_name)
+        end
+      end
       failed
     end
 
diff --git a/hbase-shell/src/test/ruby/hbase/admin_test.rb b/hbase-shell/src/test/ruby/hbase/admin_test.rb
index da73158..35a8a5e 100644
--- a/hbase-shell/src/test/ruby/hbase/admin_test.rb
+++ b/hbase-shell/src/test/ruby/hbase/admin_test.rb
@@ -345,6 +345,10 @@ module Hbase
       admin.enable_all(@regex)
       assert(command(:is_enabled, @t1))
       assert(command(:is_enabled, @t2))
+      admin.disable_all(@regex)
+      admin.drop_all(@regex)
+      assert(!command(:exists, @t1))
+      assert(!command(:exists, @t2))
     end
 
     #-------------------------------------------------------------------------------