protected static class BaseLoadBalancer.Cluster extends Object
Modifier and Type | Class and Description |
---|---|
static class |
BaseLoadBalancer.Cluster.Action
An action to move or swap a region
|
static class |
BaseLoadBalancer.Cluster.AssignRegionAction |
(package private) static class |
BaseLoadBalancer.Cluster.LocalityType |
static class |
BaseLoadBalancer.Cluster.MoveRegionAction |
static class |
BaseLoadBalancer.Cluster.SwapRegionsAction |
Modifier and Type | Field and Description |
---|---|
(package private) Map<ServerName,List<RegionInfo>> |
clusterState |
(package private) boolean |
hasRegionReplicas |
(package private) String[] |
hosts |
(package private) Map<String,Integer> |
hostsToIndex |
(package private) int[] |
initialRegionIndexToServerIndex |
(package private) float[] |
localityPerServer |
(package private) boolean |
multiServersPerHost |
static BaseLoadBalancer.Cluster.Action |
NullAction |
(package private) int |
numHosts |
(package private) int[] |
numMaxRegionsPerTable |
(package private) int |
numMovedRegions |
(package private) int |
numRacks |
(package private) int |
numRegions |
private Comparator<Integer> |
numRegionsComparator |
(package private) int[][] |
numRegionsPerServerPerTable |
(package private) int |
numServers |
(package private) int |
numTables |
(package private) int[][] |
primariesOfRegionsPerHost |
(package private) int[][] |
primariesOfRegionsPerRack |
(package private) int[][] |
primariesOfRegionsPerServer |
private float[][] |
rackLocalities |
protected RackManager |
rackManager |
(package private) String[] |
racks |
(package private) Map<String,Integer> |
racksToIndex |
private RegionLocationFinder |
regionFinder |
(package private) int[] |
regionIndexToPrimaryIndex |
(package private) int[] |
regionIndexToServerIndex |
(package private) int[] |
regionIndexToTableIndex |
(package private) Deque<BalancerRegionLoad>[] |
regionLoads |
(package private) int[][] |
regionLocations |
(package private) RegionInfo[] |
regions |
(package private) int[][] |
regionsPerHost |
(package private) int[][] |
regionsPerRack |
(package private) int[][] |
regionsPerServer |
(package private) Map<RegionInfo,Integer> |
regionsToIndex |
private int[][] |
regionsToMostLocalEntities |
(package private) int[] |
serverIndexToHostIndex |
(package private) int[] |
serverIndexToRackIndex |
(package private) Integer[] |
serverIndicesSortedByLocality |
(package private) Integer[] |
serverIndicesSortedByRegionCount |
(package private) ServerName[] |
servers |
(package private) int[][] |
serversPerHost |
(package private) int[][] |
serversPerRack |
(package private) Map<String,Integer> |
serversToIndex |
(package private) ArrayList<String> |
tables |
(package private) Map<String,Integer> |
tablesToIndex |
Modifier | Constructor and Description |
---|---|
protected |
Cluster(Collection<RegionInfo> unassignedRegions,
Map<ServerName,List<RegionInfo>> clusterState,
Map<String,Deque<BalancerRegionLoad>> loads,
RegionLocationFinder regionFinder,
RackManager rackManager) |
protected |
Cluster(Map<ServerName,List<RegionInfo>> clusterState,
Map<String,Deque<BalancerRegionLoad>> loads,
RegionLocationFinder regionFinder,
RackManager rackManager) |
Modifier and Type | Method and Description |
---|---|
(package private) int[] |
addRegion(int[] regions,
int regionIndex) |
(package private) int[] |
addRegionSorted(int[] regions,
int regionIndex) |
private void |
computeCachedLocalities()
Computes and caches the locality for each region/rack combinations,
as well as storing a mapping of region -> server and region -> rack such that server
and rack have the highest locality for region
|
(package private) boolean |
contains(int[] arr,
int val) |
void |
doAction(BaseLoadBalancer.Cluster.Action action) |
(package private) void |
doAssignRegion(RegionInfo regionInfo,
ServerName serverName) |
(package private) float |
getLocalityOfRegion(int region,
int server) |
(package private) int |
getLowestLocalityRegionOnServer(int serverIndex) |
(package private) int |
getNumRegions(int server) |
float |
getOrComputeLocality(int region,
int entity,
BaseLoadBalancer.Cluster.LocalityType type)
Looks up locality from cache of localities.
|
float[][] |
getOrComputeRackLocalities()
Retrieves and lazily initializes a field storing the locality of
every region/server combination
|
int[] |
getOrComputeRegionsToMostLocalEntities(BaseLoadBalancer.Cluster.LocalityType type)
Lazily initializes and retrieves a mapping of region -> server for which region has
the highest the locality
|
double |
getOrComputeWeightedLocality(int region,
int server,
BaseLoadBalancer.Cluster.LocalityType type)
Returns locality weighted by region size in MB.
|
int |
getRackForRegion(int region)
Maps region index to rack index
|
int |
getRegionSizeMB(int region)
Returns the size in MB from the most recent RegionLoad for region
|
(package private) void |
regionMoved(int region,
int oldServer,
int newServer) |
private void |
registerRegion(RegionInfo region,
int regionIndex,
int serverIndex,
Map<String,Deque<BalancerRegionLoad>> loads,
RegionLocationFinder regionFinder)
Helper for Cluster constructor to handle a region
|
(package private) int[] |
removeRegion(int[] regions,
int regionIndex) |
(package private) int[] |
replaceRegion(int[] regions,
int regionIndex,
int newRegionIndex) |
boolean |
serverHasTooFewRegions(int server)
Returns true iff a given server has less regions than the balanced amount
|
protected void |
setNumMovedRegions(int numMovedRegions) |
protected void |
setNumRegions(int numRegions) |
(package private) void |
sortServersByRegionCount() |
String |
toString() |
(package private) boolean |
wouldLowerAvailability(RegionInfo regionInfo,
ServerName serverName)
Return true if the placement of region on server would lower the availability
of the region in question
|
ServerName[] servers
boolean multiServersPerHost
RegionInfo[] regions
Deque<BalancerRegionLoad>[] regionLoads
private RegionLocationFinder regionFinder
int[][] regionLocations
int[] serverIndexToHostIndex
int[] serverIndexToRackIndex
int[][] regionsPerServer
int[][] regionsPerHost
int[][] regionsPerRack
int[][] primariesOfRegionsPerServer
int[][] primariesOfRegionsPerHost
int[][] primariesOfRegionsPerRack
int[][] serversPerHost
int[][] serversPerRack
int[] regionIndexToServerIndex
int[] initialRegionIndexToServerIndex
int[] regionIndexToTableIndex
int[][] numRegionsPerServerPerTable
int[] numMaxRegionsPerTable
int[] regionIndexToPrimaryIndex
boolean hasRegionReplicas
Integer[] serverIndicesSortedByRegionCount
Integer[] serverIndicesSortedByLocality
Map<String,Integer> serversToIndex
Map<String,Integer> hostsToIndex
Map<String,Integer> racksToIndex
Map<String,Integer> tablesToIndex
Map<RegionInfo,Integer> regionsToIndex
float[] localityPerServer
int numServers
int numHosts
int numRacks
int numTables
int numRegions
int numMovedRegions
Map<ServerName,List<RegionInfo>> clusterState
protected final RackManager rackManager
private float[][] rackLocalities
private int[][] regionsToMostLocalEntities
public static final BaseLoadBalancer.Cluster.Action NullAction
private Comparator<Integer> numRegionsComparator
protected Cluster(Map<ServerName,List<RegionInfo>> clusterState, Map<String,Deque<BalancerRegionLoad>> loads, RegionLocationFinder regionFinder, RackManager rackManager)
protected Cluster(Collection<RegionInfo> unassignedRegions, Map<ServerName,List<RegionInfo>> clusterState, Map<String,Deque<BalancerRegionLoad>> loads, RegionLocationFinder regionFinder, RackManager rackManager)
private void registerRegion(RegionInfo region, int regionIndex, int serverIndex, Map<String,Deque<BalancerRegionLoad>> loads, RegionLocationFinder regionFinder)
public boolean serverHasTooFewRegions(int server)
public float[][] getOrComputeRackLocalities()
public int[] getOrComputeRegionsToMostLocalEntities(BaseLoadBalancer.Cluster.LocalityType type)
public float getOrComputeLocality(int region, int entity, BaseLoadBalancer.Cluster.LocalityType type)
public double getOrComputeWeightedLocality(int region, int server, BaseLoadBalancer.Cluster.LocalityType type)
public int getRegionSizeMB(int region)
private void computeCachedLocalities()
public int getRackForRegion(int region)
public void doAction(BaseLoadBalancer.Cluster.Action action)
boolean wouldLowerAvailability(RegionInfo regionInfo, ServerName serverName)
void doAssignRegion(RegionInfo regionInfo, ServerName serverName)
void regionMoved(int region, int oldServer, int newServer)
int[] removeRegion(int[] regions, int regionIndex)
int[] addRegion(int[] regions, int regionIndex)
int[] addRegionSorted(int[] regions, int regionIndex)
int[] replaceRegion(int[] regions, int regionIndex, int newRegionIndex)
void sortServersByRegionCount()
int getNumRegions(int server)
boolean contains(int[] arr, int val)
int getLowestLocalityRegionOnServer(int serverIndex)
float getLocalityOfRegion(int region, int server)
protected void setNumRegions(int numRegions)
protected void setNumMovedRegions(int numMovedRegions)
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.