From 2e078005f9cc8ea315f457b08669768cc276491f Mon Sep 17 00:00:00 2001 From: Sakthi Date: Sun, 20 Jan 2019 18:55:21 -0800 Subject: [PATCH] HBASE-21689: Make table/namespace specific current quota info available in shell(describe_namespace & describe) --- .../src/main/ruby/shell/commands/describe.rb | 7 ++++ .../ruby/shell/commands/describe_namespace.rb | 7 ++++ hbase-shell/src/test/ruby/hbase/admin_test.rb | 42 ++++++++++++++++++- 3 files changed, 54 insertions(+), 2 deletions(-) diff --git a/hbase-shell/src/main/ruby/shell/commands/describe.rb b/hbase-shell/src/main/ruby/shell/commands/describe.rb index 3268b2f7228abb4cfae6fced2298234f313b228d..eadcb5fd760ad1c1d174c149d8ef600367333ac8 100644 --- a/hbase-shell/src/main/ruby/shell/commands/describe.rb +++ b/hbase-shell/src/main/ruby/shell/commands/describe.rb @@ -40,8 +40,15 @@ EOF formatter.header(['COLUMN FAMILIES DESCRIPTION']) column_families.each do |column_family| formatter.row([column_family.to_s], true) + puts end formatter.footer + puts + formatter.header(%w[QUOTAS]) + count = quotas_admin.list_quotas({TABLE => "#{table}"}) do |row, cells| + formatter.row([cells]) + end + formatter.footer(count) end end end 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 55261d6bdc23737c12261fcb99183a932bf0147e..6d6b183469eed93c24741fe0ee84b5b91563b682 100644 --- a/hbase-shell/src/main/ruby/shell/commands/describe_namespace.rb +++ b/hbase-shell/src/main/ruby/shell/commands/describe_namespace.rb @@ -32,6 +32,13 @@ EOF formatter.header(['DESCRIPTION'], [64]) formatter.row([desc], true, [64]) + + puts + formatter.header(%w[QUOTAS]) + count = quotas_admin.list_quotas({NAMESPACE => "#{namespace}"}) do |row, cells| + formatter.row([cells]) + end + formatter.footer(count) end end end diff --git a/hbase-shell/src/test/ruby/hbase/admin_test.rb b/hbase-shell/src/test/ruby/hbase/admin_test.rb index 9fafea4afcc9413e869f19521ad393a2c17d9bfd..76dea9eaa83121d2c69fb50f50d5db5308d85e78 100644 --- a/hbase-shell/src/test/ruby/hbase/admin_test.rb +++ b/hbase-shell/src/test/ruby/hbase/admin_test.rb @@ -267,8 +267,46 @@ module Hbase end end - define_test "describe should return a description" do - assert_not_nil admin.describe(@test_name) + define_test "describe should return a description along with quotas" do + drop_test_table(@create_test_name) + command(:create, @create_test_name, {NAME => 'cf1'}, {NAME => 'cf2'}) + command(:set_quota, TYPE => SPACE, LIMIT => '1G', POLICY => NO_INSERTS, TABLE => @create_test_name) + output = capture_stdout{ command(:describe, @create_test_name) } + + assert(output.include?("Table #{@create_test_name} is ENABLED")) + assert(output.include?("COLUMN FAMILIES DESCRIPTION")) + assert(output.include?("NAME => 'cf1'")) + assert(output.include?("NAME => 'cf2'")) + assert(output.include?("2 row(s)")) + + assert(output.include?("QUOTAS")) + assert(output.include?("LIMIT => 1G")) + assert(output.include?("VIOLATION_POLICY => NO_INSERTS")) + assert(output.include?("TYPE => SPACE")) + assert(output.include?("1 row(s)")) + + command(:set_quota, TYPE => SPACE, LIMIT => NONE, TABLE => @create_test_name) + output = capture_stdout{ command(:describe, @create_test_name) } + assert(output.include?("0 row(s)")) + end + + define_test "describe_namespace should return a description along with quotas" do + command(:create_namespace, @create_test_name) + command(:set_quota, TYPE => SPACE, LIMIT => '1G', POLICY => NO_INSERTS, NAMESPACE => @create_test_name) + output = capture_stdout{ command(:describe_namespace, @create_test_name) } + + assert(output.include?("DESCRIPTION")) + assert(output.include?("NAME => '#{@create_test_name}'")) + + assert(output.include?("QUOTAS")) + assert(output.include?("LIMIT => 1G")) + assert(output.include?("VIOLATION_POLICY => NO_INSERTS")) + assert(output.include?("TYPE => SPACE")) + assert(output.include?("1 row(s)")) + + command(:set_quota, TYPE => SPACE, LIMIT => NONE, NAMESPACE => @create_test_name) + output = capture_stdout{ command(:describe_namespace, @create_test_name) } + assert(output.include?("0 row(s)")) end #------------------------------------------------------------------------------- -- 2.17.2 (Apple Git-113)