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 12:58:29 UTC
[hbase] branch branch-2 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
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2 by this push:
new 928bd78 HBASE-23138 Drop_all table by regex fail (#704)
928bd78 is described below
commit 928bd78ece9430b60b26c95d5ee5af8ea5c1c3f2
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 766b43e..de6ccb4 100644
--- a/hbase-shell/src/main/ruby/hbase/admin.rb
+++ b/hbase-shell/src/main/ruby/hbase/admin.rb
@@ -372,7 +372,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 66a17e8..24a42da 100644
--- a/hbase-shell/src/test/ruby/hbase/admin_test.rb
+++ b/hbase-shell/src/test/ruby/hbase/admin_test.rb
@@ -429,6 +429,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
#-------------------------------------------------------------------------------