@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, onlySystemTablesOnMaster, rackManager, regionFinder, services, slop, useRegionFinderFAVORED_ALWAYS_ASSIGN_REGIONSBOGUS_SERVER_NAME, SYSTEM_TABLES_ON_MASTER, TABLES_ON_MASTER| Constructor and Description |
|---|
FavoredStochasticBalancer() |
| Modifier and Type | Method and Description |
|---|---|
protected List<RegionPlan> |
balanceTable(TableName tableName,
Map<ServerName,List<RegionInfo>> loadOfOneTable)
Given the cluster state this will try and approach an optimal balance.
|
protected List<org.apache.hadoop.hbase.master.balancer.CandidateGenerator> |
createCandidateGenerators() |
void |
generateFavoredNodesForDaughter(List<ServerName> servers,
RegionInfo parent,
RegionInfo regionA,
RegionInfo regionB) |
void |
generateFavoredNodesForMergedRegion(RegionInfo merged,
RegionInfo[] mergeParents) |
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)
Used to assign a single region to a random server.
|
Map<ServerName,List<RegionInfo>> |
retainAssignment(Map<RegionInfo,ServerName> regions,
List<ServerName> servers)
Generates a bulk assignment startup plan, attempting to reuse the existing assignment
information from META, but adjusting for the specified list of available/online servers
available for assignment.
|
Map<ServerName,List<RegionInfo>> |
roundRobinAssignment(List<RegionInfo> regions,
List<ServerName> servers)
Generates a bulk assignment plan to be used on cluster startup using a simple round-robin
assignment.
|
void |
setMasterServices(MasterServices masterServices)
Set the master service.
|
loadConf, updateBalancerLoadInfo, updateClusterMetricsassignMasterSystemRegions, balanceCluster, balanceMasterRegions, getConf, getDefaultSlop, idleRegionServerExist, initialize, isStopped, onConfigurationChange, postMasterStartupInitialize, preBalanceCluster, regionOffline, regionOnline, shouldBeOnMaster, sloppyRegionServerExist, stop, toEnsumbleTableLoad, updateBalancerStatusclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitisMasterCanHostUserRegions, isSystemTablesOnlyOnMaster, isTablesOnMasterprotected List<org.apache.hadoop.hbase.master.balancer.CandidateGenerator> createCandidateGenerators()
createCandidateGenerators in class StochasticLoadBalancerprotected org.apache.hadoop.hbase.master.balancer.CandidateGenerator getRandomGenerator()
getRandomGenerator in class StochasticLoadBalancerpublic void setMasterServices(MasterServices masterServices)
LoadBalancersetMasterServices in interface LoadBalancersetMasterServices in class BaseLoadBalancer@NonNull public Map<ServerName,List<RegionInfo>> roundRobinAssignment(List<RegionInfo> regions, List<ServerName> servers) throws HBaseIOException
BaseLoadBalancerroundRobinAssignment in interface LoadBalancerroundRobinAssignment in class BaseLoadBalancerregions - all regionsservers - all serversHBaseIOExceptionpublic ServerName randomAssignment(RegionInfo regionInfo, List<ServerName> servers) throws HBaseIOException
BaseLoadBalancerrandomAssignment 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
BaseLoadBalancerTakes a map of all regions to their existing assignment from META. Also takes a list of online servers for regions to be assigned to. Attempts to retain all assignment, so in some instances initial assignment will not be completely balanced.
Any leftover regions without an existing server to be assigned to will be assigned randomly to available servers.
retainAssignment in interface LoadBalancerretainAssignment in class BaseLoadBalancerregions - regions and existing assignment from metaservers - available serversHBaseIOExceptionpublic List<ServerName> getFavoredNodes(RegionInfo regionInfo)
public 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)
StochasticLoadBalancerbalanceTable 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.