Search in sources :

Example 86 with DefaultChocoScheduler

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

the class CRunningCapacityTest method testWithSatisfiedConstraint.

@Test
public void testWithSatisfiedConstraint() 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();
    Node n1 = mo.newNode();
    Node n2 = mo.newNode();
    Node n3 = mo.newNode();
    Mapping map = mo.getMapping().on(n1, n2, n3).run(n1, vm1, vm2).run(n3, vm3, vm4).sleep(n2, vm5);
    List<SatConstraint> l = new ArrayList<>();
    org.btrplace.model.constraint.RunningCapacity x = new org.btrplace.model.constraint.RunningCapacity(map.getAllNodes(), 4);
    x.setContinuous(false);
    l.add(x);
    ChocoScheduler cra = new DefaultChocoScheduler();
    cra.getDurationEvaluators().register(ShutdownVM.class, new ConstantActionDuration<>(10));
    ReconfigurationPlan plan = cra.solve(mo, l);
    Assert.assertEquals(plan.getSize(), 0);
}
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) BootVM(org.btrplace.plan.event.BootVM) ShutdownVM(org.btrplace.plan.event.ShutdownVM) org.btrplace.model.constraint(org.btrplace.model.constraint) org.btrplace.model(org.btrplace.model) Test(org.testng.annotations.Test)

Example 87 with DefaultChocoScheduler

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

the class CRunningCapacityTest method testSingleContinuousResolution.

@Test
public void testSingleContinuousResolution() throws SchedulerException {
    Model mo = new DefaultModel();
    VM vm1 = mo.newVM();
    VM vm2 = mo.newVM();
    VM vm3 = mo.newVM();
    Node n1 = mo.newNode();
    mo.getMapping().on(n1).run(n1, vm1, vm2).ready(vm3);
    List<SatConstraint> l = new ArrayList<>();
    l.add(new Running(vm1));
    l.add(new Ready(vm2));
    l.add(new Running(vm3));
    RunningCapacity sc = new RunningCapacity(Collections.singleton(n1), 2, true);
    sc.setContinuous(true);
    l.add(sc);
    ChocoScheduler cra = new DefaultChocoScheduler();
    cra.setTimeLimit(3);
    cra.getDurationEvaluators().register(ShutdownVM.class, new ConstantActionDuration<>(10));
    ReconfigurationPlan plan = cra.solve(mo, l);
    Assert.assertNotNull(plan);
    Iterator<Action> ite = plan.iterator();
    Assert.assertEquals(2, plan.getSize());
    Action a1 = ite.next();
    Action a2 = ite.next();
    Assert.assertTrue(a1 instanceof ShutdownVM);
    Assert.assertTrue(a2 instanceof BootVM);
    Assert.assertTrue(a1.getEnd() <= a2.getStart());
}
Also used : Action(org.btrplace.plan.event.Action) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) BootVM(org.btrplace.plan.event.BootVM) ShutdownVM(org.btrplace.plan.event.ShutdownVM) BootVM(org.btrplace.plan.event.BootVM) ShutdownVM(org.btrplace.plan.event.ShutdownVM) Test(org.testng.annotations.Test)

Example 88 with DefaultChocoScheduler

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

the class CSeqTest method testWithOnlyTransitions.

@Test
public void testWithOnlyTransitions() throws SchedulerException {
    Model mo = new DefaultModel();
    VM vm1 = mo.newVM();
    VM vm2 = mo.newVM();
    VM vm3 = mo.newVM();
    VM vm4 = mo.newVM();
    Node n1 = mo.newNode();
    Node n2 = mo.newNode();
    Mapping map = mo.getMapping().on(n1, n2).ready(vm1).run(n1, vm2, vm4).sleep(n2, vm3);
    List<SatConstraint> cstrs = new ArrayList<>();
    cstrs.add(new Running(vm1));
    cstrs.add(new Sleeping(vm2));
    cstrs.add(new Running(vm3));
    cstrs.add(new Ready(vm4));
    cstrs.addAll(Online.newOnline(map.getAllNodes()));
    ChocoScheduler cra = new DefaultChocoScheduler();
    List<VM> seq = Arrays.asList(vm1, vm2, vm3, vm4);
    cstrs.add(new Seq(seq));
    ReconfigurationPlan plan = cra.solve(mo, cstrs);
    Assert.assertNotNull(plan);
}
Also used : ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) ArrayList(java.util.ArrayList) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) Test(org.testng.annotations.Test)

Example 89 with DefaultChocoScheduler

use of org.btrplace.scheduler.choco.DefaultChocoScheduler 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 90 with DefaultChocoScheduler

use of org.btrplace.scheduler.choco.DefaultChocoScheduler 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

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