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
Modifier and TypeClassDescriptionprivate class
Inner class caries the state necessary to perform a single invocation ofcomputePlansForTable(TableDescriptor)
.private static final class
Holds the configuration values read fromConfiguration
. -
Field Summary
Modifier 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 boolean
private static final org.slf4j.Logger
private 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 String
Deprecated.since 2.5.0 and will be removed in 4.0.0.(package private) static final String
-
Constructor Summary
-
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 double
getAverageRegionSizeMb
(List<RegionInfo> tableRegions, TableDescriptor tableDescriptor) Also make sure tableRegions contains regions of the same tableorg.apache.hadoop.conf.Configuration
getConf()
Return this instance's configured value for "hbase.normalizer.merge.min_region_age.days".int
Return this instance's configured value for "hbase.normalizer.merge.min.region.count".long
Return this instance's configured value for "hbase.normalizer.merge.min_region_size.mb".long
private long
Returns size of region in MB and if region is not found than -1private boolean
isLargeEnoughForMerge
(SimpleRegionNormalizer.NormalizerConfiguration normalizerConfiguration, SimpleRegionNormalizer.NormalizeContext ctx, RegionInfo regionInfo) Returntrue
whenregionInfo
has a size that is sufficient to be considered for a merge operation,false
otherwise.private boolean
isMasterSwitchEnabled
(MasterSwitchType masterSwitchType) boolean
Return this instance's configured value for "hbase.normalizer.merge.enabled".private static boolean
isOldEnoughForMerge
(SimpleRegionNormalizer.NormalizerConfiguration normalizerConfiguration, SimpleRegionNormalizer.NormalizeContext ctx, RegionInfo regionInfo) Returntrue
whenregionInfo
has a creation date that is old enough to be considered for a merge operation,false
otherwise.boolean
Return this instance's configured value for "hbase.normalizer.split.enabled".private static <T> void
logConfigurationUpdated
(String key, T oldValue, T newValue) private static boolean
logTraceReason
(BooleanSupplier predicate, String fmtWhenTrue, Object... args) void
onConfigurationChange
(org.apache.hadoop.conf.Configuration conf) This method would be called by theConfigurationManager
object when theConfiguration
object is reloaded from disk.private static Period
parseMergeMinRegionAge
(org.apache.hadoop.conf.Configuration conf) private static int
parseMergeMinRegionCount
(org.apache.hadoop.conf.Configuration conf) private static long
parseMergeMinRegionSizeMb
(org.apache.hadoop.conf.Configuration conf) private static long
parseMergeRequestMaxNumberOfRegionsCount
(org.apache.hadoop.conf.Configuration conf) private boolean
proceedWithMergePlanning
(TableDescriptor tableDescriptor) private boolean
proceedWithSplitPlanning
(TableDescriptor tableDescriptor) void
setConf
(org.apache.hadoop.conf.Configuration conf) void
setMasterServices
(MasterServices masterServices) Set the master service.(package private) void
This very simple method exists so we can verify it was called in a unit test.private boolean
skipForMerge
(SimpleRegionNormalizer.NormalizerConfiguration normalizerConfiguration, SimpleRegionNormalizer.NormalizeContext ctx, RegionInfo regionInfo) Determine if aRegionInfo
should be considered for a merge operation.private static boolean
skipForSplit
(RegionState state, RegionInfo regionInfo) Determine if a region inRegionState
should be considered for a split operation.private static <T> void
warnInvalidValue
(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_KEY
instead.- 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:
getConf
in interfaceorg.apache.hadoop.conf.Configurable
-
setConf
- Specified by:
setConf
in interfaceorg.apache.hadoop.conf.Configurable
-
onConfigurationChange
Description copied from interface:ConfigurationObserver
This method would be called by theConfigurationManager
object when theConfiguration
object is reloaded from disk.- Specified by:
onConfigurationChange
in 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:RegionNormalizer
Set the master service. Must be called before first call toRegionNormalizer.computePlansForTable(TableDescriptor)
.- Specified by:
setMasterServices
in interfaceRegionNormalizer
- Parameters:
masterServices
- master services to use
-
computePlansForTable
Description copied from interface:RegionNormalizer
Computes 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:
computePlansForTable
in 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 aRegionInfo
should 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 inRegionState
should 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) Returntrue
whenregionInfo
has a creation date that is old enough to be considered for a merge operation,false
otherwise. -
isLargeEnoughForMerge
private boolean isLargeEnoughForMerge(SimpleRegionNormalizer.NormalizerConfiguration normalizerConfiguration, SimpleRegionNormalizer.NormalizeContext ctx, RegionInfo regionInfo) Returntrue
whenregionInfo
has a size that is sufficient to be considered for a merge operation,false
otherwise. 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)
-