public class AsSoftConstraint
extends java.lang.Object
ConstraintEvaluator
is by default a "hard," or
mandatory constraint. Fenzo will not place a task with a target that fails such a constraint, and will not
place the task at all if no target passes the constraint. You can convert such a "hard" constraint into a
"soft" constraint by passing it into the get(com.netflix.fenzo.ConstraintEvaluator)
method of this class. That method returns a
VMTaskFitnessCalculator
that implements a "soft" constraint. When Fenzo uses such a constraint, it
will attempt to place a task with a target that satisfies the constraint, but will place the task with a
target that fails the constraint if no other target can be found.
The resulting "soft" constraint will return evaluate a host/task combination as 0.0 if the underlying hard constraint would be violated, or 1.0 if the underlying hard constraint would be satisfied.
Note that some hard constraints may implement their own hard-to-soft conversion methods and that these
methods may return a soft constraint that is more nuanced, returning values between 0.0 and 1.0 and not just
those two values at either extreme (see, for example,
BalancedHostAttrConstraint
).
Constructor and Description |
---|
AsSoftConstraint() |
Modifier and Type | Method and Description |
---|---|
static VMTaskFitnessCalculator |
get(ConstraintEvaluator c)
Returns a "soft" constraint, in the form of a
VMTaskFitnessCalculator , based on a specified "hard"
constraint, in the form of a ConstraintEvaluator . |
public static VMTaskFitnessCalculator get(ConstraintEvaluator c)
VMTaskFitnessCalculator
, based on a specified "hard"
constraint, in the form of a ConstraintEvaluator
.c
- the "hard" constraint to convertc