This is an automated email from the ASF dual-hosted git repository.

ndimiduk pushed a commit to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-2 by this push:
     new 78fe9ca  HBASE-25651 NORMALIZER_TARGET_REGION_SIZE needs a unit in its 
name (#3450)
78fe9ca is described below

commit 78fe9caa5cc41a6c6e9315aa4365daefd27f6716
Author: Rahul Kumar <[email protected]>
AuthorDate: Wed Aug 4 20:51:43 2021 +0530

    HBASE-25651 NORMALIZER_TARGET_REGION_SIZE needs a unit in its name (#3450)
    
    Signed-off-by: Nick Dimiduk <[email protected]>
    Signed-off-by: Baiqiang Zhao <ZhaoBQ>
---
 .../java/org/apache/hadoop/hbase/HTableDescriptor.java     |  2 ++
 .../apache/hadoop/hbase/client/TableDescriptorBuilder.java | 14 ++++++++++++--
 hbase-shell/src/main/ruby/hbase/admin.rb                   |  8 +++++++-
 hbase-shell/src/main/ruby/shell/commands/alter.rb          |  2 +-
 hbase-shell/src/test/ruby/hbase/admin_test.rb              |  7 +++++++
 5 files changed, 29 insertions(+), 4 deletions(-)

diff --git 
a/hbase-client/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java 
b/hbase-client/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java
index 6bb9091..8f9e77a 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java
@@ -72,6 +72,8 @@ public class HTableDescriptor implements TableDescriptor, 
Comparable<HTableDescr
       TableDescriptorBuilder.NORMALIZER_TARGET_REGION_COUNT;
   public static final String NORMALIZER_TARGET_REGION_SIZE =
       TableDescriptorBuilder.NORMALIZER_TARGET_REGION_SIZE;
+  public static final String NORMALIZER_TARGET_REGION_SIZE_MB =
+      TableDescriptorBuilder.NORMALIZER_TARGET_REGION_SIZE_MB;
   public static final String PRIORITY = TableDescriptorBuilder.PRIORITY;
   public static final boolean DEFAULT_READONLY = 
TableDescriptorBuilder.DEFAULT_READONLY;
   public static final boolean DEFAULT_COMPACTION_ENABLED = 
TableDescriptorBuilder.DEFAULT_COMPACTION_ENABLED;
diff --git 
a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/TableDescriptorBuilder.java
 
b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/TableDescriptorBuilder.java
index 092583a..01d2753 100644
--- 
a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/TableDescriptorBuilder.java
+++ 
b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/TableDescriptorBuilder.java
@@ -178,7 +178,14 @@ public class TableDescriptorBuilder {
       new Bytes(Bytes.toBytes(NORMALIZER_TARGET_REGION_COUNT));
 
   @InterfaceAudience.Private
+  public static final String NORMALIZER_TARGET_REGION_SIZE_MB = 
"NORMALIZER_TARGET_REGION_SIZE_MB";
+  private static final Bytes NORMALIZER_TARGET_REGION_SIZE_MB_KEY =
+      new Bytes(Bytes.toBytes(NORMALIZER_TARGET_REGION_SIZE_MB));
+  // TODO: Keeping backward compatability with HBASE-25651 change. Can be 
removed in later version
+  @InterfaceAudience.Private
+  @Deprecated
   public static final String NORMALIZER_TARGET_REGION_SIZE = 
"NORMALIZER_TARGET_REGION_SIZE";
+  @Deprecated
   private static final Bytes NORMALIZER_TARGET_REGION_SIZE_KEY =
       new Bytes(Bytes.toBytes(NORMALIZER_TARGET_REGION_SIZE));
 
@@ -916,7 +923,10 @@ public class TableDescriptorBuilder {
      */
     @Override
     public long getNormalizerTargetRegionSize() {
-      return getOrDefault(NORMALIZER_TARGET_REGION_SIZE_KEY, Long::valueOf, 
Long.valueOf(-1));
+      long target_region_size =
+        getOrDefault(NORMALIZER_TARGET_REGION_SIZE_MB_KEY, Long::valueOf, 
Long.valueOf(-1));
+      return target_region_size == Long.valueOf(-1) ? getOrDefault(
+        NORMALIZER_TARGET_REGION_SIZE_KEY, Long::valueOf, Long.valueOf(-1)) : 
target_region_size;
     }
 
     /**
@@ -944,7 +954,7 @@ public class TableDescriptorBuilder {
      * @return the modifyable TD
      */
     public ModifyableTableDescriptor setNormalizerTargetRegionSize(final long 
regionSize) {
-      return setValue(NORMALIZER_TARGET_REGION_SIZE_KEY, 
Long.toString(regionSize));
+      return setValue(NORMALIZER_TARGET_REGION_SIZE_MB_KEY, 
Long.toString(regionSize));
     }
 
     /**
diff --git a/hbase-shell/src/main/ruby/hbase/admin.rb 
b/hbase-shell/src/main/ruby/hbase/admin.rb
index 9997b38..f8ebe5e 100644
--- a/hbase-shell/src/main/ruby/hbase/admin.rb
+++ b/hbase-shell/src/main/ruby/hbase/admin.rb
@@ -1444,7 +1444,13 @@ module Hbase
       
htd.setMergeEnabled(JBoolean.valueOf(arg.delete(org.apache.hadoop.hbase.HTableDescriptor::MERGE_ENABLED)))
 if arg.include?(org.apache.hadoop.hbase.HTableDescriptor::MERGE_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.setNormalizerTargetRegionCount(JInteger.valueOf(arg.delete(org.apache.hadoop.hbase.HTableDescriptor::NORMALIZER_TARGET_REGION_COUNT)))
 if 
arg.include?(org.apache.hadoop.hbase.HTableDescriptor::NORMALIZER_TARGET_REGION_COUNT)
-      
htd.setNormalizerTargetRegionSize(JLong.valueOf(arg.delete(org.apache.hadoop.hbase.HTableDescriptor::NORMALIZER_TARGET_REGION_SIZE)))
 if 
arg.include?(org.apache.hadoop.hbase.HTableDescriptor::NORMALIZER_TARGET_REGION_SIZE)
+      # TODO: Keeping backward compatability for NORMALIZER_TARGET_REGION_SIZE 
with HBASE-25651 change. Can be removed in later version
+      if 
arg.include?(org.apache.hadoop.hbase.HTableDescriptor::NORMALIZER_TARGET_REGION_SIZE)
+        warn 'Use of NORMALIZER_TARGET_REGION_SIZE has been deprecated and 
will be removed in future version, please use NORMALIZER_TARGET_REGION_SIZE_MB 
instead'
+        
htd.setNormalizerTargetRegionSize(JLong.valueOf(arg.delete(org.apache.hadoop.hbase.HTableDescriptor::NORMALIZER_TARGET_REGION_SIZE)))
+      end
+      
htd.setNormalizerTargetRegionSize(JLong.valueOf(arg.delete(org.apache.hadoop.hbase.HTableDescriptor::NORMALIZER_TARGET_REGION_SIZE_MB)))
 \
+        if 
arg.include?(org.apache.hadoop.hbase.HTableDescriptor::NORMALIZER_TARGET_REGION_SIZE_MB)
       
htd.setMemStoreFlushSize(arg.delete(org.apache.hadoop.hbase.HTableDescriptor::MEMSTORE_FLUSHSIZE))
 if arg.include?(org.apache.hadoop.hbase.HTableDescriptor::MEMSTORE_FLUSHSIZE)
       
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)
diff --git a/hbase-shell/src/main/ruby/shell/commands/alter.rb 
b/hbase-shell/src/main/ruby/shell/commands/alter.rb
index e6872fb..93323be 100644
--- a/hbase-shell/src/main/ruby/shell/commands/alter.rb
+++ b/hbase-shell/src/main/ruby/shell/commands/alter.rb
@@ -48,7 +48,7 @@ To delete the 'f1' column family in table 'ns1:t1', use one 
of:
 
 You can also change table-scope attributes like MAX_FILESIZE, READONLY,
 MEMSTORE_FLUSHSIZE, NORMALIZATION_ENABLED, NORMALIZER_TARGET_REGION_COUNT,
-NORMALIZER_TARGET_REGION_SIZE(MB), DURABILITY, etc. These can be put at the 
end;
+NORMALIZER_TARGET_REGION_SIZE_MB, DURABILITY, etc. These can be put at the end;
 for example, to change the max size of a region to 128MB, do:
 
   hbase> alter 't1', MAX_FILESIZE => '134217728'
diff --git a/hbase-shell/src/test/ruby/hbase/admin_test.rb 
b/hbase-shell/src/test/ruby/hbase/admin_test.rb
index 534a9d7..19910ca 100644
--- a/hbase-shell/src/test/ruby/hbase/admin_test.rb
+++ b/hbase-shell/src/test/ruby/hbase/admin_test.rb
@@ -910,6 +910,13 @@ module Hbase
       assert_match(/12345678/, admin.describe(@test_name))
     end
 
+    define_test 'alter should be able to set the TargetRegionSizeMB and 
TargetRegionCount' do
+      command(:alter, @test_name, 'NORMALIZER_TARGET_REGION_COUNT' => 156)
+      assert_match(/156/, admin.describe(@test_name))
+      command(:alter, @test_name, 'NORMALIZER_TARGET_REGION_SIZE_MB' => 234)
+      assert_match(/234/, admin.describe(@test_name))
+    end
+
     define_test 'alter should be able to set the TargetRegionSize and 
TargetRegionCount' do
       command(:alter, @test_name, 'NORMALIZER_TARGET_REGION_COUNT' => 156)
       assert_match(/156/, admin.describe(@test_name))

Reply via email to