@InterfaceAudience.Private public class FavoredStochasticBalancer extends StochasticLoadBalancer implements FavoredNodesPromoter
LoadBalancer that assigns favored
nodes for each region. There is a Primary RegionServer that hosts the region, and then there is
Secondary and Tertiary RegionServers. Currently, the favored nodes information is used in
creating HDFS files - the Primary RegionServer passes the primary, secondary, tertiary node
addresses as hints to the DistributedFileSystem API for creating files on the filesystem. These
nodes are treated as hints by the HDFS to place the blocks of the file. This alleviates the
problem to do with reading from remote nodes (since we can make the Secondary RegionServer as the
new Primary RegionServer) after a region is recovered. This should help provide consistent read
latencies for the regions even when their primary region servers die. This provides two
CandidateGeneratorStochasticLoadBalancer.GeneratorTypecandidateGenerators, COST_FUNCTIONS_COST_FUNCTIONS_KEY, DEFAULT_KEEP_REGION_LOADS, DEFAULT_MAX_RUNNING_TIME, DEFAULT_MAX_STEPS, DEFAULT_MIN_COST_NEED_BALANCE, DEFAULT_RUN_MAX_STEPS, DEFAULT_STEPS_PER_REGION, KEEP_REGION_LOADS, MAX_RUNNING_TIME_KEY, MAX_STEPS_KEY, MIN_COST_NEED_BALANCE_KEY, OVERALL_COST_FUNCTION_NAME, RUN_MAX_STEPS_KEY, STEPS_PER_REGION_KEYBALANCER_DECISION_BUFFER_ENABLED, BALANCER_REJECTION_BUFFER_ENABLED, clusterStatus, DEFAULT_BALANCER_DECISION_BUFFER_ENABLED, DEFAULT_BALANCER_REJECTION_BUFFER_ENABLED, DEFAULT_HBASE_MASTER_LOADBALANCE_BYTABLE, isByTable, masterServerName, metricsBalancer, MIN_SERVER_BALANCE, provider, rackManager, regionFinder, slop, useRegionFinderFAVORED_ALWAYS_ASSIGN_REGIONSBOGUS_SERVER_NAME, HBASE_RSGROUP_LOADBALANCER_CLASS| Constructor and Description |
|---|
FavoredStochasticBalancer() |
| Modifier and Type | Method and Description |
|---|---|
protected List<RegionPlan> |
balanceTable(TableName tableName,
Map<ServerName,List<RegionInfo>> loadOfOneTable)
For all regions correctly assigned to favored nodes, we just use the stochastic balancer
implementation.
|
protected List<org.apache.hadoop.hbase.master.balancer.CandidateGenerator> |
createCandidateGenerators() |
void |
generateFavoredNodesForDaughter(List<ServerName> servers,
RegionInfo parent,
RegionInfo regionA,
RegionInfo regionB)
Generate Favored Nodes for daughters during region split.
|
void |
generateFavoredNodesForMergedRegion(RegionInfo merged,
RegionInfo[] mergeParents)
Generate favored nodes for a region during merge.
|
List<ServerName> |
getFavoredNodes(RegionInfo regionInfo) |
protected org.apache.hadoop.hbase.master.balancer.CandidateGenerator |
getRandomGenerator()
Returns any candidate generator in random
|
ServerName |
randomAssignment(RegionInfo regionInfo,
List<ServerName> servers)
If we have favored nodes for a region, we will return one of the FN as destination.
|
Map<ServerName,List<RegionInfo>> |
retainAssignment(Map<RegionInfo,ServerName> regions,
List<ServerName> servers)
Reuse BaseLoadBalancer's retainAssignment, but generate favored nodes when its missing.
|
Map<ServerName,List<RegionInfo>> |
roundRobinAssignment(List<RegionInfo> regions,
List<ServerName> servers)
Round robin assignment: Segregate the regions into two types: 1.
|
void |
setFavoredNodesManager(FavoredNodesManager fnm) |
loadConf, updateBalancerLoadInfo, updateClusterMetricsbalanceCluster, getConf, getDefaultSlop, idleRegionServerExist, initialize, isStopped, onConfigurationChange, postMasterStartupInitialize, preBalanceCluster, regionOffline, regionOnline, setClusterInfoProvider, sloppyRegionServerExist, stop, toEnsumbleTableLoad, updateBalancerStatuspublic void setFavoredNodesManager(FavoredNodesManager fnm)
setFavoredNodesManager in interface FavoredNodesPromoterprotected List<org.apache.hadoop.hbase.master.balancer.CandidateGenerator> createCandidateGenerators()
createCandidateGenerators in class StochasticLoadBalancerprotected org.apache.hadoop.hbase.master.balancer.CandidateGenerator getRandomGenerator()
getRandomGenerator in class StochasticLoadBalancer@NonNull public Map<ServerName,List<RegionInfo>> roundRobinAssignment(List<RegionInfo> regions, List<ServerName> servers) throws HBaseIOException
roundRobinAssignment in interface LoadBalancerroundRobinAssignment in class BaseLoadBalancerregions - all regionsservers - all serversHBaseIOExceptionpublic ServerName randomAssignment(RegionInfo regionInfo, List<ServerName> servers) throws HBaseIOException
randomAssignment in interface LoadBalancerrandomAssignment in class BaseLoadBalancerregionInfo - Region for which this selection is being done.HBaseIOException@NonNull public Map<ServerName,List<RegionInfo>> retainAssignment(Map<RegionInfo,ServerName> regions, List<ServerName> servers) throws HBaseIOException
retainAssignment in interface LoadBalancerretainAssignment in class BaseLoadBalancerregions - regions and existing assignment from metaservers - available serversHBaseIOExceptionpublic List<ServerName> getFavoredNodes(RegionInfo regionInfo)
getFavoredNodes in interface FavoredNodesPromoterpublic void generateFavoredNodesForDaughter(List<ServerName> servers, RegionInfo parent, RegionInfo regionA, RegionInfo regionB) throws IOException
generateFavoredNodesForDaughter in interface FavoredNodesPromoterIOExceptionpublic void generateFavoredNodesForMergedRegion(RegionInfo merged, RegionInfo[] mergeParents) throws IOException
generateFavoredNodesForMergedRegion in interface FavoredNodesPromoterIOExceptionprotected List<RegionPlan> balanceTable(TableName tableName, Map<ServerName,List<RegionInfo>> loadOfOneTable)
balanceTable in class StochasticLoadBalancertableName - the table to be balancedloadOfOneTable - region load of servers for the specific one tableCopyright © 2007–2020 The Apache Software Foundation. All rights reserved.