Search in sources :

Example 6 with SplitAmong

use of org.btrplace.model.constraint.SplitAmong in project scheduler by btrplace.

the class CSplitAmongTest method testContinuousWithAllDiffViolated.

@Test
public void testContinuousWithAllDiffViolated() throws SchedulerException {
    Model mo = new DefaultModel();
    VM vm1 = mo.newVM();
    VM vm2 = mo.newVM();
    VM vm3 = mo.newVM();
    VM vm4 = mo.newVM();
    VM vm5 = mo.newVM();
    VM vm6 = mo.newVM();
    VM vm7 = mo.newVM();
    VM vm8 = mo.newVM();
    Node n1 = mo.newNode();
    Node n2 = mo.newNode();
    Node n3 = mo.newNode();
    Node n4 = mo.newNode();
    Node n5 = mo.newNode();
    Mapping map = mo.getMapping().on(n1, n2, n3, n4, n5).run(n1, vm1, vm3).run(n2, vm2).run(n3, vm4, vm6).run(n4, vm5).run(n5, vm7);
    // Isolated VM not considered by the constraint
    map.addRunningVM(vm8, n1);
    Collection<VM> vg1 = new HashSet<>(Arrays.asList(vm1, vm2, vm3));
    Collection<VM> vg2 = new HashSet<>(Arrays.asList(vm4, vm5, vm6));
    Collection<VM> vg3 = new HashSet<>(Collections.singletonList(vm7));
    Collection<Node> pg1 = new HashSet<>(Arrays.asList(n1, n2));
    Collection<Node> pg2 = new HashSet<>(Arrays.asList(n3, n4));
    Collection<Node> pg3 = new HashSet<>(Collections.singletonList(n5));
    Collection<Collection<VM>> vgs = new HashSet<>(Arrays.asList(vg1, vg2, vg3));
    Collection<Collection<Node>> pgs = new HashSet<>(Arrays.asList(pg1, pg2, pg3));
    SplitAmong s = new SplitAmong(vgs, pgs);
    s.setContinuous(true);
    // vg1 and vg2 overlap on n2.
    map.addRunningVM(vm6, n2);
    ChocoScheduler cra = new DefaultChocoScheduler();
    Assert.assertNull(cra.solve(mo, Collections.singleton(s)));
}
Also used : SplitAmong(org.btrplace.model.constraint.SplitAmong) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) Test(org.testng.annotations.Test)

Example 7 with SplitAmong

use of org.btrplace.model.constraint.SplitAmong in project scheduler by btrplace.

the class CSplitAmongTest method testDiscreteWithGroupChange.

@Test
public void testDiscreteWithGroupChange() throws SchedulerException {
    Model mo = new DefaultModel();
    VM vm1 = mo.newVM();
    VM vm2 = mo.newVM();
    VM vm3 = mo.newVM();
    VM vm4 = mo.newVM();
    VM vm5 = mo.newVM();
    VM vm6 = mo.newVM();
    VM vm7 = mo.newVM();
    VM vm8 = mo.newVM();
    Node n1 = mo.newNode();
    Node n2 = mo.newNode();
    Node n3 = mo.newNode();
    Node n4 = mo.newNode();
    Node n5 = mo.newNode();
    Mapping map = mo.getMapping().on(n1, n2, n3, n4, n5).run(n1, vm1, vm3).run(n2, vm2).run(n3, vm4, vm6).run(n4, vm5).run(n5, vm7);
    // Isolated VM not considered by the constraint
    map.addRunningVM(vm8, n1);
    Collection<VM> vg1 = new HashSet<>(Arrays.asList(vm1, vm2, vm3));
    Collection<VM> vg2 = new HashSet<>(Arrays.asList(vm4, vm5, vm6));
    Collection<Node> pg1 = new HashSet<>(Arrays.asList(n1, n2));
    Collection<Node> pg2 = new HashSet<>(Arrays.asList(n3, n4));
    Collection<Node> pg3 = new HashSet<>(Collections.singletonList(n5));
    Collection<Collection<VM>> vgs = new HashSet<>(Arrays.asList(vg1, vg2));
    Collection<Collection<Node>> pgs = new HashSet<>(Arrays.asList(pg1, pg2, pg3));
    List<SatConstraint> cstrs = new ArrayList<>();
    SplitAmong s = new SplitAmong(vgs, pgs);
    s.setContinuous(false);
    // Move group of VMs 1 to the group of nodes 2. This is allowed
    // group of VMs 2 will move to another group of node so at the end, the constraint should be satisfied
    cstrs.add(s);
    for (VM v : vg1) {
        cstrs.add(new Fence(v, pg2));
    }
    ChocoScheduler cra = new DefaultChocoScheduler();
    ReconfigurationPlan plan = cra.solve(mo, cstrs);
    Assert.assertNotNull(plan);
}
Also used : SplitAmong(org.btrplace.model.constraint.SplitAmong) SatConstraint(org.btrplace.model.constraint.SatConstraint) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) Fence(org.btrplace.model.constraint.Fence) Test(org.testng.annotations.Test)

Aggregations

SplitAmong (org.btrplace.model.constraint.SplitAmong)7 Test (org.testng.annotations.Test)7 ChocoScheduler (org.btrplace.scheduler.choco.ChocoScheduler)4 DefaultChocoScheduler (org.btrplace.scheduler.choco.DefaultChocoScheduler)4 DefaultModel (org.btrplace.model.DefaultModel)2 Fence (org.btrplace.model.constraint.Fence)2 SatConstraint (org.btrplace.model.constraint.SatConstraint)2 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)2 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 ScriptBuilder (org.btrplace.btrpsl.ScriptBuilder)1 Model (org.btrplace.model.Model)1 Node (org.btrplace.model.Node)1 VM (org.btrplace.model.VM)1 MinMTTR (org.btrplace.model.constraint.MinMTTR)1