Search in sources :

Example 6 with RunningCapacity

use of org.btrplace.model.constraint.RunningCapacity in project scheduler by btrplace.

the class RunningCapacityBuilder method buildConstraint.

@Override
public List<? extends SatConstraint> buildConstraint(BtrPlaceTree t, List<BtrpOperand> args) {
    if (!checkConformance(t, args)) {
        return Collections.emptyList();
    }
    @SuppressWarnings("unchecked") List<Node> ns = (List<Node>) params[0].transform(this, t, args.get(0));
    BtrpNumber n = (BtrpNumber) args.get(1);
    if (!n.isInteger()) {
        t.ignoreError("Parameter '" + params[1].getName() + "' expects an integer");
        return Collections.emptyList();
    }
    int v = n.getIntValue();
    if (v < 0) {
        t.ignoreError("Parameter '" + params[1].getName() + "' expects a positive integer (" + v + " given)");
        return Collections.emptyList();
    }
    return ns != null ? Collections.singletonList(new RunningCapacity(new HashSet<>(ns), v)) : Collections.emptyList();
}
Also used : RunningCapacity(org.btrplace.model.constraint.RunningCapacity) BtrpNumber(org.btrplace.btrpsl.element.BtrpNumber) Node(org.btrplace.model.Node) List(java.util.List) SatConstraint(org.btrplace.model.constraint.SatConstraint)

Aggregations

RunningCapacity (org.btrplace.model.constraint.RunningCapacity)6 DefaultModel (org.btrplace.model.DefaultModel)4 SatConstraint (org.btrplace.model.constraint.SatConstraint)4 Model (org.btrplace.model.Model)3 Test (org.testng.annotations.Test)3 Node (org.btrplace.model.Node)2 VM (org.btrplace.model.VM)2 Gather (org.btrplace.model.constraint.Gather)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ScriptBuilder (org.btrplace.btrpsl.ScriptBuilder)1 BtrpNumber (org.btrplace.btrpsl.element.BtrpNumber)1 Instance (org.btrplace.model.Instance)1 MinMTTR (org.btrplace.model.constraint.MinMTTR)1 Running (org.btrplace.model.constraint.Running)1 Split (org.btrplace.model.constraint.Split)1 Spread (org.btrplace.model.constraint.Spread)1 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)1 BootVM (org.btrplace.plan.event.BootVM)1 MigrateVM (org.btrplace.plan.event.MigrateVM)1