Class HeterogeneousRegionCountCostFunction
java.lang.Object
org.apache.hadoop.hbase.master.balancer.CostFunction
org.apache.hadoop.hbase.master.balancer.HeterogeneousRegionCountCostFunction
This is an optional Cost function designed to allow region count skew across RegionServers. A
rule file is loaded from the local FS or HDFS before balancing. It contains lines of rules. A
rule is composed of a regexp for hostname, and a limit. For example, we could have:
* rs[0-9] 200 * rs1[0-9] 50
RegionServers with hostname matching the first rules will have a limit of 200, and the others 50. If there's no match, a default is set. The costFunction is trying to fill all RegionServers linearly, meaning that if the global usage is at 50%, then all RegionServers should hold half of their capacity in terms of regions. In order to use this CostFunction, you need to set the following options:- hbase.master.balancer.stochastic.additionalCostFunctions
- hbase.master.balancer.stochastic.heterogeneousRegionCountRulesFile
- hbase.master.balancer.stochastic.heterogeneousRegionCountDefault
-
Field Summary
Modifier and TypeFieldDescriptionprivate final org.apache.hadoop.conf.Configuration
private static final float
private int
private static final String
Default rule to apply when the rule file is not found.(package private) static final String
configuration used for the path where the rule file is stored.private final Map<ServerName,
Integer> This is a cache, used to not go through all the limitPerRule map when searching for limitContains the rules, key is the regexp for ServerName, value is the limitprivate static final org.slf4j.Logger
(package private) double
private static final String
Cost for the function.private final String
private int
Total capacity of regions for the cluster, based on the online RS and their associated rulesFields inherited from class org.apache.hadoop.hbase.master.balancer.CostFunction
cluster, COST_EPSILON
-
Constructor Summary
ConstructorDescriptionHeterogeneousRegionCountCostFunction
(org.apache.hadoop.conf.Configuration conf) -
Method Summary
Modifier and TypeMethodDescriptionprotected double
cost()
(package private) int
findLimitForRS
(ServerName serverName) Find the limit for a ServerName.(package private) int
(package private) void
used to load the rule files.(package private) void
prepare
(BalancerClusterState cluster) Called once per LB invocation to give the cost function to initialize it's state, and perform any costly calculation.used to read the rule files from either HDFS or local FSreadFileFromHDFS
(String filename) used to read the rule files from HDFSreadFileFromLocalFS
(String filename) used to read the rule files from local FSprivate void
Rebuild cache matching ServerNames and their capacity.Methods inherited from class org.apache.hadoop.hbase.master.balancer.CostFunction
getMultiplier, isNeeded, postAction, regionMoved, scale, setMultiplier, updateWeight
-
Field Details
-
HBASE_MASTER_BALANCER_HETEROGENEOUS_RULES_FILE
configuration used for the path where the rule file is stored.- See Also:
-
LOG
-
HBASE_MASTER_BALANCER_HETEROGENEOUS_RULES_DEFAULT
Default rule to apply when the rule file is not found. Default to 200.- See Also:
-
REGION_COUNT_SKEW_COST_KEY
Cost for the function. Default to 500, can be changed.- See Also:
-
DEFAULT_REGION_COUNT_SKEW_COST
- See Also:
-
rulesPath
-
limitPerRule
Contains the rules, key is the regexp for ServerName, value is the limit -
limitPerRS
This is a cache, used to not go through all the limitPerRule map when searching for limit -
conf
-
defaultNumberOfRegions
-
totalCapacity
Total capacity of regions for the cluster, based on the online RS and their associated rules -
overallUsage
double overallUsage
-
-
Constructor Details
-
HeterogeneousRegionCountCostFunction
HeterogeneousRegionCountCostFunction(org.apache.hadoop.conf.Configuration conf)
-
-
Method Details
-
prepare
Called once per LB invocation to give the cost function to initialize it's state, and perform any costly calculation.- Overrides:
prepare
in classCostFunction
-
cost
- Specified by:
cost
in classCostFunction
-
loadRules
void loadRules()used to load the rule files. -
readFile
used to read the rule files from either HDFS or local FS -
readFileFromHDFS
used to read the rule files from HDFS- Throws:
IOException
-
readFileFromLocalFS
used to read the rule files from local FS- Throws:
IOException
-
rebuildCache
Rebuild cache matching ServerNames and their capacity. -
findLimitForRS
Find the limit for a ServerName. If not found then return the default value- Parameters:
serverName
- the server we are looking for- Returns:
- the limit
-
getNumberOfRulesLoaded
int getNumberOfRulesLoaded()
-