Repository: hbase Updated Branches: refs/heads/branch-1 381c89b5c -> e94245331
HBASE-18149 The setting rules for table-scope attributes and family-scope attributes should keep consistent Signed-off-by: tedyu <yuzhih...@gmail.com> Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/e9424533 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/e9424533 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/e9424533 Branch: refs/heads/branch-1 Commit: e94245331eaccaee0a9b2d75c3e4c08586a8b16a Parents: 381c89b Author: Guangxu Cheng <guangxuch...@gmail.com> Authored: Wed Jun 7 15:16:21 2017 +0800 Committer: tedyu <yuzhih...@gmail.com> Committed: Wed Jun 7 08:32:27 2017 -0700 ---------------------------------------------------------------------- hbase-shell/src/main/ruby/hbase/admin.rb | 29 +++++++++++----------- hbase-shell/src/test/ruby/hbase/admin_test.rb | 8 ++++++ 2 files changed, 22 insertions(+), 15 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/e9424533/hbase-shell/src/main/ruby/hbase/admin.rb ---------------------------------------------------------------------- diff --git a/hbase-shell/src/main/ruby/hbase/admin.rb b/hbase-shell/src/main/ruby/hbase/admin.rb index c71d641..502abe2 100644 --- a/hbase-shell/src/main/ruby/hbase/admin.rb +++ b/hbase-shell/src/main/ruby/hbase/admin.rb @@ -1146,28 +1146,27 @@ module Hbase # Parse arguments and update HTableDescriptor accordingly def update_htd_from_arg(htd, arg) - htd.setOwnerString(arg.delete(OWNER)) if arg[OWNER] - htd.setMaxFileSize(JLong.valueOf(arg.delete(MAX_FILESIZE))) if arg[MAX_FILESIZE] - htd.setReadOnly(JBoolean.valueOf(arg.delete(READONLY))) if arg[READONLY] - htd.setCompactionEnabled(JBoolean.valueOf(arg.delete(COMPACTION_ENABLED))) if arg[COMPACTION_ENABLED] - htd.setNormalizationEnabled( - JBoolean.valueOf(arg.delete(NORMALIZATION_ENABLED))) if arg[NORMALIZATION_ENABLED] - htd.setMemStoreFlushSize(JLong.valueOf(arg.delete(MEMSTORE_FLUSHSIZE))) if arg[MEMSTORE_FLUSHSIZE] + htd.setOwnerString(arg.delete(org.apache.hadoop.hbase.HTableDescriptor::OWNER)) if arg.include?(org.apache.hadoop.hbase.HTableDescriptor::OWNER) + htd.setMaxFileSize(JLong.valueOf(arg.delete(org.apache.hadoop.hbase.HTableDescriptor::MAX_FILESIZE))) if arg.include?(org.apache.hadoop.hbase.HTableDescriptor::MAX_FILESIZE) + htd.setReadOnly(JBoolean.valueOf(arg.delete(org.apache.hadoop.hbase.HTableDescriptor::READONLY))) if arg.include?(org.apache.hadoop.hbase.HTableDescriptor::READONLY) + htd.setCompactionEnabled(JBoolean.valueOf(arg.delete(org.apache.hadoop.hbase.HTableDescriptor::COMPACTION_ENABLED))) if arg.include?(org.apache.hadoop.hbase.HTableDescriptor::COMPACTION_ENABLED) + htd.setNormalizationEnabled(JBoolean.valueOf(arg.delete(org.apache.hadoop.hbase.HTableDescriptor::NORMALIZATION_ENABLED))) if arg.include?(org.apache.hadoop.hbase.HTableDescriptor::NORMALIZATION_ENABLED) + htd.setMemStoreFlushSize(JLong.valueOf(arg.delete(org.apache.hadoop.hbase.HTableDescriptor::MEMSTORE_FLUSHSIZE))) if arg.include?(org.apache.hadoop.hbase.HTableDescriptor::MEMSTORE_FLUSHSIZE) # DEFERRED_LOG_FLUSH is deprecated and was replaced by DURABILITY. To keep backward compatible, it still exists. # However, it has to be set before DURABILITY so that DURABILITY could overwrite if both args are set - if arg.include?(DEFERRED_LOG_FLUSH) - if arg.delete(DEFERRED_LOG_FLUSH).to_s.upcase == "TRUE" + if arg.include?(org.apache.hadoop.hbase.HTableDescriptor::DEFERRED_LOG_FLUSH) + if arg.delete(org.apache.hadoop.hbase.HTableDescriptor::DEFERRED_LOG_FLUSH).to_s.upcase == "TRUE" htd.setDurability(org.apache.hadoop.hbase.client.Durability.valueOf("ASYNC_WAL")) else htd.setDurability(org.apache.hadoop.hbase.client.Durability.valueOf("SYNC_WAL")) end end - htd.setDurability(org.apache.hadoop.hbase.client.Durability.valueOf(arg.delete(DURABILITY))) if arg[DURABILITY] - htd.setPriority(JInteger.valueOf(arg.delete(org.apache.hadoop.hbase.HTableDescriptor::PRIORITY))) if arg[org.apache.hadoop.hbase.HTableDescriptor::PRIORITY] - htd.setFlushPolicyClassName(arg.delete(org.apache.hadoop.hbase.HTableDescriptor::FLUSH_POLICY)) if arg[org.apache.hadoop.hbase.HTableDescriptor::FLUSH_POLICY] - htd.setRegionMemstoreReplication(JBoolean.valueOf(arg.delete(org.apache.hadoop.hbase.HTableDescriptor::REGION_MEMSTORE_REPLICATION))) if arg[org.apache.hadoop.hbase.HTableDescriptor::REGION_MEMSTORE_REPLICATION] - htd.setRegionSplitPolicyClassName(arg.delete(org.apache.hadoop.hbase.HTableDescriptor::SPLIT_POLICY)) if arg[org.apache.hadoop.hbase.HTableDescriptor::SPLIT_POLICY] - htd.setRegionReplication(JInteger.valueOf(arg.delete(REGION_REPLICATION))) if arg[REGION_REPLICATION] + htd.setDurability(org.apache.hadoop.hbase.client.Durability.valueOf(arg.delete(org.apache.hadoop.hbase.HTableDescriptor::DURABILITY))) if arg.include?(org.apache.hadoop.hbase.HTableDescriptor::DURABILITY) + htd.setPriority(JInteger.valueOf(arg.delete(org.apache.hadoop.hbase.HTableDescriptor::PRIORITY))) if arg.include?(org.apache.hadoop.hbase.HTableDescriptor::PRIORITY) + htd.setFlushPolicyClassName(arg.delete(org.apache.hadoop.hbase.HTableDescriptor::FLUSH_POLICY)) if arg.include?(org.apache.hadoop.hbase.HTableDescriptor::FLUSH_POLICY) + htd.setRegionMemstoreReplication(JBoolean.valueOf(arg.delete(org.apache.hadoop.hbase.HTableDescriptor::REGION_MEMSTORE_REPLICATION))) if arg.include?(org.apache.hadoop.hbase.HTableDescriptor::REGION_MEMSTORE_REPLICATION) + htd.setRegionSplitPolicyClassName(arg.delete(org.apache.hadoop.hbase.HTableDescriptor::SPLIT_POLICY)) if arg.include?(org.apache.hadoop.hbase.HTableDescriptor::SPLIT_POLICY) + htd.setRegionReplication(JInteger.valueOf(arg.delete(org.apache.hadoop.hbase.HTableDescriptor::REGION_REPLICATION))) if arg.include?(org.apache.hadoop.hbase.HTableDescriptor::REGION_REPLICATION) set_user_metadata(htd, arg.delete(METADATA)) if arg[METADATA] set_descriptor_config(htd, arg.delete(CONFIGURATION)) if arg[CONFIGURATION] end http://git-wip-us.apache.org/repos/asf/hbase/blob/e9424533/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 172aad3..15d585a 100644 --- a/hbase-shell/src/test/ruby/hbase/admin_test.rb +++ b/hbase-shell/src/test/ruby/hbase/admin_test.rb @@ -240,6 +240,14 @@ module Hbase assert_equal(['a:', 'b:'], table(@create_test_name).get_all_columns.sort) end + define_test "create should work when attributes value 'false' is not enclosed in single quotation marks" do + drop_test_table(@create_test_name) + admin.create(@create_test_name,{NAME => 'a', BLOCKCACHE => false}, {COMPACTION_ENABLED => false}) + assert_equal(['a:'], table(@create_test_name).get_all_columns.sort) + assert_match(/BLOCKCACHE/, admin.describe(@create_test_name)) + assert_match(/COMPACTION_ENABLED/, admin.describe(@create_test_name)) + end + #------------------------------------------------------------------------------- define_test "describe should fail for non-existent tables" do