@InterfaceAudience.Private abstract class CostFunction extends Object
Modifier and Type | Field and Description |
---|---|
protected BalancerClusterState |
cluster |
static double |
COST_EPSILON |
private float |
multiplier |
Constructor and Description |
---|
CostFunction() |
Modifier and Type | Method and Description |
---|---|
protected abstract double |
cost() |
(package private) float |
getMultiplier() |
(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.
|
public static final double COST_EPSILON
private float multiplier
protected BalancerClusterState cluster
CostFunction()
boolean isNeeded()
float getMultiplier()
void setMultiplier(float m)
void prepare(BalancerClusterState cluster)
void postAction(BalanceAction action)
protected void regionMoved(int region, int oldServer, int newServer)
protected abstract double cost()
protected static double scale(double min, double max, double value)
min
- Min valuemax
- The Max valuevalue
- The value to be scaled.public void updateWeight(double[] weights)
weights
- the weights for every generator.Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.