Class SimpleRegionNormalizer
java.lang.Object
org.apache.hadoop.hbase.master.normalizer.SimpleRegionNormalizer
- All Implemented Interfaces:
org.apache.hadoop.conf.Configurable,ConfigurationObserver,RegionNormalizer
@LimitedPrivate("Configuration")
class SimpleRegionNormalizer
extends Object
implements RegionNormalizer, ConfigurationObserver
Simple implementation of region normalizer. Logic in use:
- Get all regions of a given table
- Get avg size S of the regions in the table (by total size of store files reported in RegionMetrics)
- For each region R0, if R0 is bigger than S * 2, it is kindly requested to split.
- Otherwise, for the next region in the chain R1, if R0 + R1 is smaller then S, R0 and R1 are kindly requested to merge.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classInner class caries the state necessary to perform a single invocation ofcomputePlansForTable(TableDescriptor).private static final classHolds the configuration values read fromConfiguration. -
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final boolean(package private) static final int(package private) static final int(package private) static final int(package private) static final long(package private) static final booleanprivate static final org.slf4j.Loggerprivate MasterServices(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final StringDeprecated.since 2.5.0 and will be removed in 4.0.0.(package private) static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate List<NormalizationPlan>Computes the merge plans that should be executed for this table to converge average region towards target average or target region count.computePlansForTable(TableDescriptor tableDescriptor) Computes a list of normalizer actions to perform on the target table.private List<NormalizationPlan>Computes the split plans that should be executed for this table to converge average region size towards target average or target region count.private doublegetAverageRegionSizeMb(List<RegionInfo> tableRegions, TableDescriptor tableDescriptor) Also make sure tableRegions contains regions of the same tableorg.apache.hadoop.conf.ConfigurationgetConf()Return this instance's configured value for "hbase.normalizer.merge.min_region_age.days".intReturn this instance's configured value for "hbase.normalizer.merge.min.region.count".longReturn this instance's configured value for "hbase.normalizer.merge.min_region_size.mb".longprivate longReturns size of region in MB and if region is not found than -1private booleanisLargeEnoughForMerge(SimpleRegionNormalizer.NormalizerConfiguration normalizerConfiguration, SimpleRegionNormalizer.NormalizeContext ctx, RegionInfo regionInfo) ReturntruewhenregionInfohas a size that is sufficient to be considered for a merge operation,falseotherwise.private booleanisMasterSwitchEnabled(MasterSwitchType masterSwitchType) booleanReturn this instance's configured value for "hbase.normalizer.merge.enabled".private static booleanisOldEnoughForMerge(SimpleRegionNormalizer.NormalizerConfiguration normalizerConfiguration, SimpleRegionNormalizer.NormalizeContext ctx, RegionInfo regionInfo) ReturntruewhenregionInfohas a creation date that is old enough to be considered for a merge operation,falseotherwise.booleanReturn this instance's configured value for "hbase.normalizer.split.enabled".private static <T> voidlogConfigurationUpdated(String key, T oldValue, T newValue) private static booleanlogTraceReason(BooleanSupplier predicate, String fmtWhenTrue, Object... args) voidonConfigurationChange(org.apache.hadoop.conf.Configuration conf) This method would be called by theConfigurationManagerobject when theConfigurationobject is reloaded from disk.private static PeriodparseMergeMinRegionAge(org.apache.hadoop.conf.Configuration conf) private static intparseMergeMinRegionCount(org.apache.hadoop.conf.Configuration conf) private static longparseMergeMinRegionSizeMb(org.apache.hadoop.conf.Configuration conf) private static longparseMergeRequestMaxNumberOfRegionsCount(org.apache.hadoop.conf.Configuration conf) private booleanproceedWithMergePlanning(TableDescriptor tableDescriptor) private booleanproceedWithSplitPlanning(TableDescriptor tableDescriptor) voidsetConf(org.apache.hadoop.conf.Configuration conf) voidsetMasterServices(MasterServices masterServices) Set the master service.(package private) voidThis very simple method exists so we can verify it was called in a unit test.private booleanskipForMerge(SimpleRegionNormalizer.NormalizerConfiguration normalizerConfiguration, SimpleRegionNormalizer.NormalizeContext ctx, RegionInfo regionInfo) Determine if aRegionInfoshould be considered for a merge operation.private static booleanskipForSplit(RegionState state, RegionInfo regionInfo) Determine if a region inRegionStateshould be considered for a split operation.private static <T> voidwarnInvalidValue(String key, T parsedValue, T settledValue)
-
Field Details
-
LOG
-
SPLIT_ENABLED_KEY
- See Also:
-
DEFAULT_SPLIT_ENABLED
- See Also:
-
MERGE_ENABLED_KEY
- See Also:
-
DEFAULT_MERGE_ENABLED
- See Also:
-
MIN_REGION_COUNT_KEY
Deprecated.since 2.5.0 and will be removed in 4.0.0. UseMERGE_MIN_REGION_COUNT_KEYinstead.- See Also:
-
MERGE_MIN_REGION_COUNT_KEY
- See Also:
-
DEFAULT_MERGE_MIN_REGION_COUNT
- See Also:
-
MERGE_MIN_REGION_AGE_DAYS_KEY
- See Also:
-
DEFAULT_MERGE_MIN_REGION_AGE_DAYS
- See Also:
-
MERGE_MIN_REGION_SIZE_MB_KEY
- See Also:
-
DEFAULT_MERGE_MIN_REGION_SIZE_MB
- See Also:
-
MERGE_REQUEST_MAX_NUMBER_OF_REGIONS_COUNT_KEY
- See Also:
-
DEFAULT_MERGE_REQUEST_MAX_NUMBER_OF_REGIONS_COUNT
- See Also:
-
masterServices
-
normalizerConfiguration
-
-
Constructor Details
-
SimpleRegionNormalizer
public SimpleRegionNormalizer()
-
-
Method Details
-
getConf
- Specified by:
getConfin interfaceorg.apache.hadoop.conf.Configurable
-
setConf
- Specified by:
setConfin interfaceorg.apache.hadoop.conf.Configurable
-
onConfigurationChange
Description copied from interface:ConfigurationObserverThis method would be called by theConfigurationManagerobject when theConfigurationobject is reloaded from disk.- Specified by:
onConfigurationChangein interfaceConfigurationObserver
-
parseMergeMinRegionCount
-
parseMergeMinRegionAge
-
parseMergeMinRegionSizeMb
-
parseMergeRequestMaxNumberOfRegionsCount
private static long parseMergeRequestMaxNumberOfRegionsCount(org.apache.hadoop.conf.Configuration conf) -
warnInvalidValue
-
logConfigurationUpdated
-
isSplitEnabled
Return this instance's configured value for "hbase.normalizer.split.enabled". -
isMergeEnabled
Return this instance's configured value for "hbase.normalizer.merge.enabled". -
getMergeMinRegionCount
Return this instance's configured value for "hbase.normalizer.merge.min.region.count". -
getMergeMinRegionAge
Return this instance's configured value for "hbase.normalizer.merge.min_region_age.days". -
getMergeMinRegionSizeMb
Return this instance's configured value for "hbase.normalizer.merge.min_region_size.mb". -
getMergeRequestMaxNumberOfRegionsCount
-
setMasterServices
Description copied from interface:RegionNormalizerSet the master service. Must be called before first call toRegionNormalizer.computePlansForTable(TableDescriptor).- Specified by:
setMasterServicesin interfaceRegionNormalizer- Parameters:
masterServices- master services to use
-
computePlansForTable
Description copied from interface:RegionNormalizerComputes a list of normalizer actions to perform on the target table. This is the primary entry-point from the Master driving a normalization activity.- Specified by:
computePlansForTablein interfaceRegionNormalizer- Parameters:
tableDescriptor- table descriptor for table which needs normalize- Returns:
- A list of the normalization actions to perform, or an empty list if there's nothing to do.
-
getRegionSizeMB
Returns size of region in MB and if region is not found than -1 -
isMasterSwitchEnabled
-
proceedWithSplitPlanning
-
proceedWithMergePlanning
-
getAverageRegionSizeMb
private double getAverageRegionSizeMb(List<RegionInfo> tableRegions, TableDescriptor tableDescriptor) Also make sure tableRegions contains regions of the same table- Parameters:
tableRegions- regions of table to normalizetableDescriptor- the TableDescriptor- Returns:
- average region size depending on
- See Also:
-
skipForMerge
private boolean skipForMerge(SimpleRegionNormalizer.NormalizerConfiguration normalizerConfiguration, SimpleRegionNormalizer.NormalizeContext ctx, RegionInfo regionInfo) Determine if aRegionInfoshould be considered for a merge operation. Callers beware: for safe concurrency, be sure to pass in the local instance ofSimpleRegionNormalizer.NormalizerConfiguration, don't usethis's instance. -
computeMergeNormalizationPlans
private List<NormalizationPlan> computeMergeNormalizationPlans(SimpleRegionNormalizer.NormalizeContext ctx) Computes the merge plans that should be executed for this table to converge average region towards target average or target region count. -
skipForSplit
Determine if a region inRegionStateshould be considered for a split operation. -
computeSplitNormalizationPlans
private List<NormalizationPlan> computeSplitNormalizationPlans(SimpleRegionNormalizer.NormalizeContext ctx) Computes the split plans that should be executed for this table to converge average region size towards target average or target region count.
if the region is > 2 times larger than average, we split it. split is more high priority normalization action than merge. -
isOldEnoughForMerge
private static boolean isOldEnoughForMerge(SimpleRegionNormalizer.NormalizerConfiguration normalizerConfiguration, SimpleRegionNormalizer.NormalizeContext ctx, RegionInfo regionInfo) ReturntruewhenregionInfohas a creation date that is old enough to be considered for a merge operation,falseotherwise. -
isLargeEnoughForMerge
private boolean isLargeEnoughForMerge(SimpleRegionNormalizer.NormalizerConfiguration normalizerConfiguration, SimpleRegionNormalizer.NormalizeContext ctx, RegionInfo regionInfo) ReturntruewhenregionInfohas a size that is sufficient to be considered for a merge operation,falseotherwise. Callers beware: for safe concurrency, be sure to pass in the local instance ofSimpleRegionNormalizer.NormalizerConfiguration, don't usethis's instance. -
shuffleNormalizationPlans
This very simple method exists so we can verify it was called in a unit test. Visible for testing. -
logTraceReason
private static boolean logTraceReason(BooleanSupplier predicate, String fmtWhenTrue, Object... args)
-