Class RegionReplicaGroupingCostFunction
java.lang.Object
org.apache.hadoop.hbase.master.balancer.CostFunction
org.apache.hadoop.hbase.master.balancer.RegionReplicaGroupingCostFunction
- Direct Known Subclasses:
RegionReplicaHostCostFunction,RegionReplicaRackCostFunction
A cost function for region replicas. We give a high cost for hosting replicas of the same region
in the same server, host or rack. We do not prevent the case though, since if numReplicas >
numRegionServers, we still want to keep the replica open.
-
Field Summary
FieldsFields inherited from class org.apache.hadoop.hbase.master.balancer.CostFunction
cluster, COST_EPSILON -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected doublecost()protected final longcostPerGroup(org.agrona.collections.Int2IntCounterMap colocatedReplicaCounts) For each primary region, it computes the total number of replicas in the array (numReplicas) and returns a sum of numReplicas-1 squared.protected final longgetMaxCost(BalancerClusterState cluster) (package private) booleanisNeeded()protected abstract void(package private) final voidprepare(BalancerClusterState cluster) Called once per LB invocation to give the cost function to initialize it's state, and perform any costly calculation.final voidupdateWeight(double[] weights) Add the cost of this cost function to the weight of the candidate generator that is optimized for this cost function.Methods inherited from class org.apache.hadoop.hbase.master.balancer.CostFunction
getMultiplier, postAction, regionMoved, scale, setMultiplier
-
Field Details
-
maxCost
-
costsPerGroup
-
-
Constructor Details
-
RegionReplicaGroupingCostFunction
-
-
Method Details
-
prepare
Description copied from class:CostFunctionCalled once per LB invocation to give the cost function to initialize it's state, and perform any costly calculation.- Overrides:
preparein classCostFunction
-
loadCosts
-
getMaxCost
-
isNeeded
boolean isNeeded()- Overrides:
isNeededin classCostFunction
-
cost
- Specified by:
costin classCostFunction
-
costPerGroup
For each primary region, it computes the total number of replicas in the array (numReplicas) and returns a sum of numReplicas-1 squared. For example, if the server hosts regions a, b, c, d, e, f where a and b are same replicas, and c,d,e are same replicas, it returns (2-1) * (2-1) + (3-1) * (3-1) + (1-1) * (1-1).- Parameters:
colocatedReplicaCounts- a sorted array of primary regions ids for the regions hosted- Returns:
- a sum of numReplicas-1 squared for each primary region in the group.
-
updateWeight
Description copied from class:CostFunctionAdd the cost of this cost function to the weight of the candidate generator that is optimized for this cost function. By default it is the RandomCandiateGenerator for a cost function. Called once per init or after postAction.- Overrides:
updateWeightin classCostFunction- Parameters:
weights- the weights for every generator.
-