Search in sources :

Example 11 with ContradictionException

use of org.chocosolver.solver.exception.ContradictionException in project scheduler by btrplace.

the class CQuarantine method inject.

@Override
public boolean inject(Parameters ps, ReconfigurationProblem rp) throws SchedulerException {
    // It is just a composition of a root constraint on the VMs on the given nodes (the zone)
    // plus a ban on the other VMs to prevent them for being hosted in the zone
    Mapping map = rp.getSourceModel().getMapping();
    Node n = cstr.getInvolvedNodes().iterator().next();
    int nIdx = rp.getNode(n);
    for (VM vm : rp.getFutureRunningVMs()) {
        if (n.equals(map.getVMLocation(vm))) {
            IntVar d = rp.getVMAction(vm).getDSlice().getHoster();
            try {
                d.instantiateTo(nIdx, Cause.Null);
            } catch (ContradictionException e) {
                rp.getLogger().error("Unable to root " + vm + " on " + n, e);
                return false;
            }
        } else {
            IntVar d = rp.getVMAction(vm).getDSlice().getHoster();
            try {
                d.removeValue(nIdx, Cause.Null);
            } catch (ContradictionException e) {
                rp.getLogger().error("Unable to disallow " + vm + " to be hosted on " + n, e);
                return false;
            }
        }
    }
    return true;
}
Also used : ContradictionException(org.chocosolver.solver.exception.ContradictionException) Node(org.btrplace.model.Node) VM(org.btrplace.model.VM) Mapping(org.btrplace.model.Mapping) IntVar(org.chocosolver.solver.variables.IntVar)

Aggregations

ContradictionException (org.chocosolver.solver.exception.ContradictionException)11 Node (org.btrplace.model.Node)9 VM (org.btrplace.model.VM)6 Slice (org.btrplace.scheduler.choco.Slice)4 VMTransition (org.btrplace.scheduler.choco.transition.VMTransition)4 SatConstraint (org.btrplace.model.constraint.SatConstraint)3 IntVar (org.chocosolver.solver.variables.IntVar)3 NodeTransition (org.btrplace.scheduler.choco.transition.NodeTransition)2 RelocatableVM (org.btrplace.scheduler.choco.transition.RelocatableVM)2 HashSet (java.util.HashSet)1 Attributes (org.btrplace.model.Attributes)1 Mapping (org.btrplace.model.Mapping)1 Model (org.btrplace.model.Model)1 Killed (org.btrplace.model.constraint.Killed)1 Ready (org.btrplace.model.constraint.Ready)1 Running (org.btrplace.model.constraint.Running)1 Sleeping (org.btrplace.model.constraint.Sleeping)1 SchedulerModelingException (org.btrplace.scheduler.SchedulerModelingException)1 DefaultReconfigurationProblemBuilder (org.btrplace.scheduler.choco.DefaultReconfigurationProblemBuilder)1 ReconfigurationProblem (org.btrplace.scheduler.choco.ReconfigurationProblem)1