hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bus...@apache.org
Subject [01/47] hbase git commit: HBASE-18412 [Shell] Support unset of list of configuration for a table (Yun Zhao) [Forced Update!]
Date Sat, 29 Jul 2017 23:51:39 GMT
Repository: hbase
Updated Branches:
  refs/heads/HBASE-18426 ceb6b96bd -> d5c00c9c6 (forced update)
  refs/heads/branch-1.1-HBASE-18426 [created] 2c362a104
  refs/heads/branch-1.2-HBASE-18426 5f1f9dea4 -> 67a2a4397 (forced update)


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


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/af534aca
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/af534aca
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/af534aca

Branch: refs/heads/HBASE-18426
Commit: af534acabb3e0d03e804ff409a09f3b77e17e779
Parents: bdc94b1
Author: tedyu <yuzhihong@gmail.com>
Authored: Thu Jul 20 21:01:05 2017 -0700
Committer: tedyu <yuzhihong@gmail.com>
Committed: Thu Jul 20 21:01:05 2017 -0700

----------------------------------------------------------------------
 hbase-shell/src/main/ruby/hbase/admin.rb        | 17 +++++++++++
 .../src/main/ruby/shell/commands/alter.rb       |  4 +++
 hbase-shell/src/test/ruby/hbase/admin_test.rb   | 30 ++++++++++++++++++++
 3 files changed, 51 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/af534aca/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 5eee26c..460ede3 100644
--- a/hbase-shell/src/main/ruby/hbase/admin.rb
+++ b/hbase-shell/src/main/ruby/hbase/admin.rb
@@ -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}"

http://git-wip-us.apache.org/repos/asf/hbase/blob/af534aca/hbase-shell/src/main/ruby/shell/commands/alter.rb
----------------------------------------------------------------------
diff --git a/hbase-shell/src/main/ruby/shell/commands/alter.rb b/hbase-shell/src/main/ruby/shell/commands/alter.rb
index 2207111..4aef28c 100644
--- a/hbase-shell/src/main/ruby/shell/commands/alter.rb
+++ b/hbase-shell/src/main/ruby/shell/commands/alter.rb
@@ -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'

http://git-wip-us.apache.org/repos/asf/hbase/blob/af534aca/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 2a20d34..025b737 100644
--- a/hbase-shell/src/test/ruby/hbase/admin_test.rb
+++ b/hbase-shell/src/test/ruby/hbase/admin_test.rb
@@ -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)


Mime
View raw message