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

[hbase] branch branch-2.2 updated: HBASE-23140 Remove unknown table error (#706)

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

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


The following commit(s) were added to refs/heads/branch-2.2 by this push:
     new a342590  HBASE-23140 Remove unknown table error (#706)
a342590 is described below

commit a34259082fbf90aed38b8710f780e20f9f55311a
Author: Karthik Palanisamy <kp...@hortonworks.com>
AuthorDate: Wed Oct 9 01:00:56 2019 -0700

    HBASE-23140 Remove unknown table error (#706)
    
    Signed-off-by: huzheng <op...@gmail.com>
---
 hbase-shell/src/main/ruby/hbase/quotas.rb                  |  1 +
 .../src/main/ruby/shell/commands/describe_namespace.rb     | 14 ++++++++------
 hbase-shell/src/test/ruby/hbase/admin_test.rb              | 11 +++++++++++
 3 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/hbase-shell/src/main/ruby/hbase/quotas.rb b/hbase-shell/src/main/ruby/hbase/quotas.rb
index 9243877..62a2d02 100644
--- a/hbase-shell/src/main/ruby/hbase/quotas.rb
+++ b/hbase-shell/src/main/ruby/hbase/quotas.rb
@@ -30,6 +30,7 @@ java_import org.apache.hadoop.hbase.quotas.QuotaTableUtil
 java_import org.apache.hadoop.hbase.quotas.SpaceViolationPolicy
 
 module HBaseQuotasConstants
+  QUOTA_TABLE_NAME = QuotaTableUtil::QUOTA_TABLE_NAME
   # RPC Quota constants
   GLOBAL_BYPASS = 'GLOBAL_BYPASS'.freeze
   THROTTLE_TYPE = 'THROTTLE_TYPE'.freeze
diff --git a/hbase-shell/src/main/ruby/shell/commands/describe_namespace.rb b/hbase-shell/src/main/ruby/shell/commands/describe_namespace.rb
index 4252ad6..fd14c45 100644
--- a/hbase-shell/src/main/ruby/shell/commands/describe_namespace.rb
+++ b/hbase-shell/src/main/ruby/shell/commands/describe_namespace.rb
@@ -33,14 +33,16 @@ EOF
 
         formatter.header(['DESCRIPTION'], [64])
         formatter.row([desc], true, [64])
-
-        puts
-        formatter.header(%w[QUOTAS])
         ns = namespace.to_s
-        count = quotas_admin.list_quotas(NAMESPACE => ns) do |_, quota|
-          formatter.row([quota])
+        if admin.exists?(::HBaseQuotasConstants::QUOTA_TABLE_NAME.to_s)
+          puts formatter.header(%w[QUOTAS])
+          count = quotas_admin.list_quotas(NAMESPACE => ns) do |_, quota|
+            formatter.row([quota])
+          end
+          formatter.footer(count)
+        else
+          puts 'Quota is disabled'
         end
-        formatter.footer(count)
       end
       # rubocop:enable Metrics/AbcSize
     end
diff --git a/hbase-shell/src/test/ruby/hbase/admin_test.rb b/hbase-shell/src/test/ruby/hbase/admin_test.rb
index ade39fe..2eaf2ba 100644
--- a/hbase-shell/src/test/ruby/hbase/admin_test.rb
+++ b/hbase-shell/src/test/ruby/hbase/admin_test.rb
@@ -341,6 +341,17 @@ module Hbase
       assert(output.include?('0 row(s)'))
     end
 
+    define_test 'describe_namespace should return quota disabled' do
+      ns = 'ns'
+      quota_table = ::HBaseQuotasConstants::QUOTA_TABLE_NAME.to_s
+      drop_test_table(quota_table)
+      command(:create_namespace, ns)
+      output = capture_stdout { command(:describe_namespace, ns) }
+      # re-creating quota table otherwise other test case may fail
+      command(:create, quota_table, 'q', 'u')
+      assert(output.include?('Quota is disabled'))
+    end
+
     #-------------------------------------------------------------------------------
 
     define_test "truncate should empty a table" do