Search in sources :

Example 71 with VM

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

the class CGather method getDSlices.

private List<Slice> getDSlices(ReconfigurationProblem rp) {
    List<Slice> dSlices = new ArrayList<>();
    for (VM vm : cstr.getInvolvedVMs()) {
        VMTransition a = rp.getVMAction(vm);
        Slice dSlice = a.getDSlice();
        if (dSlice != null) {
            dSlices.add(dSlice);
        }
    }
    return dSlices;
}
Also used : Slice(org.btrplace.scheduler.choco.Slice) VM(org.btrplace.model.VM) ArrayList(java.util.ArrayList) VMTransition(org.btrplace.scheduler.choco.transition.VMTransition)

Example 72 with VM

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

the class CLonely method continuousRestriction.

private static void continuousRestriction(ReconfigurationProblem rp, Collection<VM> vms, Set<VM> otherVMs) {
    // Get the position of all the others c-slices and their associated end moment
    TIntArrayList otherPos = new TIntArrayList();
    TIntArrayList minePos = new TIntArrayList();
    List<IntVar> otherEnds = new ArrayList<>();
    List<IntVar> mineEnds = new ArrayList<>();
    Mapping map = rp.getSourceModel().getMapping();
    for (Node n : map.getOnlineNodes()) {
        for (VM vm : map.getRunningVMs(n)) {
            if (!vms.contains(vm)) {
                otherPos.add(rp.getNode(map.getVMLocation(vm)));
                VMTransition a = rp.getVMAction(vm);
                otherEnds.add(a.getCSlice().getEnd());
            } else {
                minePos.add(rp.getNode(map.getVMLocation(vm)));
                VMTransition a = rp.getVMAction(vm);
                mineEnds.add(a.getCSlice().getEnd());
            }
        }
    }
    for (VM vm : vms) {
        VMTransition a = rp.getVMAction(vm);
        Precedences p = new Precedences(a.getDSlice().getHoster(), a.getDSlice().getStart(), otherPos.toArray(), otherEnds.toArray(new IntVar[otherEnds.size()]));
        rp.getModel().post(p);
    }
    // TODO: The following reveals a model problem. Too many constraints!!
    for (VM vm : otherVMs) {
        VMTransition a = rp.getVMAction(vm);
        Precedences p = new Precedences(a.getDSlice().getHoster(), a.getDSlice().getStart(), minePos.toArray(), mineEnds.toArray(new IntVar[mineEnds.size()]));
        rp.getModel().post(p);
    }
}
Also used : Precedences(org.btrplace.scheduler.choco.extensions.Precedences) Node(org.btrplace.model.Node) VM(org.btrplace.model.VM) TIntArrayList(gnu.trove.list.array.TIntArrayList) ArrayList(java.util.ArrayList) VMTransition(org.btrplace.scheduler.choco.transition.VMTransition) Mapping(org.btrplace.model.Mapping) IntVar(org.chocosolver.solver.variables.IntVar) TIntArrayList(gnu.trove.list.array.TIntArrayList)

Example 73 with VM

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

the class CLonely method getMisPlacedVMs.

@Override
public Set<VM> getMisPlacedVMs(Instance i) {
    Set<VM> bad = new HashSet<>();
    Set<Node> hosts = new HashSet<>();
    Collection<VM> vms = cstr.getInvolvedVMs();
    Mapping map = i.getModel().getMapping();
    for (VM vm : vms) {
        if (map.isRunning(vm)) {
            hosts.add(map.getVMLocation(vm));
        }
    }
    for (Node n : hosts) {
        // is a bad node. All the hosted VMs are candidate for relocation. Not optimal, but safe
        for (VM vm : map.getRunningVMs(n)) {
            if (!vms.contains(vm)) {
                bad.addAll(map.getRunningVMs(n));
                break;
            }
        }
    }
    return bad;
}
Also used : VM(org.btrplace.model.VM) Node(org.btrplace.model.Node) Mapping(org.btrplace.model.Mapping) HashSet(java.util.HashSet)

Example 74 with VM

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

the class CResourceCapacity method getMisPlacedVMs.

@Override
public Set<VM> getMisPlacedVMs(Instance i) {
    if (cstr.getInvolvedNodes().size() <= 1) {
        // If there is only a single node, we delegate this work to CShareableResource.
        return Collections.emptySet();
    }
    Mapping map = i.getModel().getMapping();
    ShareableResource rc = ShareableResource.get(i.getModel(), cstr.getResource());
    if (rc == null) {
        return map.getRunningVMs(cstr.getInvolvedNodes());
    }
    Set<VM> bad = new HashSet<>();
    int remainder = cstr.getAmount();
    for (Node n : cstr.getInvolvedNodes()) {
        for (VM v : map.getRunningVMs(n)) {
            remainder -= rc.getConsumption(v);
            if (remainder < 0) {
                for (Node n2 : cstr.getInvolvedNodes()) {
                    bad.addAll(map.getRunningVMs(n2));
                }
                return bad;
            }
        }
    }
    return bad;
}
Also used : VM(org.btrplace.model.VM) Node(org.btrplace.model.Node) Mapping(org.btrplace.model.Mapping) CShareableResource(org.btrplace.scheduler.choco.view.CShareableResource) ShareableResource(org.btrplace.model.view.ShareableResource) HashSet(java.util.HashSet)

Example 75 with VM

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

the class CRoot method inject.

@Override
public boolean inject(Parameters ps, ReconfigurationProblem rp) throws SchedulerException {
    VM vm = cstr.getInvolvedVMs().iterator().next();
    VMTransition m = rp.getVMAction(vm);
    Slice cSlice = m.getCSlice();
    Slice dSlice = m.getDSlice();
    if (cSlice != null && dSlice != null) {
        try {
            dSlice.getHoster().instantiateTo(cSlice.getHoster().getValue(), Cause.Null);
        } catch (ContradictionException ex) {
            Node n = rp.getSourceModel().getMapping().getVMLocation(vm);
            rp.getLogger().error("Unable to force '" + vm + "' to be running on node '" + n + "'", ex);
            return false;
        }
    }
    return true;
}
Also used : Slice(org.btrplace.scheduler.choco.Slice) ContradictionException(org.chocosolver.solver.exception.ContradictionException) VM(org.btrplace.model.VM) Node(org.btrplace.model.Node) VMTransition(org.btrplace.scheduler.choco.transition.VMTransition)

Aggregations

VM (org.btrplace.model.VM)192 Node (org.btrplace.model.Node)110 Model (org.btrplace.model.Model)92 DefaultModel (org.btrplace.model.DefaultModel)91 Test (org.testng.annotations.Test)91 Mapping (org.btrplace.model.Mapping)64 HashSet (java.util.HashSet)58 ArrayList (java.util.ArrayList)43 SatConstraint (org.btrplace.model.constraint.SatConstraint)40 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)39 VMTransition (org.btrplace.scheduler.choco.transition.VMTransition)35 IntVar (org.chocosolver.solver.variables.IntVar)35 ShareableResource (org.btrplace.model.view.ShareableResource)32 RelocatableVM (org.btrplace.scheduler.choco.transition.RelocatableVM)27 MigrateVM (org.btrplace.plan.event.MigrateVM)25 DefaultChocoScheduler (org.btrplace.scheduler.choco.DefaultChocoScheduler)17 StayAwayVM (org.btrplace.scheduler.choco.transition.StayAwayVM)17 Slice (org.btrplace.scheduler.choco.Slice)16 BootVM (org.btrplace.scheduler.choco.transition.BootVM)16 BootableNode (org.btrplace.scheduler.choco.transition.BootableNode)16