Search in sources :

Example 41 with DefaultChocoScheduler

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

the class CSplitAmongTest method testContinuousWithGroupChange.

@Test
public void testContinuousWithGroupChange() 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(true);
    // Move group of VMs 1 to the group of nodes 2. Cannot work as
    // the among part of the constraint will be violated
    cstrs.add(s);
    for (VM v : vg1) {
        cstrs.add(new Fence(v, pg2));
    }
    ChocoScheduler cra = new DefaultChocoScheduler();
    Assert.assertNull(cra.solve(mo, cstrs));
}
Also used : SplitAmong(org.btrplace.model.constraint.SplitAmong) SatConstraint(org.btrplace.model.constraint.SatConstraint) 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)

Example 42 with DefaultChocoScheduler

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

the class CSplitAmongTest method testDiscrete.

@Test
public void testDiscrete() 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(false);
    // vg1 and vg2 overlap on n2. The two groups are mis-placed
    map.addRunningVM(vm6, n2);
    ChocoScheduler cra = new DefaultChocoScheduler();
    ReconfigurationPlan p = cra.solve(mo, Collections.singleton(s));
    Assert.assertNotNull(p);
    Assert.assertTrue(p.getSize() > 0);
}
Also used : SplitAmong(org.btrplace.model.constraint.SplitAmong) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) Test(org.testng.annotations.Test)

Example 43 with DefaultChocoScheduler

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

the class CSplitTest method testSimpleDiscrete.

@Test
public void testSimpleDiscrete() 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();
    mo.getMapping().on(n1, n2, n3, n4, n5).run(n1, vm1, vm2, vm3).run(n3, vm4, vm5, vm6).run(n5, vm7, vm8);
    Collection<VM> g1 = Arrays.asList(vm1, vm2);
    Collection<VM> g2 = Arrays.asList(vm3, vm4, vm5);
    Collection<VM> g3 = Arrays.asList(vm6, vm7);
    Collection<Collection<VM>> grps = Arrays.asList(g1, g2, g3);
    Split s = new Split(grps);
    ChocoScheduler cra = new DefaultChocoScheduler();
    ReconfigurationPlan p = cra.solve(mo, Collections.singleton(s));
    Assert.assertNotNull(p);
    Assert.assertTrue(p.getSize() > 0);
}
Also used : DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) Split(org.btrplace.model.constraint.Split) Test(org.testng.annotations.Test)

Example 44 with DefaultChocoScheduler

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

the class CSpreadTest method testFoo.

@Test
public void testFoo() {
    String buf = "{\"model\":{\"mapping\":{\"readyVMs\":[],\"onlineNodes\":{\"0\":{\"sleepingVMs\":[],\"runningVMs\":[4,3,2,1,0]},\"1\":{\"sleepingVMs\":[],\"runningVMs\":[9,8,7,6,5]},\"2\":{\"sleepingVMs\":[],\"runningVMs\":[14,13,12,11,10]},\"3\":{\"sleepingVMs\":[],\"runningVMs\":[17,16,15]}},\"offlineNodes\":[]},\"attributes\":{\"nodes\":{},\"vms\":{}},\"views\":[{\"defConsumption\":0,\"nodes\":{\"0\":48986,\"1\":48986,\"2\":48986,\"3\":48986},\"rcId\":\"memory\",\"id\":\"shareableResource\",\"defCapacity\":0,\"vms\":{\"11\":8661,\"12\":8661,\"13\":8661,\"14\":8661,\"15\":8661,\"16\":8661,\"17\":8661,\"0\":8661,\"1\":8661,\"2\":8661,\"3\":8661,\"4\":8661,\"5\":8661,\"6\":8661,\"7\":8661,\"8\":8661,\"9\":8665,\"10\":8661}},{\"defConsumption\":0,\"nodes\":{\"0\":47040,\"1\":47040,\"2\":47040,\"3\":47098},\"rcId\":\"cpu\",\"id\":\"shareableResource\",\"defCapacity\":0,\"vms\":{\"11\":6,\"12\":6,\"13\":11,\"14\":12,\"15\":5,\"16\":5,\"17\":5,\"0\":5029,\"1\":8956,\"2\":6009,\"3\":9856,\"4\":27,\"5\":6,\"6\":5,\"7\":5,\"8\":6,\"9\":4,\"10\":6}},{\"defConsumption\":0,\"nodes\":{\"0\":1727,\"1\":1705,\"2\":1727,\"3\":1673},\"rcId\":\"controller_cpu\",\"id\":\"shareableResource\",\"defCapacity\":0,\"vms\":{\"11\":42,\"12\":22,\"13\":9,\"14\":28,\"15\":30,\"16\":29,\"17\":31,\"0\":28,\"1\":56,\"2\":43,\"3\":49,\"4\":26,\"5\":19,\"6\":38,\"7\":25,\"8\":35,\"9\":57,\"10\":39}}]},\"constraints\":[{\"rc\":\"cpu\",\"amount\":26927,\"nodes\":[0],\"continuous\":false,\"id\":\"resourceCapacity\"},{\"rc\":\"memory\",\"amount\":48986,\"nodes\":[0],\"continuous\":false,\"id\":\"resourceCapacity\"},{\"rc\":\"controller_cpu\",\"amount\":1468,\"nodes\":[0],\"continuous\":false,\"id\":\"resourceCapacity\"},{\"rc\":\"cpu\",\"amount\":6035,\"vm\":0,\"id\":\"preserve\"},{\"rc\":\"cpu\",\"amount\":10747,\"vm\":1,\"id\":\"preserve\"},{\"rc\":\"cpu\",\"amount\":7211,\"vm\":2,\"id\":\"preserve\"},{\"rc\":\"cpu\",\"amount\":11827,\"vm\":3,\"id\":\"preserve\"},{\"rc\":\"cpu\",\"amount\":32,\"vm\":4,\"id\":\"preserve\"},{\"rc\":\"cpu\",\"amount\":26927,\"nodes\":[1],\"continuous\":false,\"id\":\"resourceCapacity\"},{\"rc\":\"memory\",\"amount\":48986,\"nodes\":[1],\"continuous\":false,\"id\":\"resourceCapacity\"},{\"rc\":\"controller_cpu\",\"amount\":1449,\"nodes\":[1],\"continuous\":false,\"id\":\"resourceCapacity\"},{\"rc\":\"cpu\",\"amount\":26927,\"nodes\":[2],\"continuous\":false,\"id\":\"resourceCapacity\"},{\"rc\":\"memory\",\"amount\":48986,\"nodes\":[2],\"continuous\":false,\"id\":\"resourceCapacity\"},{\"rc\":\"controller_cpu\",\"amount\":1468,\"nodes\":[2],\"continuous\":false,\"id\":\"resourceCapacity\"},{\"rc\":\"cpu\",\"amount\":26961,\"nodes\":[3],\"continuous\":false,\"id\":\"resourceCapacity\"},{\"rc\":\"memory\",\"amount\":48986,\"nodes\":[3],\"continuous\":false,\"id\":\"resourceCapacity\"},{\"rc\":\"controller_cpu\",\"amount\":1422,\"nodes\":[3],\"continuous\":false,\"id\":\"resourceCapacity\"},{\"continuous\":true,\"id\":\"spread\",\"vms\":[17,3,9,13]}],\"objective\":{\"id\":\"minimizeMTTR\"}}";
    Instance i = JSON.readInstance(new StringReader(buf));
    ChocoScheduler s = new DefaultChocoScheduler();
    // s.doOptimize(false);
    s.setMaxEnd(3);
    s.doRepair(true);
    s.solve(i);
}
Also used : DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) StringReader(java.io.StringReader) Test(org.testng.annotations.Test)

