Search in sources :

Example 76 with Mapping

use of org.btrplace.model.Mapping in project scheduler by btrplace.

the class CFence method getMisPlacedVMs.

@Override
public Set<VM> getMisPlacedVMs(Instance i) {
    Mapping map = i.getModel().getMapping();
    VM vm = cstr.getInvolvedVMs().iterator().next();
    if (map.isRunning(vm) && !cstr.getInvolvedNodes().contains(map.getVMLocation(vm))) {
        return Collections.singleton(vm);
    }
    return Collections.emptySet();
}
Also used : VM(org.btrplace.model.VM) Mapping(org.btrplace.model.Mapping)

Example 77 with Mapping

use of org.btrplace.model.Mapping in project scheduler by btrplace.

the class CKilled method getMisPlacedVMs.

@Override
public Set<VM> getMisPlacedVMs(Instance i) {
    Mapping map = i.getModel().getMapping();
    VM v = cstr.getInvolvedVMs().iterator().next();
    if (map.contains(v)) {
        return Collections.singleton(v);
    }
    return Collections.emptySet();
}
Also used : VM(org.btrplace.model.VM) Mapping(org.btrplace.model.Mapping)

Example 78 with Mapping

use of org.btrplace.model.Mapping 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)

Example 79 with Mapping

use of org.btrplace.model.Mapping in project scheduler by btrplace.

the class CReady method getMisPlacedVMs.

@Override
public Set<VM> getMisPlacedVMs(Instance i) {
    VM v = cstr.getInvolvedVMs().iterator().next();
    Mapping map = i.getModel().getMapping();
    if (!map.isReady(v)) {
        return Collections.singleton(v);
    }
    return Collections.emptySet();
}
Also used : VM(org.btrplace.model.VM) Mapping(org.btrplace.model.Mapping)

Example 80 with Mapping

use of org.btrplace.model.Mapping in project scheduler by btrplace.

the class CRunning method getMisPlacedVMs.

@Override
public Set<VM> getMisPlacedVMs(Instance i) {
    VM vm = cstr.getInvolvedVMs().iterator().next();
    Mapping map = i.getModel().getMapping();
    if (!map.isRunning(vm)) {
        return Collections.singleton(vm);
    }
    return Collections.emptySet();
}
Also used : VM(org.btrplace.model.VM) Mapping(org.btrplace.model.Mapping)

Aggregations

Mapping (org.btrplace.model.Mapping)83 Node (org.btrplace.model.Node)68 VM (org.btrplace.model.VM)62 Model (org.btrplace.model.Model)42 DefaultModel (org.btrplace.model.DefaultModel)39 Test (org.testng.annotations.Test)39 HashSet (java.util.HashSet)29 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)23 ShareableResource (org.btrplace.model.view.ShareableResource)16 RelocatableVM (org.btrplace.scheduler.choco.transition.RelocatableVM)16 BootableNode (org.btrplace.scheduler.choco.transition.BootableNode)15 ShutdownableNode (org.btrplace.scheduler.choco.transition.ShutdownableNode)15 VMTransition (org.btrplace.scheduler.choco.transition.VMTransition)15 IntVar (org.chocosolver.solver.variables.IntVar)15 SatConstraint (org.btrplace.model.constraint.SatConstraint)14 BootVM (org.btrplace.scheduler.choco.transition.BootVM)14 ForgeVM (org.btrplace.scheduler.choco.transition.ForgeVM)14 KillVM (org.btrplace.scheduler.choco.transition.KillVM)14 ResumeVM (org.btrplace.scheduler.choco.transition.ResumeVM)14 ShutdownVM (org.btrplace.scheduler.choco.transition.ShutdownVM)14