Search in sources :

Example 36 with Mapping

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

the class CRunningCapacity method getMisPlacedVMs.

@Override
public Set<VM> getMisPlacedVMs(Instance i) {
    Mapping map = i.getModel().getMapping();
    Set<VM> bad = new HashSet<>();
    int remainder = cstr.getAmount();
    for (Node n : cstr.getInvolvedNodes()) {
        remainder -= map.getRunningVMs(n).size();
        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) HashSet(java.util.HashSet)

Example 37 with Mapping

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

the class CSplit method getMisPlacedVMs.

@Override
public Set<VM> getMisPlacedVMs(Instance i) {
    Mapping map = i.getModel().getMapping();
    List<Collection<VM>> groups = new ArrayList<>(cstr.getSets());
    // Bad contains the VMs on nodes that host VMs from different groups.
    Set<VM> bad = new HashSet<>();
    for (Collection<VM> grp : groups) {
        for (VM vm : grp) {
            if (map.isRunning(vm)) {
                Node n = map.getVMLocation(vm);
                Set<VM> allOnN = map.getRunningVMs(n);
                for (VM vmOnN : allOnN) {
                    if (inOtherGroup(groups, grp, vmOnN)) {
                        // The VM belong to another group
                        bad.add(vm);
                        bad.add(vmOnN);
                    }
                }
            }
        }
    }
    return bad;
}
Also used : VM(org.btrplace.model.VM) Node(org.btrplace.model.Node) TIntArrayList(gnu.trove.list.array.TIntArrayList) ArrayList(java.util.ArrayList) Collection(java.util.Collection) Mapping(org.btrplace.model.Mapping) HashSet(java.util.HashSet)

Example 38 with Mapping

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

the class MaxOnlineTest method isSatisfiedModel.

@Test
public void isSatisfiedModel() {
    Model model = new DefaultModel();
    Mapping map = model.getMapping();
    Node n1 = model.newNode();
    Node n2 = model.newNode();
    Node n3 = model.newNode();
    map.addOnlineNode(n1);
    map.addOnlineNode(n2);
    map.addOfflineNode(n3);
    Set<Node> s = new HashSet<>(Arrays.asList(n1, n2, n3));
    MaxOnline mo = new MaxOnline(s, 2);
    Assert.assertTrue(mo.isSatisfied(model));
    model.getMapping().addOnlineNode(n3);
    Assert.assertFalse(mo.isSatisfied(model));
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Node(org.btrplace.model.Node) BootNode(org.btrplace.plan.event.BootNode) ShutdownNode(org.btrplace.plan.event.ShutdownNode) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Mapping(org.btrplace.model.Mapping) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 39 with Mapping

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

the class MaxOnlineTest method isSatisfiedReconfigurationPlan.

@Test
public void isSatisfiedReconfigurationPlan() {
    Model model = new DefaultModel();
    Mapping map = model.getMapping();
    Node n1 = model.newNode();
    Node n2 = model.newNode();
    Node n3 = model.newNode();
    map.addOnlineNode(n1);
    map.addOnlineNode(n2);
    map.addOfflineNode(n3);
    Set<Node> s = new HashSet<>(Arrays.asList(n1, n2, n3));
    MaxOnline mo = new MaxOnline(s, 2);
    ReconfigurationPlan plan = new DefaultReconfigurationPlan(model);
    Assert.assertTrue(mo.isSatisfied(plan));
    plan.add(new BootNode(n3, 3, 9));
    Assert.assertFalse(mo.isSatisfied(plan));
    plan.add(new ShutdownNode(n2, 0, 5));
    Assert.assertTrue(mo.isSatisfied(plan));
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) BootNode(org.btrplace.plan.event.BootNode) Node(org.btrplace.model.Node) BootNode(org.btrplace.plan.event.BootNode) ShutdownNode(org.btrplace.plan.event.ShutdownNode) DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) ShutdownNode(org.btrplace.plan.event.ShutdownNode) Mapping(org.btrplace.model.Mapping) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 40 with Mapping

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

the class AmongChecker method endsWith.

@Override
public boolean endsWith(Model i) {
    Mapping map = i.getMapping();
    Collection<Node> grp = null;
    for (VM vm : getVMs()) {
        if (map.isRunning(vm)) {
            Collection<Node> nodes = getConstraint().getAssociatedPGroup(map.getVMLocation(vm));
            if (nodes.isEmpty()) {
                return false;
            } else if (grp == null) {
                grp = nodes;
            } else if (!grp.equals(nodes)) {
                return false;
            }
        }
    }
    return true;
}
Also used : Node(org.btrplace.model.Node) 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