@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) boolean |
multiServersPerHost |
(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[] |
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 |
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) 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 |
Constructor and Description |
---|
BalancerClusterState(Collection<RegionInfo> unassignedRegions,
Map<ServerName,List<RegionInfo>> clusterState,
Map<String,Deque<BalancerRegionLoad>> loads,
RegionLocationFinder regionFinder,
RackManager rackManager) |
BalancerClusterState(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 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
|
(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
|
int[] |
getOrComputeRegionsToMostLocalEntities(BalancerClusterState.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,
BalancerClusterState.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
|
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,
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
|
(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 RegionLocationFinder 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
int[] numMaxRegionsPerTable
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 Comparator<Integer> numRegionsComparator
BalancerClusterState(Map<ServerName,List<RegionInfo>> clusterState, Map<String,Deque<BalancerRegionLoad>> loads, RegionLocationFinder regionFinder, RackManager rackManager)
BalancerClusterState(Collection<RegionInfo> unassignedRegions, Map<ServerName,List<RegionInfo>> clusterState, Map<String,Deque<BalancerRegionLoad>> loads, RegionLocationFinder regionFinder, RackManager rackManager)
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, RegionLocationFinder 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 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)
public Comparator<Integer> getNumRegionsComparator()
boolean contains(int[] arr, int val)
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.