Search in sources :

Example 91 with VM

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

the class MovingVMs method setToNextMovingVM.

@SuppressWarnings("squid:S3346")
private boolean setToNextMovingVM(IntVar[] scopes) {
    assert actions.size() == scopes.length;
    for (int i = idx.get(); i < scopes.length; i++) {
        IntVar h = scopes[i];
        if (!h.isInstantiated()) {
            VM vm = actions.get(i).getVM();
            Node nId = map.getVMLocation(vm);
            if (!h.contains(rp.getNode(nId))) {
                // VM was running, otherwise -1 so not inside h
                idx.set(i);
                return true;
            }
        }
        i++;
    }
    return false;
}
Also used : VM(org.btrplace.model.VM) Node(org.btrplace.model.Node) IntVar(org.chocosolver.solver.variables.IntVar)

Example 92 with VM

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

the class RandomVMPlacement method selectValue.

@Override
public int selectValue(IntVar x) {
    if (stay) {
        VM vm = vmPlacement.get(x);
        int nIdx = canStay(rp, vm);
        if (nIdx >= 0) {
            Node n = rp.getSourceModel().getMapping().getVMLocation(vm);
            return nodeMap[n.id()];
        }
    }
    if (!x.isInstantiated()) {
        int nIdx;
        if (ranks != null) {
            nIdx = randomWithRankedValues(x);
        } else {
            nIdx = randomValue(x);
        }
        return nIdx;
    }
    return x.getValue();
}
Also used : VM(org.btrplace.model.VM) Node(org.btrplace.model.Node)

Example 93 with VM

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

the class VMPlacementUtils method makePlacementMap.

/**
 * Map a map where keys are the placement variable of the future-running VMs
 * and values are the VM identifier.
 *
 * @param rp the problem
 * @return the resulting map.
 */
public static Map<IntVar, VM> makePlacementMap(ReconfigurationProblem rp) {
    Map<IntVar, VM> m = new HashMap<>(rp.getFutureRunningVMs().size());
    for (VM vm : rp.getFutureRunningVMs()) {
        IntVar v = rp.getVMAction(vm).getDSlice().getHoster();
        m.put(v, vm);
    }
    return m;
}
Also used : HashMap(java.util.HashMap) VM(org.btrplace.model.VM) IntVar(org.chocosolver.solver.variables.IntVar)

Example 94 with VM

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

the class WorstFit method selectValue.

@Override
public int selectValue(IntVar v) {
    VM vm = vmMap.get(v);
    if (stayFirst && canStay(vm)) {
        return rp.getNode(rp.getSourceModel().getMapping().getVMLocation(vm));
    }
    // Get the load
    int leastId = v.getLB();
    double minLoad = 2;
    IStateInt[] loads = new IStateInt[rcs.size()];
    for (int nId = v.getLB(); nId <= v.getUB(); nId = v.nextValue(nId)) {
        for (int d = 0; d < rcs.size(); d++) {
            loads[d] = packing.assignedLoad()[d][nId];
        }
        double global = loadWith(nId, loads, vm);
        if (global < minLoad) {
            leastId = nId;
            minLoad = global;
        }
    }
    return leastId;
}
Also used : VM(org.btrplace.model.VM) IStateInt(org.chocosolver.memory.IStateInt)

Example 95 with VM

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

the class InstanceSolverRunner method checkUnknownVMsInMapping.

private static void checkUnknownVMsInMapping(Model m, Collection<VM> vms) throws SchedulerException {
    for (VM v : vms) {
        // This loop prevent from a useless allocation of memory when there is no issue
        if (!m.getMapping().contains(v)) {
            Set<VM> unknown = new HashSet<>(vms);
            unknown.removeAll(m.getMapping().getAllVMs());
            throw new SchedulerModelingException(m, "Unknown VMs: " + unknown);
        }
    }
}
Also used : VM(org.btrplace.model.VM) SchedulerModelingException(org.btrplace.scheduler.SchedulerModelingException) HashSet(java.util.HashSet)

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