HBASE-18412 [Shell] Support unset of list of configuration for a table (Yun Zhao)

This commit is contained in:
tedyu 2017-07-20 21:01:05 -07:00
parent bdc94b1d6b
commit af534acabb
3 changed files with 51 additions and 0 deletions

View File

@ -657,6 +657,23 @@ module Hbase
htd.remove(name)
end
hasTableUpdate = true
# Unset table configuration
elsif method == 'table_conf_unset'
raise(ArgumentError, 'NAME parameter missing for table_conf_unset method') unless name
if name.is_a?(Array)
name.each do |key|
if htd.getConfigurationValue(key).nil?
raise ArgumentError, "Could not find configuration: #{key}"
end
htd.removeConfiguration(key)
end
else
if htd.getConfigurationValue(name).nil?
raise ArgumentError, "Could not find configuration: #{name}"
end
htd.removeConfiguration(name)
end
hasTableUpdate = true
# Unknown method
else
raise ArgumentError, "Unknown method: #{method}"

View File

@ -71,6 +71,10 @@ You can also set configuration settings specific to this table or column family:
hbase> alter 't1', CONFIGURATION => {'hbase.hregion.scan.loadColumnFamiliesOnDemand' => 'true'}
hbase> alter 't1', {NAME => 'f2', CONFIGURATION => {'hbase.hstore.blockingStoreFiles' => '10'}}
You can also unset configuration settings specific to this table:
hbase> alter 't1', METHOD => 'table_conf_unset', NAME => 'hbase.hregion.majorcompaction'
You can also remove a table-scope attribute:
hbase> alter 't1', METHOD => 'table_att_unset', NAME => 'MAX_FILESIZE'

View File

@ -480,6 +480,36 @@ module Hbase
assert_no_match(eval("/" + key_2 + "/"), admin.describe(@test_name))
end
define_test "alter should be able to remove a table configuration" do
drop_test_table(@test_name)
create_test_table(@test_name)
key = "TestConf"
command(:alter, @test_name, CONFIGURATION => {key => 1})
# eval() is used to convert a string to regex
assert_match(eval("/" + key + "/"), admin.describe(@test_name))
command(:alter, @test_name, 'METHOD' => 'table_conf_unset', 'NAME' => key)
assert_no_match(eval("/" + key + "/"), admin.describe(@test_name))
end
define_test "alter should be able to remove a list of table configuration" do
drop_test_table(@test_name)
key_1 = "TestConf1"
key_2 = "TestConf2"
command(:create, @test_name, { NAME => 'i'}, CONFIGURATION => { key_1 => 1, key_2 => 2 })
# eval() is used to convert a string to regex
assert_match(eval("/" + key_1 + "/"), admin.describe(@test_name))
assert_match(eval("/" + key_2 + "/"), admin.describe(@test_name))
command(:alter, @test_name, 'METHOD' => 'table_conf_unset', 'NAME' => [ key_1, key_2 ])
assert_no_match(eval("/" + key_1 + "/"), admin.describe(@test_name))
assert_no_match(eval("/" + key_2 + "/"), admin.describe(@test_name))
end
define_test "get_table should get a real table" do
drop_test_table(@test_name)
create_test_table(@test_name)