Search in sources :

Example 36 with DefaultChocoScheduler

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

the class CResourceCapacityTest method testDiscreteSolvable.

/*@Test
    public void testSingleGetMisplaced() {
        Model mo = new DefaultModel();
        VM vm2 = mo.newVM();
        VM vm3 = mo.newVM();
        Node n2 = mo.newNode();
        Mapping map = mo.getMapping().on(n2).run(n2, vm2, vm3);

        org.btrplace.model.view.ShareableResource rc = new ShareableResource("cpu", 5, 5);
        rc.setConsumption(vm2, 3);
        rc.setConsumption(vm3, 1);

        mo.attach(rc);

        Instance i = new Instance(mo, Collections.emptyList(), new MinMTTR());
        ResourceCapacity s = new ResourceCapacity(n2, "cpu", 4);
        CResourceCapacity cs = new CResourceCapacity(s);
        Assert.assertTrue(cs.getMisPlacedVMs(i).isEmpty());
        rc.setConsumption(vm3, 2);
        Assert.assertEquals(cs.getMisPlacedVMs(i), map.getRunningVMs(n2));
    }*/
@Test
public void testDiscreteSolvable() 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();
    mo.getMapping().on(n1, n2).run(n1, vm1, vm2);
    ShareableResource rc = new ShareableResource("cpu", 5, 5);
    rc.setConsumption(vm1, 3);
    rc.setConsumption(vm2, 1);
    rc.setConsumption(vm3, 1);
    mo.attach(rc);
    ResourceCapacity s = new ResourceCapacity(n1, "cpu", 4);
    ChocoScheduler cra = new DefaultChocoScheduler();
    ReconfigurationPlan p = cra.solve(mo, Arrays.asList(s, new Preserve(vm2, "cpu", 3)));
    Assert.assertNotNull(p);
    Assert.assertEquals(p.getSize(), 1);
// System.out.println(p);
}
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) ShareableResource(org.btrplace.model.view.ShareableResource) Test(org.testng.annotations.Test)

Example 37 with DefaultChocoScheduler

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

the class CRunningCapacityTest method testSingleDiscreteResolution.

@Test
public void testSingleDiscreteResolution() 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 x = new RunningCapacity(Collections.singleton(n1), 2);
    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(2, plan.getSize());
}
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) Test(org.testng.annotations.Test)

Example 38 with DefaultChocoScheduler

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

the class CRunningCapacityTest method testFeasibleContinuousResolution.

@Test
public void testFeasibleContinuousResolution() 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).ready(vm5);
    Set<Node> on = new HashSet<>(Arrays.asList(n1, n2));
    List<SatConstraint> l = new ArrayList<>();
    l.add(new Running(vm5));
    l.add(new Fence(vm5, Collections.singleton(n1)));
    org.btrplace.model.constraint.RunningCapacity x = new org.btrplace.model.constraint.RunningCapacity(on, 4);
    x.setContinuous(true);
    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(), 2);
}
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 39 with DefaultChocoScheduler

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

the class CRunningCapacityTest method testIssue112.

@Test
public void testIssue112() throws Exception {
    String buf = "{\"model\":{\"mapping\":{\"readyVMs\":[],\"onlineNodes\":{\"0\":{\"sleepingVMs\":[],\"runningVMs\":[0]},\"1\":{\"sleepingVMs\":[],\"runningVMs\":[2,1]},\"2\":{\"sleepingVMs\":[],\"runningVMs\":[]}},\"offlineNodes\":[]},\"attributes\":{\"nodes\":{},\"vms\":{}},\"views\":[]},\"constraints\":[{\"vm\":0,\"continuous\":false,\"id\":\"running\"},{\"vm\":1,\"continuous\":false,\"id\":\"running\"},{\"vm\":2,\"continuous\":false,\"id\":\"running\"},{\"amount\":2,\"nodes\":[0],\"continuous\":false,\"id\":\"runningCapacity\"},{\"amount\":1,\"nodes\":[1],\"continuous\":false,\"id\":\"runningCapacity\"},{\"amount\":0,\"nodes\":[2],\"continuous\":false,\"id\":\"runningCapacity\"},{\"continuous\":false,\"parts\":[[0,1,2]],\"id\":\"among\",\"vms\":[0]},{\"continuous\":false,\"parts\":[[0,1,2]],\"id\":\"among\",\"vms\":[1]},{\"continuous\":false,\"parts\":[[0,1,2]],\"id\":\"among\",\"vms\":[2]}],\"objective\":{\"id\":\"minimizeMTTR\"}}";
    Instance i = JSON.readInstance(new StringReader(buf));
    List<SatConstraint> l = i.getSatConstraints().stream().filter(s -> !(s instanceof Among)).collect(Collectors.toList());
    ChocoScheduler s = new DefaultChocoScheduler();
    i = new Instance(i.getModel(), l, new MinMTTR());
    ReconfigurationPlan p = s.solve(i);
    Assert.assertNotNull(p);
}
Also used : java.util(java.util) SchedulerException(org.btrplace.scheduler.SchedulerException) ConstantActionDuration(org.btrplace.scheduler.choco.duration.ConstantActionDuration) Test(org.testng.annotations.Test) Collectors(java.util.stream.Collectors) JSON(org.btrplace.json.JSON) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) BootVM(org.btrplace.plan.event.BootVM) ShutdownVM(org.btrplace.plan.event.ShutdownVM) Assert(org.testng.Assert) StringReader(java.io.StringReader) org.btrplace.model(org.btrplace.model) org.btrplace.model.constraint(org.btrplace.model.constraint) Action(org.btrplace.plan.event.Action) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) StringReader(java.io.StringReader) Test(org.testng.annotations.Test)

Example 40 with DefaultChocoScheduler

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

the class CSeqTest method testWithVMsWithNoTransitions.

@Test
public void testWithVMsWithNoTransitions() 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();
    mo.getMapping().on(n1, n2).ready(vm1).run(n1, vm2, vm4).run(n2, vm3);
    List<SatConstraint> cstrs = new ArrayList<>();
    cstrs.add(new Running(vm1));
    cstrs.add(new Running(vm2));
    cstrs.add(new Running(vm3));
    cstrs.add(new Ready(vm4));
    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);
// System.out.println(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)

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