Search in sources :

Example 6 with Slice

use of org.btrplace.scheduler.choco.Slice in project scheduler by btrplace.

the class MovementGraph method make.

public void make() {
    incoming.clear();
    outgoings.clear();
    for (VMTransition a : rp.getVMActions()) {
        Slice cSlice = a.getCSlice();
        Slice dSlice = a.getDSlice();
        if (cSlice != null) {
            addOutgoing(cSlice);
        }
        if (dSlice != null) {
            addIncoming(dSlice);
        }
    }
}
Also used : Slice(org.btrplace.scheduler.choco.Slice) VMTransition(org.btrplace.scheduler.choco.transition.VMTransition)

Example 7 with Slice

use of org.btrplace.scheduler.choco.Slice in project scheduler by btrplace.

the class AbstractCumulatives method inject.

@Override
public boolean inject(Parameters ps, ReconfigurationProblem rp) throws SchedulerException {
    cUsages = new ArrayList<>();
    dUsages = new ArrayList<>();
    List<Slice> dS = new ArrayList<>();
    List<Slice> cS = new ArrayList<>();
    non = new HashMap<>();
    int dIdx = 0;
    int cIdx = 0;
    for (VMTransition a : rp.getVMActions()) {
        Slice c = a.getCSlice();
        Slice d = a.getDSlice();
        if (d != null && c != null) {
            non.put(a.getVM(), new int[] { dIdx, cIdx });
        }
        if (d != null) {
            dS.add(dIdx, d);
            dIdx++;
        }
        if (c != null) {
            cS.add(cIdx, c);
            cIdx++;
        }
    }
    int i = 0;
    cHosts = new IntVar[cS.size()];
    cEnds = new IntVar[cS.size()];
    for (Slice s : cS) {
        cHosts[i] = s.getHoster();
        cEnds[i] = s.getEnd();
        i++;
    }
    i = 0;
    dStarts = new IntVar[dS.size()];
    dHosts = new IntVar[dS.size()];
    for (Slice s : dS) {
        dHosts[i] = s.getHoster();
        dStarts[i] = s.getStart();
        i++;
    }
    associations = makeAssociations();
    return true;
}
Also used : Slice(org.btrplace.scheduler.choco.Slice) ArrayList(java.util.ArrayList) VMTransition(org.btrplace.scheduler.choco.transition.VMTransition)

Example 8 with Slice

use of org.btrplace.scheduler.choco.Slice 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 9 with Slice

use of org.btrplace.scheduler.choco.Slice in project scheduler by btrplace.

the class COffline method inject.

@Override
public boolean inject(Parameters ps, ReconfigurationProblem rp) throws SchedulerException {
    if (cstr.isContinuous() && !cstr.getChecker().startsWith(rp.getSourceModel())) {
        rp.getLogger().error("Constraint {} is not satisfied initially", cstr);
        return false;
    }
    Node nId = cstr.getInvolvedNodes().iterator().next();
    int id = rp.getNode(nId);
    NodeTransition m = rp.getNodeAction(nId);
    try {
        m.getState().instantiateTo(0, Cause.Null);
        if (rp.getSourceModel().getMapping().isOffline(nId)) {
            m.getStart().instantiateTo(0, Cause.Null);
        }
    } catch (ContradictionException ex) {
        rp.getLogger().error("Unable to force node '" + nId + "' at being offline", ex);
        return false;
    }
    for (VMTransition am : rp.getVMActions()) {
        Slice s = am.getDSlice();
        if (s != null) {
            try {
                s.getHoster().removeValue(id, Cause.Null);
            } catch (ContradictionException e) {
                rp.getLogger().error("Unable to remove " + am.getVM() + " of node " + nId, e);
            }
        }
    }
    return true;
}
Also used : ContradictionException(org.chocosolver.solver.exception.ContradictionException) Slice(org.btrplace.scheduler.choco.Slice) Node(org.btrplace.model.Node) NodeTransition(org.btrplace.scheduler.choco.transition.NodeTransition) VMTransition(org.btrplace.scheduler.choco.transition.VMTransition)

Example 10 with Slice

use of org.btrplace.scheduler.choco.Slice 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

Slice (org.btrplace.scheduler.choco.Slice)22 VMTransition (org.btrplace.scheduler.choco.transition.VMTransition)17 VM (org.btrplace.model.VM)16 ArrayList (java.util.ArrayList)12 IntVar (org.chocosolver.solver.variables.IntVar)11 Node (org.btrplace.model.Node)8 List (java.util.List)6 TIntArrayList (gnu.trove.list.array.TIntArrayList)5 TObjectIntMap (gnu.trove.map.TObjectIntMap)5 Collections (java.util.Collections)5 HashSet (java.util.HashSet)5 Map (java.util.Map)5 Objects (java.util.Objects)5 Set (java.util.Set)5 Instance (org.btrplace.model.Instance)5 Mapping (org.btrplace.model.Mapping)5 Model (org.btrplace.model.Model)5 ShareableResource (org.btrplace.model.view.ShareableResource)5 SchedulerException (org.btrplace.scheduler.SchedulerException)5 Parameters (org.btrplace.scheduler.choco.Parameters)5