Search in sources :

Example 11 with Mapping

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

the class IssuesTest method issue72b.

@Test
public void issue72b() throws SchedulerException {
    Model mo = new DefaultModel();
    Mapping ma = mo.getMapping();
    ShareableResource rcCPU = new ShareableResource("cpu", 2, 0);
    mo.attach(rcCPU);
    List<Node> nodes = new ArrayList<>();
    for (int i = 0; i < 2; i++) {
        nodes.add(mo.newNode());
        ma.addOnlineNode(nodes.get(i));
    }
    for (int i = 0; i < 1; i++) {
        VM v = mo.newVM();
        ma.addRunningVM(v, nodes.get(0));
    }
    for (int i = 0; i < 2; i++) {
        VM v = mo.newVM();
        ma.addRunningVM(v, nodes.get(1));
    }
    DefaultParameters ps = new DefaultParameters();
    ReconfigurationPlan p = new DefaultChocoScheduler(ps).solve(mo, new ArrayList<>());
    Assert.assertNotNull(p);
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Node(org.btrplace.model.Node) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) ArrayList(java.util.ArrayList) Mapping(org.btrplace.model.Mapping) ShareableResource(org.btrplace.model.view.ShareableResource) OptConstraint(org.btrplace.model.constraint.OptConstraint) Constraint(org.chocosolver.solver.constraints.Constraint) SatConstraint(org.btrplace.model.constraint.SatConstraint) VM(org.btrplace.model.VM) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Test(org.testng.annotations.Test)

Example 12 with Mapping

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

the class MaxOnlineChecker method startsWith.

@Override
public boolean startsWith(Model mo) {
    if (getConstraint().isContinuous()) {
        Mapping map = mo.getMapping();
        currentOnline = 0;
        for (Node n : getConstraint().getInvolvedNodes()) {
            if (map.isOnline(n)) {
                currentOnline++;
            }
        }
        return currentOnline <= getConstraint().getAmount();
    }
    return true;
}
Also used : Node(org.btrplace.model.Node) ShutdownNode(org.btrplace.plan.event.ShutdownNode) BootNode(org.btrplace.plan.event.BootNode) Mapping(org.btrplace.model.Mapping)

Example 13 with Mapping

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

the class QuarantineChecker method startsWith.

@Override
public boolean startsWith(Model mo) {
    Mapping map = mo.getMapping();
    getVMs().clear();
    return getVMs().addAll(map.getRunningVMs(getNodes()));
}
Also used : Mapping(org.btrplace.model.Mapping)

Example 14 with Mapping

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

the class ResourceCapacityChecker method startsWith.

@Override
public boolean startsWith(Model mo) {
    if (getConstraint().isContinuous()) {
        rc = ShareableResource.get(mo, getConstraint().getResource());
        free = getConstraint().getAmount();
        Mapping map = mo.getMapping();
        for (Node n : getNodes()) {
            free -= rc.sumConsumptions(map.getRunningVMs(n), true);
            if (free < 0) {
                return false;
            }
        }
    }
    return true;
}
Also used : Node(org.btrplace.model.Node) Mapping(org.btrplace.model.Mapping)

Example 15 with Mapping

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

the class RunningCapacityChecker method endsWith.

@Override
public boolean endsWith(Model mo) {
    int nb = 0;
    Mapping map = mo.getMapping();
    for (Node n : getNodes()) {
        nb += map.getRunningVMs(n).size();
        if (nb > qty) {
            return false;
        }
    }
    return true;
}
Also used : Node(org.btrplace.model.Node) 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