@@ -65,10 +65,15 @@ class SimpleRegionNormalizer implements RegionNormalizer, ConfigurationObserver
6565 static final boolean DEFAULT_SPLIT_ENABLED = true ;
6666 static final String MERGE_ENABLED_KEY = "hbase.normalizer.merge.enabled" ;
6767 static final boolean DEFAULT_MERGE_ENABLED = true ;
68- // TODO: after HBASE-24416, `min.region.count` only applies to merge plans; should
69- // deprecate/rename the configuration key.
68+ /**
69+ * @deprecated since 2.5.0 and will be removed in 4.0.0.
70+ * Use {@link SimpleRegionNormalizer#MERGE_MIN_REGION_COUNT_KEY} instead.
71+ * @see <a href="https://issues.apache.org/jira/browse/HBASE-25745">HBASE-25745</a>
72+ */
73+ @ Deprecated
7074 static final String MIN_REGION_COUNT_KEY = "hbase.normalizer.min.region.count" ;
71- static final int DEFAULT_MIN_REGION_COUNT = 3 ;
75+ static final String MERGE_MIN_REGION_COUNT_KEY = "hbase.normalizer.merge.min.region.count" ;
76+ static final int DEFAULT_MERGE_MIN_REGION_COUNT = 3 ;
7277 static final String MERGE_MIN_REGION_AGE_DAYS_KEY = "hbase.normalizer.merge.min_region_age.days" ;
7378 static final int DEFAULT_MERGE_MIN_REGION_AGE_DAYS = 3 ;
7479 static final String MERGE_MIN_REGION_SIZE_MB_KEY = "hbase.normalizer.merge.min_region_size.mb" ;
@@ -101,11 +106,21 @@ public void onConfigurationChange(Configuration conf) {
101106 setConf (conf );
102107 }
103108
104- private static int parseMinRegionCount (final Configuration conf ) {
105- final int parsedValue = conf .getInt (MIN_REGION_COUNT_KEY , DEFAULT_MIN_REGION_COUNT );
109+ private static int parseMergeMinRegionCount (final Configuration conf ) {
110+ String parsedStringValue = conf .get (MERGE_MIN_REGION_COUNT_KEY );
111+ if (parsedStringValue == null ) {
112+ parsedStringValue = conf .get (MIN_REGION_COUNT_KEY );
113+ if (parsedStringValue != null ) {
114+ LOG .warn ("The config key {} is deprecated. Instead please use {}. In future release we "
115+ + "will remove the deprecated config." , MIN_REGION_COUNT_KEY ,
116+ MERGE_MIN_REGION_COUNT_KEY );
117+ }
118+ }
119+ final int parsedValue = parsedStringValue == null ? DEFAULT_MERGE_MIN_REGION_COUNT :
120+ Integer .parseInt (parsedStringValue );
106121 final int settledValue = Math .max (1 , parsedValue );
107122 if (parsedValue != settledValue ) {
108- warnInvalidValue (MIN_REGION_COUNT_KEY , parsedValue , settledValue );
123+ warnInvalidValue (MERGE_MIN_REGION_COUNT_KEY , parsedValue , settledValue );
109124 }
110125 return settledValue ;
111126 }
@@ -158,10 +173,10 @@ public boolean isMergeEnabled() {
158173 }
159174
160175 /**
161- * Return this instance's configured value for {@value #MIN_REGION_COUNT_KEY }.
176+ * Return this instance's configured value for {@value #MERGE_MIN_REGION_COUNT_KEY }.
162177 */
163- public int getMinRegionCount () {
164- return normalizerConfiguration .getMinRegionCount ();
178+ public int getMergeMinRegionCount () {
179+ return normalizerConfiguration .getMergeMinRegionCount ();
165180 }
166181
167182 /**
@@ -340,10 +355,10 @@ private boolean skipForMerge(
340355 */
341356 private List <NormalizationPlan > computeMergeNormalizationPlans (final NormalizeContext ctx ) {
342357 final NormalizerConfiguration configuration = normalizerConfiguration ;
343- if (ctx .getTableRegions ().size () < configuration .getMinRegionCount (ctx )) {
358+ if (ctx .getTableRegions ().size () < configuration .getMergeMinRegionCount (ctx )) {
344359 LOG .debug ("Table {} has {} regions, required min number of regions for normalizer to run"
345360 + " is {}, not computing merge plans." , ctx .getTableName (),
346- ctx .getTableRegions ().size (), configuration .getMinRegionCount ());
361+ ctx .getTableRegions ().size (), configuration .getMergeMinRegionCount ());
347362 return Collections .emptyList ();
348363 }
349364
@@ -493,15 +508,15 @@ private static final class NormalizerConfiguration {
493508 private final Configuration conf ;
494509 private final boolean splitEnabled ;
495510 private final boolean mergeEnabled ;
496- private final int minRegionCount ;
511+ private final int mergeMinRegionCount ;
497512 private final Period mergeMinRegionAge ;
498513 private final long mergeMinRegionSizeMb ;
499514
500515 private NormalizerConfiguration () {
501516 conf = null ;
502517 splitEnabled = DEFAULT_SPLIT_ENABLED ;
503518 mergeEnabled = DEFAULT_MERGE_ENABLED ;
504- minRegionCount = DEFAULT_MIN_REGION_COUNT ;
519+ mergeMinRegionCount = DEFAULT_MERGE_MIN_REGION_COUNT ;
505520 mergeMinRegionAge = Period .ofDays (DEFAULT_MERGE_MIN_REGION_AGE_DAYS );
506521 mergeMinRegionSizeMb = DEFAULT_MERGE_MIN_REGION_SIZE_MB ;
507522 }
@@ -513,15 +528,15 @@ private NormalizerConfiguration(
513528 this .conf = conf ;
514529 splitEnabled = conf .getBoolean (SPLIT_ENABLED_KEY , DEFAULT_SPLIT_ENABLED );
515530 mergeEnabled = conf .getBoolean (MERGE_ENABLED_KEY , DEFAULT_MERGE_ENABLED );
516- minRegionCount = parseMinRegionCount (conf );
531+ mergeMinRegionCount = parseMergeMinRegionCount (conf );
517532 mergeMinRegionAge = parseMergeMinRegionAge (conf );
518533 mergeMinRegionSizeMb = parseMergeMinRegionSizeMb (conf );
519534 logConfigurationUpdated (SPLIT_ENABLED_KEY , currentConfiguration .isSplitEnabled (),
520535 splitEnabled );
521536 logConfigurationUpdated (MERGE_ENABLED_KEY , currentConfiguration .isMergeEnabled (),
522537 mergeEnabled );
523- logConfigurationUpdated (MIN_REGION_COUNT_KEY , currentConfiguration . getMinRegionCount () ,
524- minRegionCount );
538+ logConfigurationUpdated (MERGE_MIN_REGION_COUNT_KEY ,
539+ currentConfiguration . getMergeMinRegionCount (), mergeMinRegionCount );
525540 logConfigurationUpdated (MERGE_MIN_REGION_AGE_DAYS_KEY ,
526541 currentConfiguration .getMergeMinRegionAge (), mergeMinRegionAge );
527542 logConfigurationUpdated (MERGE_MIN_REGION_SIZE_MB_KEY ,
@@ -540,24 +555,34 @@ public boolean isMergeEnabled() {
540555 return mergeEnabled ;
541556 }
542557
543- public int getMinRegionCount () {
544- return minRegionCount ;
558+ public int getMergeMinRegionCount () {
559+ return mergeMinRegionCount ;
545560 }
546561
547- public int getMinRegionCount (NormalizeContext context ) {
548- int minRegionCount = context .getOrDefault (MIN_REGION_COUNT_KEY , Integer ::parseInt , 0 );
549- if (minRegionCount <= 0 ) {
550- minRegionCount = getMinRegionCount ();
562+ public int getMergeMinRegionCount (NormalizeContext context ) {
563+ String stringValue = context .getOrDefault (MERGE_MIN_REGION_COUNT_KEY ,
564+ Function .identity (), null );
565+ if (stringValue == null ) {
566+ stringValue = context .getOrDefault (MIN_REGION_COUNT_KEY , Function .identity (), null );
567+ if (stringValue != null ) {
568+ LOG .debug ("The config key {} in table descriptor is deprecated. Instead please use {}. "
569+ + "In future release we will remove the deprecated config." , MIN_REGION_COUNT_KEY ,
570+ MERGE_MIN_REGION_COUNT_KEY );
571+ }
572+ }
573+ final int mergeMinRegionCount = stringValue == null ? 0 : Integer .parseInt (stringValue );
574+ if (mergeMinRegionCount <= 0 ) {
575+ return getMergeMinRegionCount ();
551576 }
552- return minRegionCount ;
577+ return mergeMinRegionCount ;
553578 }
554579
555580 public Period getMergeMinRegionAge () {
556581 return mergeMinRegionAge ;
557582 }
558583
559584 public Period getMergeMinRegionAge (NormalizeContext context ) {
560- int mergeMinRegionAge = context .getOrDefault (MERGE_MIN_REGION_AGE_DAYS_KEY ,
585+ final int mergeMinRegionAge = context .getOrDefault (MERGE_MIN_REGION_AGE_DAYS_KEY ,
561586 Integer ::parseInt , -1 );
562587 if (mergeMinRegionAge < 0 ) {
563588 return getMergeMinRegionAge ();
@@ -570,10 +595,10 @@ public long getMergeMinRegionSizeMb() {
570595 }
571596
572597 public long getMergeMinRegionSizeMb (NormalizeContext context ) {
573- long mergeMinRegionSizeMb = context .getOrDefault (MERGE_MIN_REGION_SIZE_MB_KEY ,
598+ final long mergeMinRegionSizeMb = context .getOrDefault (MERGE_MIN_REGION_SIZE_MB_KEY ,
574599 Long ::parseLong , (long )-1 );
575600 if (mergeMinRegionSizeMb < 0 ) {
576- mergeMinRegionSizeMb = getMergeMinRegionSizeMb ();
601+ return getMergeMinRegionSizeMb ();
577602 }
578603 return mergeMinRegionSizeMb ;
579604 }
0 commit comments