Search in sources :

Example 81 with DefaultChocoScheduler

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

the class CResourceCapacityTest method testSingleContinuousSolvable.

@Test
public void testSingleContinuousSolvable() 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).run(n1, vm1, vm2).ready(vm4);
    ShareableResource rc = new ShareableResource("cpu", 5, 5);
    rc.setConsumption(vm1, 3);
    rc.setConsumption(vm2, 1);
    rc.setConsumption(vm3, 1);
    rc.setConsumption(vm4, 3);
    mo.attach(rc);
    List<SatConstraint> cstrs = new ArrayList<>();
    ResourceCapacity s = new ResourceCapacity(n1, "cpu", 4);
    s.setContinuous(true);
    cstrs.add(s);
    cstrs.add(new Fence(vm4, Collections.singleton(n1)));
    cstrs.add(new Running(vm4));
    cstrs.addAll(Overbook.newOverbooks(map.getAllNodes(), "cpu", 1));
    ChocoScheduler cra = new DefaultChocoScheduler();
    ReconfigurationPlan p = cra.solve(mo, cstrs);
    Assert.assertNotNull(p);
    Assert.assertEquals(p.getSize(), 2);
}
Also used : ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) ShareableResource(org.btrplace.model.view.ShareableResource) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) Test(org.testng.annotations.Test)

Example 82 with DefaultChocoScheduler

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

the class CRootTest method testBasic.

@Test
public void testBasic() throws SchedulerException {
    Model mo = new DefaultModel();
    VM vm1 = mo.newVM();
    VM vm2 = mo.newVM();
    VM vm3 = mo.newVM();
    Node n1 = mo.newNode();
    Node n2 = mo.newNode();
    Mapping map = mo.getMapping().on(n1, n2).run(n1, vm1, vm2).ready(vm3);
    ChocoScheduler cra = new DefaultChocoScheduler();
    cra.doRepair(false);
    Root r1 = new Root(vm1);
    List<SatConstraint> l = new ArrayList<>();
    l.add(r1);
    l.addAll(Online.newOnline(map.getAllNodes()));
    ReconfigurationPlan p = cra.solve(mo, l);
    Assert.assertNotNull(p);
    Model res = p.getResult();
    Assert.assertEquals(n1, res.getMapping().getVMLocation(vm1));
}
Also used : DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) Root(org.btrplace.model.constraint.Root) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) SatConstraint(org.btrplace.model.constraint.SatConstraint) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) ArrayList(java.util.ArrayList) Test(org.testng.annotations.Test)

Example 83 with DefaultChocoScheduler

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

the class CRunningCapacityTest method testDiscreteSatisfaction.

@Test
public void testDiscreteSatisfaction() 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();
    mo.getMapping().on(n1, n2, n3).run(n1, vm1, vm2).run(n2, vm3, vm4, vm5);
    Set<Node> on = new HashSet<>(Arrays.asList(n1, n2));
    List<SatConstraint> l = new ArrayList<>();
    org.btrplace.model.constraint.RunningCapacity x = new org.btrplace.model.constraint.RunningCapacity(on, 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.assertNotNull(plan);
    Assert.assertEquals(plan.getSize(), 1);
}
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 84 with DefaultChocoScheduler

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

the class CRunningCapacityTest method testUnFeasibleContinuousResolution.

@Test
public void testUnFeasibleContinuousResolution() 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();
    mo.getMapping().on(n1, n2, n3).ready(vm1).run(n1, vm2).run(n2, vm3, vm4).run(n3, vm5);
    List<SatConstraint> l = new ArrayList<>();
    List<VM> seq = new ArrayList<>();
    seq.add(vm1);
    seq.add(vm2);
    l.add(new Seq(seq));
    l.add(new Fence(vm1, Collections.singleton(n1)));
    l.add(new Sleeping(vm2));
    l.add(new Running(vm1));
    l.add(new Root(vm3));
    l.add(new Root(vm4));
    Set<Node> on = new HashSet<>(Arrays.asList(n1, n2));
    org.btrplace.model.constraint.RunningCapacity x = new org.btrplace.model.constraint.RunningCapacity(on, 3);
    x.setContinuous(true);
    l.add(x);
    ChocoScheduler cra = new DefaultChocoScheduler();
    cra.setMaxEnd(5);
    cra.getDurationEvaluators().register(ShutdownVM.class, new ConstantActionDuration<>(10));
    ReconfigurationPlan plan = cra.solve(mo, l);
    Assert.assertNull(plan);
}
Also used : DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) org.btrplace.model(org.btrplace.model) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) 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 85 with DefaultChocoScheduler

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

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