Class CostFunction
java.lang.Object
org.apache.hadoop.hbase.master.balancer.CostFunction
- Direct Known Subclasses:
CacheAwareLoadBalancer.CacheAwareCostFunction
,CacheAwareLoadBalancer.CacheAwareRegionSkewnessCostFunction
,CostFromRegionLoadFunction
,HeterogeneousRegionCountCostFunction
,LocalityBasedCostFunction
,MoveCostFunction
,PrimaryRegionCountSkewCostFunction
,RegionCountSkewCostFunction
,RegionReplicaGroupingCostFunction
,TableSkewCostFunction
Base class of StochasticLoadBalancer's Cost Functions.
-
Field Summary
Modifier and TypeFieldDescriptionprotected BalancerClusterState
static final double
private float
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract double
cost()
(package private) float
(package private) boolean
isNeeded()
(package private) void
postAction
(BalanceAction action) Called once per cluster Action to give the cost function an opportunity to update it's state.(package private) void
prepare
(BalancerClusterState cluster) Called once per LB invocation to give the cost function to initialize it's state, and perform any costly calculation.protected void
regionMoved
(int region, int oldServer, int newServer) protected static double
scale
(double min, double max, double value) Scale the value between 0 and 1.(package private) void
setMultiplier
(float m) void
updateWeight
(double[] weights) Add the cost of this cost function to the weight of the candidate generator that is optimized for this cost function.
-
Field Details
-
COST_EPSILON
- See Also:
-
multiplier
-
cluster
-
-
Constructor Details
-
CostFunction
-
-
Method Details
-
isNeeded
boolean isNeeded() -
getMultiplier
float getMultiplier() -
setMultiplier
-
prepare
Called once per LB invocation to give the cost function to initialize it's state, and perform any costly calculation. -
postAction
Called once per cluster Action to give the cost function an opportunity to update it's state. postAction() is always called at least once before cost() is called with the cluster that this action is performed on. -
regionMoved
-
cost
-
updateWeight
Add 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.- Parameters:
weights
- the weights for every generator.
-
scale
Scale the value between 0 and 1.- Parameters:
min
- Min valuemax
- The Max valuevalue
- The value to be scaled.- Returns:
- The scaled value.
-