Class LocalityBasedCostFunction
java.lang.Object
org.apache.hadoop.hbase.master.balancer.CostFunction
org.apache.hadoop.hbase.master.balancer.LocalityBasedCostFunction
- Direct Known Subclasses:
RackLocalityCostFunction,ServerLocalityCostFunction
Compute a cost of a potential cluster configuration based upon where
HStoreFiles are located.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate doubleprivate doubleprivate final BalancerClusterState.LocalityTypeFields inherited from class org.apache.hadoop.hbase.master.balancer.CostFunction
cluster -
Constructor Summary
ConstructorsConstructorDescriptionLocalityBasedCostFunction(org.apache.hadoop.conf.Configuration conf, BalancerClusterState.LocalityType type, String localityCostKey, float defaultLocalityCost) -
Method Summary
Modifier and TypeMethodDescriptionprotected final doublecost()private intgetMostLocalEntityForRegion(int region) private doublegetWeightedLocality(int region, int entity) (package private) voidprepare(BalancerClusterState cluster) Called once per LB invocation to give the cost function to initialize it's state, and perform any costly calculation.(package private) abstract intregionIndexToEntityIndex(int region) Maps region to the current entity (server or rack) on which it is storedprotected voidregionMoved(int region, int oldServer, int newServer) final voidupdateWeight(Map<Class<? extends CandidateGenerator>, 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
getCostEpsilon, getMultiplier, isNeeded, postAction, scale, setMultiplier
-
Field Details
-
type
-
bestLocality
-
locality
-
-
Constructor Details
-
LocalityBasedCostFunction
LocalityBasedCostFunction(org.apache.hadoop.conf.Configuration conf, BalancerClusterState.LocalityType type, String localityCostKey, float defaultLocalityCost)
-
-
Method Details
-
regionIndexToEntityIndex
Maps region to the current entity (server or rack) on which it is stored -
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
-
regionMoved
- Overrides:
regionMovedin classCostFunction
-
cost
- Specified by:
costin classCostFunction
-
getMostLocalEntityForRegion
-
getWeightedLocality
-
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.
-