public class BalancedHostAttrConstraint extends java.lang.Object implements ConstraintEvaluator
ConstraintEvaluator.Result
Constructor and Description |
---|
BalancedHostAttrConstraint(Func1<java.lang.String,java.util.Set<java.lang.String>> coTasksGetter,
java.lang.String hostAttributeName,
int expectedValues)
Create a constraint evaluator to balance tasks across hosts based on a given host attribute.
|
Modifier and Type | Method and Description |
---|---|
VMTaskFitnessCalculator |
asSoftConstraint()
Converts this constraint into a "soft" constraint.
|
ConstraintEvaluator.Result |
evaluate(TaskRequest taskRequest,
VirtualMachineCurrentState targetVM,
TaskTrackerState taskTrackerState)
Inspects a target to decide whether or not it meets the constraints appropriate to a particular task.
|
java.lang.String |
getName()
Returns the name of the balanced host attribute constraint, which takes the form of the name of the
class (or subclass) followed by a dash followed by the value of
hostAttributeName as it was set
when the constraint object was created. |
public BalancedHostAttrConstraint(Func1<java.lang.String,java.util.Set<java.lang.String>> coTasksGetter, java.lang.String hostAttributeName, int expectedValues)
coTasksGetter
- a one-argument function that, given a task ID being considered for assignment,
returns the set of Task IDs of the tasks that form the group of tasks which need to
be balancedhostAttributeName
- the name of the host attribute whose values need to be balanced across the
co-tasksexpectedValues
- the number of distinct values to expect for hostAttributeName
public java.lang.String getName()
hostAttributeName
as it was set
when the constraint object was created.getName
in interface ConstraintEvaluator
public ConstraintEvaluator.Result evaluate(TaskRequest taskRequest, VirtualMachineCurrentState targetVM, TaskTrackerState taskTrackerState)
ConstraintEvaluator
evaluate
in interface ConstraintEvaluator
taskRequest
- a description of the task to be assignedtargetVM
- a description of the host that is a potential match for the tasktaskTrackerState
- the current status of tasks and task assignments in the system at largepublic VMTaskFitnessCalculator asSoftConstraint()
VMTaskFitnessCalculator
that represents this constraint as a "soft" constraint that will permit
Fenzo to place a task in violation of the constraint if it cannot do so otherwise.