Search in sources :

Example 71 with ChocoScheduler

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

the class CRunningCapacityTest method testUnfeasible.

@Test
public void testUnfeasible() throws SchedulerException {
    Model model = new DefaultModel();
    VM vm1 = model.newVM();
    VM vm2 = model.newVM();
    VM vm3 = model.newVM();
    VM vm4 = model.newVM();
    Node n1 = model.newNode();
    Node n2 = model.newNode();
    Node n3 = model.newNode();
    Mapping map = model.getMapping().on(n1, n2, n3).run(n1, vm1, vm2).run(n2, vm3).run(n3, vm4);
    Collection<SatConstraint> ctrs = new HashSet<>();
    ctrs.add(new org.btrplace.model.constraint.RunningCapacity(map.getAllNodes(), 2));
    ChocoScheduler cra = new DefaultChocoScheduler();
    ReconfigurationPlan plan = cra.solve(model, ctrs);
    Assert.assertNull(plan);
}
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) Test(org.testng.annotations.Test)

Example 72 with ChocoScheduler

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

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

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

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

Aggregations

ChocoScheduler (org.btrplace.scheduler.choco.ChocoScheduler)82 DefaultChocoScheduler (org.btrplace.scheduler.choco.DefaultChocoScheduler)82 Test (org.testng.annotations.Test)76 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)73 ShareableResource (org.btrplace.model.view.ShareableResource)30 SatConstraint (org.btrplace.model.constraint.SatConstraint)28 ArrayList (java.util.ArrayList)25 DefaultModel (org.btrplace.model.DefaultModel)17 Model (org.btrplace.model.Model)17 Node (org.btrplace.model.Node)17 VM (org.btrplace.model.VM)16 BootVM (org.btrplace.plan.event.BootVM)12 ShutdownVM (org.btrplace.plan.event.ShutdownVM)12 MigrateVM (org.btrplace.plan.event.MigrateVM)10 Fence (org.btrplace.model.constraint.Fence)9 Preserve (org.btrplace.model.constraint.Preserve)8 org.btrplace.model.constraint (org.btrplace.model.constraint)7 MaxOnline (org.btrplace.model.constraint.MaxOnline)6 org.btrplace.model (org.btrplace.model)5 SchedulerException (org.btrplace.scheduler.SchedulerException)5