@InterfaceAudience.Private public class HeterogeneousRegionCountCostFunction extends CostFunction
* 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:Modifier and Type | Field and Description |
---|---|
private org.apache.hadoop.conf.Configuration |
conf |
private static float |
DEFAULT_REGION_COUNT_SKEW_COST |
private int |
defaultNumberOfRegions |
private static String |
HBASE_MASTER_BALANCER_HETEROGENEOUS_RULES_DEFAULT
Default rule to apply when the rule file is not found.
|
(package private) static String |
HBASE_MASTER_BALANCER_HETEROGENEOUS_RULES_FILE
configuration used for the path where the rule file is stored.
|
private Map<ServerName,Integer> |
limitPerRS
This is a cache, used to not go through all the limitPerRule map when searching for limit
|
private Map<Pattern,Integer> |
limitPerRule
Contains the rules, key is the regexp for ServerName, value is the limit
|
private static org.slf4j.Logger |
LOG |
(package private) double |
overallUsage |
private static String |
REGION_COUNT_SKEW_COST_KEY
Cost for the function.
|
private String |
rulesPath |
private int |
totalCapacity
Total capacity of regions for the cluster, based on the online RS and their associated rules
|
cluster, COST_EPSILON
Constructor and Description |
---|
HeterogeneousRegionCountCostFunction(org.apache.hadoop.conf.Configuration conf) |
Modifier and Type | Method and Description |
---|---|
protected double |
cost() |
(package private) int |
findLimitForRS(ServerName serverName)
Find the limit for a ServerName.
|
(package private) int |
getNumberOfRulesLoaded() |
(package private) void |
loadRules()
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.
|
private List<String> |
readFile(String filename)
used to read the rule files from either HDFS or local FS
|
private List<String> |
readFileFromHDFS(String filename)
used to read the rule files from HDFS
|
private List<String> |
readFileFromLocalFS(String filename)
used to read the rule files from local FS
|
private List<String> |
readLines(BufferedReader reader) |
private void |
rebuildCache()
Rebuild cache matching ServerNames and their capacity.
|
getMultiplier, isNeeded, postAction, regionMoved, scale, setMultiplier, updateWeight
static final String HBASE_MASTER_BALANCER_HETEROGENEOUS_RULES_FILE
private static final org.slf4j.Logger LOG
private static final String HBASE_MASTER_BALANCER_HETEROGENEOUS_RULES_DEFAULT
private static final String REGION_COUNT_SKEW_COST_KEY
private static final float DEFAULT_REGION_COUNT_SKEW_COST
private final Map<Pattern,Integer> limitPerRule
private final Map<ServerName,Integer> limitPerRS
private final org.apache.hadoop.conf.Configuration conf
private int defaultNumberOfRegions
private int totalCapacity
double overallUsage
HeterogeneousRegionCountCostFunction(org.apache.hadoop.conf.Configuration conf)
void prepare(BalancerClusterState cluster)
prepare
in class CostFunction
protected double cost()
cost
in class CostFunction
void loadRules()
private List<String> readFile(String filename)
private List<String> readFileFromHDFS(String filename) throws IOException
IOException
private List<String> readFileFromLocalFS(String filename) throws IOException
IOException
private List<String> readLines(BufferedReader reader) throws IOException
IOException
private void rebuildCache()
int findLimitForRS(ServerName serverName)
serverName
- the server we are looking forint getNumberOfRulesLoaded()
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.