HBASE-21689: Make table/namespace specific current quota info available in shell(describe_namespace & describe)
Signed-off-by: Guanghao Zhang <zghao@apache.org>
This commit is contained in:
parent
281558a3ab
commit
006f05b458
|
@ -32,6 +32,7 @@ Alternatively, you can use the abbreviated 'desc' for the same thing.
|
|||
EOF
|
||||
end
|
||||
|
||||
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
||||
def command(table)
|
||||
column_families = admin.get_column_families(table)
|
||||
|
||||
|
@ -40,9 +41,17 @@ 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.to_s) do |_, quota|
|
||||
formatter.row([quota])
|
||||
end
|
||||
formatter.footer(count)
|
||||
end
|
||||
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -27,12 +27,22 @@ Describe the named namespace. For example:
|
|||
EOF
|
||||
end
|
||||
|
||||
# rubocop:disable Metrics/AbcSize
|
||||
def command(namespace)
|
||||
desc = admin.describe_namespace(namespace)
|
||||
|
||||
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])
|
||||
end
|
||||
formatter.footer(count)
|
||||
end
|
||||
# rubocop:enable Metrics/AbcSize
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -60,6 +60,7 @@ module Hbase
|
|||
end
|
||||
|
||||
# Simple administration methods tests
|
||||
# rubocop:disable Metrics/ClassLength
|
||||
class AdminMethodsTest < Test::Unit::TestCase
|
||||
include TestHelpers
|
||||
|
||||
|
@ -267,8 +268,61 @@ 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 and quotas' do
|
||||
drop_test_table(@create_test_name)
|
||||
command(:create, @create_test_name, 'cf1', '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 and quotas' do
|
||||
ns = @create_test_name
|
||||
command(:create_namespace, ns)
|
||||
command(:set_quota,
|
||||
TYPE => SPACE,
|
||||
LIMIT => '1G',
|
||||
POLICY => NO_INSERTS,
|
||||
NAMESPACE => ns)
|
||||
output = capture_stdout { command(:describe_namespace, ns) }
|
||||
|
||||
assert(output.include?('DESCRIPTION'))
|
||||
assert(output.include?("NAME => '#{ns}'"))
|
||||
|
||||
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 => ns)
|
||||
output = capture_stdout { command(:describe_namespace, ns) }
|
||||
assert(output.include?('0 row(s)'))
|
||||
end
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
@ -332,6 +386,7 @@ module Hbase
|
|||
end
|
||||
end
|
||||
end
|
||||
# rubocop:enable Metrics/ClassLength
|
||||
|
||||
# Simple administration methods tests
|
||||
class AdminCloneTableSchemaTest < Test::Unit::TestCase
|
||||
|
|
Loading…
Reference in New Issue