@InterfaceAudience.Private class BalancerClusterState extends Object
Modifier and Type | Class and Description |
---|---|
(package private) static class |
BalancerClusterState.DefaultRackManager |
(package private) static class |
BalancerClusterState.LocalityType |
Modifier and Type | Field and Description |
---|---|
(package private) Map<ServerName,List<RegionInfo>> |
clusterState |
(package private) org.agrona.collections.Int2IntCounterMap[] |
colocatedReplicaCountsPerHost |
(package private) org.agrona.collections.Int2IntCounterMap[] |
colocatedReplicaCountsPerRack |
(package private) org.agrona.collections.Int2IntCounterMap[] |
colocatedReplicaCountsPerServer |
(package private) boolean |
hasRegionReplicas |
(package private) String[] |
hosts |
(package private) Map<String,Integer> |
hostsToIndex |
(package private) int[] |
initialRegionIndexToServerIndex |
(package private) float[] |
localityPerServer |
private static org.slf4j.Logger |
LOG |
(package private) double[] |
meanRegionsPerTable |
(package private) boolean |
multiServersPerHost |
(package private) int |
numHosts |
(package private) int |
numMovedRegions |
(package private) int |
numRacks |
(package private) int |
numRegions |
private Comparator<Integer> |
numRegionsComparator |
(package private) int[][] |
numRegionsPerServerPerTable |
(package private) int[] |
numRegionsPerTable |
(package private) int |
numServers |
(package private) int |
numTables |
private float[][] |
rackLocalities |
private RackManager |
rackManager |
(package private) String[] |
racks |
(package private) Map<String,Integer> |
racksToIndex |
(package private) Map<String,Pair<ServerName,Float>> |
regionCacheRatioOnOldServerMap |
private RegionHDFSBlockLocationFinder |
regionFinder |
private Map<Pair<Integer,Integer>,Float> |
regionIndexServerIndexRegionCachedRatio |
(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 |
private int[] |
regionServerIndexWithBestRegionCachedRatio |
(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) int[] |
serverIndexToRegionsOffset |
(package private) Integer[] |
serverIndicesSortedByLocality |
(package private) Integer[] |
serverIndicesSortedByRegionCount |
(package private) ServerName[] |
servers |
(package private) int[][] |
serversPerHost |
(package private) int[][] |
serversPerRack |
(package private) Map<Address,Integer> |
serversToIndex |
(package private) ArrayList<String> |
tables |
(package private) Map<String,Integer> |
tablesToIndex |
Modifier | Constructor and Description |
---|---|
(package private) |
BalancerClusterState(Collection<RegionInfo> unassignedRegions,
Map<ServerName,List<RegionInfo>> clusterState,
Map<String,Deque<BalancerRegionLoad>> loads,
RegionHDFSBlockLocationFinder regionFinder,
RackManager rackManager,
Map<String,Pair<ServerName,Float>> oldRegionServerRegionCacheRatio) |
(package private) |
BalancerClusterState(Map<ServerName,List<RegionInfo>> clusterState,
Map<String,Deque<BalancerRegionLoad>> loads,
RegionHDFSBlockLocationFinder regionFinder,
RackManager rackManager) |
protected |
BalancerClusterState(Map<ServerName,List<RegionInfo>> clusterState,
Map<String,Deque<BalancerRegionLoad>> loads,
RegionHDFSBlockLocationFinder regionFinder,
RackManager rackManager,
Map<String,Pair<ServerName,Float>> oldRegionServerRegionCacheRatio) |
Modifier and Type | Method and Description |
---|---|
(package private) int[] |
addRegion(int[] regions,
int regionIndex) |
(package private) int[] |
addRegionSorted(int[] regions,
int regionIndex) |
private int |
checkLocationForPrimary(int location,
org.agrona.collections.Int2IntCounterMap[] colocatedReplicaCountsPerLocation,
int primary)
Common method for better solution check.
|
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
|
private void |
computeRegionServerRegionCacheRatio()
Populate the maps containing information about how much a region is cached on a region server.
|
(package private) boolean |
contains(int[] arr,
int val) |
void |
doAction(BalanceAction 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) |
Comparator<Integer> |
getNumRegionsComparator() |
float |
getOrComputeLocality(int region,
int entity,
BalancerClusterState.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
|
protected float |
getOrComputeRegionCacheRatio(int region,
int server) |
int[] |
getOrComputeRegionsToMostLocalEntities(BalancerClusterState.LocalityType type)
Lazily initializes and retrieves a mapping of region -> server for which region has the highest
the locality
|
int[] |
getOrComputeServerWithBestRegionCachedRatio() |
double |
getOrComputeWeightedLocality(int region,
int server,
BalancerClusterState.LocalityType type)
Returns locality weighted by region size in MB.
|
float |
getOrComputeWeightedRegionCacheRatio(int region,
int server)
Returns the weighted cache ratio of a region on the given region server
|
int |
getRackForRegion(int region)
Maps region index to rack index
|
protected float |
getRegionCacheRatioOnRegionServer(int region,
int regionServerIndex)
Returns the amount by which a region is cached on a given region server.
|
int |
getRegionSizeMB(int region)
Returns the size in MB from the most recent RegionLoad for region
|
int |
getTotalRegionHFileSizeMB(int region)
Returns the size of hFiles from the most recent RegionLoad for region
|
private void |
populateRegionPerLocationFromServer(int[][] regionsPerLocation,
org.agrona.collections.Int2IntCounterMap[] colocatedReplicaCountsPerLocation,
int[][] serversPerLocation) |
(package private) void |
regionMoved(int region,
int oldServer,
int newServer) |
private void |
registerRegion(RegionInfo region,
int regionIndex,
int serverIndex,
Map<String,Deque<BalancerRegionLoad>> loads,
RegionHDFSBlockLocationFinder 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
|
(package private) void |
setNumMovedRegions(int numMovedRegions) |
(package private) void |
setNumRegions(int numRegions) |
(package private) void |
sortServersByRegionCount() |
String |
toString() |
private void |
updateForLocation(int[] serverIndexToLocation,
int[][] regionsPerLocation,
org.agrona.collections.Int2IntCounterMap[] colocatedReplicaCountsPerLocation,
int oldServer,
int newServer,
int primary,
int region)
Common method for per host and per Location region index updates when a region is moved.
|
(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
|
private static final org.slf4j.Logger LOG
ServerName[] servers
boolean multiServersPerHost
RegionInfo[] regions
Deque<BalancerRegionLoad>[] regionLoads
private RegionHDFSBlockLocationFinder regionFinder
int[][] regionLocations
int[] serverIndexToHostIndex
int[] serverIndexToRackIndex
int[][] regionsPerServer
int[] serverIndexToRegionsOffset
int[][] regionsPerHost
int[][] regionsPerRack
org.agrona.collections.Int2IntCounterMap[] colocatedReplicaCountsPerServer
org.agrona.collections.Int2IntCounterMap[] colocatedReplicaCountsPerHost
org.agrona.collections.Int2IntCounterMap[] colocatedReplicaCountsPerRack
int[][] serversPerHost
int[][] serversPerRack
int[] regionIndexToServerIndex
int[] initialRegionIndexToServerIndex
int[] regionIndexToTableIndex
int[][] numRegionsPerServerPerTable
int[] numRegionsPerTable
double[] meanRegionsPerTable
int[] regionIndexToPrimaryIndex
boolean hasRegionReplicas
Integer[] serverIndicesSortedByRegionCount
Integer[] serverIndicesSortedByLocality
Map<Address,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
private final RackManager rackManager
private float[][] rackLocalities
private int[][] regionsToMostLocalEntities
private Map<Pair<Integer,Integer>,Float> regionIndexServerIndexRegionCachedRatio
private int[] regionServerIndexWithBestRegionCachedRatio
Map<String,Pair<ServerName,Float>> regionCacheRatioOnOldServerMap
private Comparator<Integer> numRegionsComparator
BalancerClusterState(Map<ServerName,List<RegionInfo>> clusterState, Map<String,Deque<BalancerRegionLoad>> loads, RegionHDFSBlockLocationFinder regionFinder, RackManager rackManager)
protected BalancerClusterState(Map<ServerName,List<RegionInfo>> clusterState, Map<String,Deque<BalancerRegionLoad>> loads, RegionHDFSBlockLocationFinder regionFinder, RackManager rackManager, Map<String,Pair<ServerName,Float>> oldRegionServerRegionCacheRatio)
BalancerClusterState(Collection<RegionInfo> unassignedRegions, Map<ServerName,List<RegionInfo>> clusterState, Map<String,Deque<BalancerRegionLoad>> loads, RegionHDFSBlockLocationFinder regionFinder, RackManager rackManager, Map<String,Pair<ServerName,Float>> oldRegionServerRegionCacheRatio)
private void populateRegionPerLocationFromServer(int[][] regionsPerLocation, org.agrona.collections.Int2IntCounterMap[] colocatedReplicaCountsPerLocation, int[][] serversPerLocation)
private void registerRegion(RegionInfo region, int regionIndex, int serverIndex, Map<String,Deque<BalancerRegionLoad>> loads, RegionHDFSBlockLocationFinder regionFinder)
public boolean serverHasTooFewRegions(int server)
public float[][] getOrComputeRackLocalities()
public int[] getOrComputeRegionsToMostLocalEntities(BalancerClusterState.LocalityType type)
public float getOrComputeLocality(int region, int entity, BalancerClusterState.LocalityType type)
public double getOrComputeWeightedLocality(int region, int server, BalancerClusterState.LocalityType type)
public int getRegionSizeMB(int region)
private void computeCachedLocalities()
public int getTotalRegionHFileSizeMB(int region)
public float getOrComputeWeightedRegionCacheRatio(int region, int server)
protected float getRegionCacheRatioOnRegionServer(int region, int regionServerIndex)
private void computeRegionServerRegionCacheRatio()
protected float getOrComputeRegionCacheRatio(int region, int server)
public int[] getOrComputeServerWithBestRegionCachedRatio()
public int getRackForRegion(int region)
public void doAction(BalanceAction action)
boolean wouldLowerAvailability(RegionInfo regionInfo, ServerName serverName)
private int checkLocationForPrimary(int location, org.agrona.collections.Int2IntCounterMap[] colocatedReplicaCountsPerLocation, int primary)
colocatedReplicaCountsPerLocation
- colocatedReplicaCountsPerHost or
colocatedReplicaCountsPerRackvoid doAssignRegion(RegionInfo regionInfo, ServerName serverName)
void regionMoved(int region, int oldServer, int newServer)
private void updateForLocation(int[] serverIndexToLocation, int[][] regionsPerLocation, org.agrona.collections.Int2IntCounterMap[] colocatedReplicaCountsPerLocation, int oldServer, int newServer, int primary, int region)
serverIndexToLocation
- serverIndexToHostIndex or serverIndexToLocationIndexregionsPerLocation
- regionsPerHost or regionsPerLocationcolocatedReplicaCountsPerLocation
- colocatedReplicaCountsPerHost or
colocatedReplicaCountsPerRackint[] 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)
public Comparator<Integer> getNumRegionsComparator()
int getLowestLocalityRegionOnServer(int serverIndex)
float getLocalityOfRegion(int region, int server)
void setNumRegions(int numRegions)
void setNumMovedRegions(int numMovedRegions)
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.