Example 45 with DefaultChocoScheduler

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

the class CSpreadTest method testDiscrete.

@Test
public void testDiscrete() throws SchedulerException {
    Model mo = new DefaultModel();
    VM vm1 = mo.newVM();
    VM vm2 = mo.newVM();
    Node n1 = mo.newNode();
    Node n2 = mo.newNode();
    Node n3 = mo.newNode();
    mo.getMapping().on(n1, n2, n3).run(n1, vm1).run(n2, vm2);
    List<SatConstraint> cstr = new ArrayList<>();
    ChocoScheduler cra = new DefaultChocoScheduler();
    Spread s = new Spread(mo.getMapping().getAllVMs());
    s.setContinuous(false);
    cstr.add(s);
    cstr.addAll(Online.newOnline(mo.getMapping().getAllNodes()));
    cstr.add(new Fence(vm1, Collections.singleton(n2)));
    ReconfigurationPlan p = cra.solve(mo, cstr);
    Assert.assertNotNull(p);
    System.err.println(p);
    Mapping res = p.getResult().getMapping();
    Assert.assertEquals(2, p.getSize());
    Assert.assertNotSame(res.getVMLocation(vm1), res.getVMLocation(vm2));
}
Also used : ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) Test(org.testng.annotations.Test)

Aggregations

DefaultChocoScheduler (org.btrplace.scheduler.choco.DefaultChocoScheduler)104 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)94 Test (org.testng.annotations.Test)90 ChocoScheduler (org.btrplace.scheduler.choco.ChocoScheduler)83 ShareableResource (org.btrplace.model.view.ShareableResource)43 SatConstraint (org.btrplace.model.constraint.SatConstraint)40 ArrayList (java.util.ArrayList)37 DefaultModel (org.btrplace.model.DefaultModel)19 Model (org.btrplace.model.Model)19 Node (org.btrplace.model.Node)19 VM (org.btrplace.model.VM)18 MigrateVM (org.btrplace.plan.event.MigrateVM)17 Fence (org.btrplace.model.constraint.Fence)14 Network (org.btrplace.model.view.network.Network)14 BootVM (org.btrplace.plan.event.BootVM)14 ShutdownVM (org.btrplace.plan.event.ShutdownVM)14 Offline (org.btrplace.model.constraint.Offline)13 Switch (org.btrplace.model.view.network.Switch)13 MinMTTRMig (org.btrplace.model.constraint.migration.MinMTTRMig)11 SchedulerException (org.btrplace.scheduler.SchedulerException)11