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 1c1cbaa8723d..d306fdc55210 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 @@ -172,7 +172,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)); @@ -884,7 +891,10 @@ public int getNormalizerTargetRegionCount() { */ @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; } /** @@ -912,7 +922,7 @@ public ModifyableTableDescriptor setNormalizerTargetRegionCount(final int region * @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 a546605c621c..d76ab22872f9 100644 --- a/hbase-shell/src/main/ruby/hbase/admin.rb +++ b/hbase-shell/src/main/ruby/hbase/admin.rb @@ -1492,7 +1492,13 @@ def update_tdb_from_arg(tdb, arg) tdb.setMergeEnabled(JBoolean.valueOf(arg.delete(TableDescriptorBuilder::MERGE_ENABLED))) if arg.include?(TableDescriptorBuilder::MERGE_ENABLED) tdb.setNormalizationEnabled(JBoolean.valueOf(arg.delete(TableDescriptorBuilder::NORMALIZATION_ENABLED))) if arg.include?(TableDescriptorBuilder::NORMALIZATION_ENABLED) tdb.setNormalizerTargetRegionCount(JInteger.valueOf(arg.delete(TableDescriptorBuilder::NORMALIZER_TARGET_REGION_COUNT))) if arg.include?(TableDescriptorBuilder::NORMALIZER_TARGET_REGION_COUNT) - tdb.setNormalizerTargetRegionSize(JLong.valueOf(arg.delete(TableDescriptorBuilder::NORMALIZER_TARGET_REGION_SIZE))) if arg.include?(TableDescriptorBuilder::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?(TableDescriptorBuilder::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' + tdb.setNormalizerTargetRegionSize(JLong.valueOf(arg.delete(TableDescriptorBuilder::NORMALIZER_TARGET_REGION_SIZE))) + end + tdb.setNormalizerTargetRegionSize(JLong.valueOf(arg.delete(TableDescriptorBuilder::NORMALIZER_TARGET_REGION_SIZE_MB))) \ + if arg.include?(TableDescriptorBuilder::NORMALIZER_TARGET_REGION_SIZE_MB) tdb.setMemStoreFlushSize(arg.delete(TableDescriptorBuilder::MEMSTORE_FLUSHSIZE)) if arg.include?(TableDescriptorBuilder::MEMSTORE_FLUSHSIZE) tdb.setDurability(org.apache.hadoop.hbase.client.Durability.valueOf(arg.delete(TableDescriptorBuilder::DURABILITY))) if arg.include?(TableDescriptorBuilder::DURABILITY) tdb.setPriority(JInteger.valueOf(arg.delete(TableDescriptorBuilder::PRIORITY))) if arg.include?(TableDescriptorBuilder::PRIORITY) diff --git a/hbase-shell/src/main/ruby/shell/commands/alter.rb b/hbase-shell/src/main/ruby/shell/commands/alter.rb index 22e6e42e69c3..b06ada00248e 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 @@ def help 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 309624ae1808..9e7096da9037 100644 --- a/hbase-shell/src/test/ruby/hbase/admin_test.rb +++ b/hbase-shell/src/test/ruby/hbase/admin_test.rb @@ -917,6 +917,13 @@ def teardown 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))