Search in sources :

Example 61 with ChocoScheduler

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

the class COnlineTest method testSolvableProblem.

@Test
public void testSolvableProblem() throws SchedulerException {
    Model mo = new DefaultModel();
    Node n1 = mo.newNode();
    mo.getMapping().off(n1);
    ChocoScheduler cra = new DefaultChocoScheduler();
    ReconfigurationPlan plan = cra.solve(mo, Collections.singleton(new Online(n1)));
    Assert.assertNotNull(plan);
    Model res = plan.getResult();
    Assert.assertTrue(res.getMapping().isOnline(n1));
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) Node(org.btrplace.model.Node) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Online(org.btrplace.model.constraint.Online) Test(org.testng.annotations.Test)

Example 62 with ChocoScheduler

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

the class COverbookTest method testWithScheduling1.

@Test
public void testWithScheduling1() throws SchedulerException {
    Model mo = new DefaultModel();
    VM vm1 = mo.newVM();
    VM vm3 = mo.newVM();
    Node n1 = mo.newNode();
    Mapping m = mo.getMapping().on(n1).run(n1, vm1).ready(vm3);
    ShareableResource rcCPU = new ShareableResource("cpu", 2, 2);
    List<SatConstraint> cstrs = new ArrayList<>();
    cstrs.add(new Running(vm3));
    cstrs.add(new Sleeping(vm1));
    cstrs.addAll(Online.newOnline(m.getAllNodes()));
    cstrs.add(new Overbook(n1, "cpu", 1));
    cstrs.add(new Preserve(vm1, "cpu", 2));
    cstrs.add(new Preserve(vm3, "cpu", 2));
    mo.attach(rcCPU);
    ChocoScheduler cra = new DefaultChocoScheduler();
    ReconfigurationPlan p = cra.solve(mo, cstrs);
    Assert.assertNotNull(p);
}
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) BootVM(org.btrplace.plan.event.BootVM) ShutdownVM(org.btrplace.plan.event.ShutdownVM) Test(org.testng.annotations.Test)

Example 63 with ChocoScheduler

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

the class CPreserveTest method testPreserveWithoutOverbook.

/*@Test
    public void testGetMisplaced() {
        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).run(n2, vm3).get();
        ShareableResource rc = new ShareableResource("cpu", 7, 7);
        rc.setConsumption(vm1, 3);
        rc.setConsumption(vm2, 3);
        rc.setConsumption(vm3, 5);

        Preserve p = new Preserve(vm1, "cpu", 5);

        mo.attach(rc);
        //Assert.assertEquals(SatConstraint.Sat.UNSATISFIED, p.isSatisfied(mo));

        CPreserve cp = new CPreserve(p);
        Instance i = new Instance(mo, Collections.emptyList(), new MinMTTR());
        Set<VM> bads = cp.getMisPlacedVMs(i);
        Assert.assertEquals(1, bads.size());
        Assert.assertEquals(vm1, bads.iterator().next());
    }*/
/**
 * A preserve constraint asks for a minimum amount of resources but
 * their is no overbook ratio so, the default value of 1 is used
 * and vm1 or vm2 is moved to n2
 *
 * @throws org.btrplace.scheduler.SchedulerException
 */
@Test
public void testPreserveWithoutOverbook() 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).run(n2, vm3);
    ShareableResource rc = new ShareableResource("cpu", 10, 10);
    rc.setCapacity(n1, 7);
    rc.setConsumption(vm1, 3);
    rc.setConsumption(vm2, 3);
    rc.setConsumption(vm3, 5);
    Preserve pr = new Preserve(vm2, "cpu", 5);
    ChocoScheduler cra = new DefaultChocoScheduler();
    mo.attach(rc);
    List<SatConstraint> cstrs = new ArrayList<>();
    cstrs.addAll(Online.newOnline(map.getAllNodes()));
    cstrs.add(pr);
    ReconfigurationPlan p = cra.solve(mo, cstrs);
    Assert.assertNotNull(p);
}
Also used : SatConstraint(org.btrplace.model.constraint.SatConstraint) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) ArrayList(java.util.ArrayList) ShareableResource(org.btrplace.model.view.ShareableResource) Preserve(org.btrplace.model.constraint.Preserve) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) Test(org.testng.annotations.Test)

Example 64 with ChocoScheduler

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

the class CQuarantineTest method testWithSatisfiedModel.

@Test
public void testWithSatisfiedModel() 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();
    Node n3 = mo.newNode();
    mo.getMapping().on(n1, n2, n3).run(n1, vm1).run(n2, vm2, vm3).run(n3, vm4);
    Quarantine q = new Quarantine(n2);
    ChocoScheduler cra = new DefaultChocoScheduler();
    ReconfigurationPlan p = cra.solve(mo, Collections.singleton(q));
    Assert.assertNotNull(p);
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) VM(org.btrplace.model.VM) Node(org.btrplace.model.Node) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Quarantine(org.btrplace.model.constraint.Quarantine) Test(org.testng.annotations.Test)

Example 65 with ChocoScheduler

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

the class CResourceCapacityTest 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));
    org.btrplace.model.view.ShareableResource rc = new ShareableResource("cpu", 5, 5);
    rc.setConsumption(vm1, 2);
    rc.setConsumption(vm2, 3);
    rc.setConsumption(vm3, 3);
    rc.setConsumption(vm4, 1);
    rc.setConsumption(vm5, 5);
    mo.attach(rc);
    List<SatConstraint> l = new ArrayList<>();
    l.add(new Running(vm5));
    l.add(new Fence(vm5, Collections.singleton(n1)));
    ResourceCapacity x = new ResourceCapacity(on, "cpu", 10);
    x.setContinuous(true);
    l.add(x);
    ChocoScheduler cra = new DefaultChocoScheduler();
    ReconfigurationPlan plan = cra.solve(mo, l);
    Assert.assertNotNull(plan);
    // System.out.println(plan);
    Assert.assertTrue(plan.getSize() > 0);
}
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) ShareableResource(org.btrplace.model.view.ShareableResource) 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