You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zh...@apache.org on 2018/04/08 09:35:48 UTC

[33/50] [abbrv] hbase git commit: HBASE-20287 After cluster startup list_regions command fails on disabled table

HBASE-20287 After cluster startup list_regions command fails on disabled table

Add is_enabled check for list_regions command

Signed-off-by: Mike Drob <md...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/bdc0d3a4
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/bdc0d3a4
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/bdc0d3a4

Branch: refs/heads/HBASE-19064
Commit: bdc0d3a4c612289af8e0472f4ae30b1c39c09c7f
Parents: adc0e85
Author: Peter Somogyi <ps...@apache.org>
Authored: Thu Apr 5 12:12:14 2018 +0200
Committer: Peter Somogyi <ps...@apache.org>
Committed: Sat Apr 7 18:11:29 2018 +0200

----------------------------------------------------------------------
 .../src/main/ruby/shell/commands/list_regions.rb        |  2 ++
 hbase-shell/src/test/ruby/hbase/admin_test.rb           | 12 ++++++++++++
 2 files changed, 14 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/bdc0d3a4/hbase-shell/src/main/ruby/shell/commands/list_regions.rb
----------------------------------------------------------------------
diff --git a/hbase-shell/src/main/ruby/shell/commands/list_regions.rb b/hbase-shell/src/main/ruby/shell/commands/list_regions.rb
index bcc0c4a..0ce569c 100644
--- a/hbase-shell/src/main/ruby/shell/commands/list_regions.rb
+++ b/hbase-shell/src/main/ruby/shell/commands/list_regions.rb
@@ -50,6 +50,8 @@ EOF
           options = { SERVER_NAME => options }
         end
 
+        raise "Table #{table_name} must be enabled." unless admin.enabled?(table_name)
+
         size_hash = {}
         if cols.nil?
           size_hash = { 'SERVER_NAME' => 12, 'REGION_NAME' => 12, 'START_KEY' => 10, 'END_KEY' => 10, 'SIZE' => 5, 'REQ' => 5, 'LOCALITY' => 10 }

http://git-wip-us.apache.org/repos/asf/hbase/blob/bdc0d3a4/hbase-shell/src/test/ruby/hbase/admin_test.rb
----------------------------------------------------------------------
diff --git a/hbase-shell/src/test/ruby/hbase/admin_test.rb b/hbase-shell/src/test/ruby/hbase/admin_test.rb
index 929484c..a27bbc5 100644
--- a/hbase-shell/src/test/ruby/hbase/admin_test.rb
+++ b/hbase-shell/src/test/ruby/hbase/admin_test.rb
@@ -319,6 +319,18 @@ module Hbase
       admin.truncate_preserve(@create_test_name, $TEST_CLUSTER.getConfiguration)
       assert_equal(splits, table(@create_test_name)._get_splits_internal())
     end
+
+    #-------------------------------------------------------------------------------
+
+    define_test "list_regions should fail for disabled table" do
+      drop_test_table(@create_test_name)
+      admin.create(@create_test_name, 'a')
+      command(:disable, @create_test_name)
+      assert(:is_disabled, @create_test_name)
+      assert_raise(RuntimeError) do
+        command(:list_regions, @create_test_name)
+      end
+    end
   end
 
   # Simple administration methods tests