Search in sources :

Example 31 with ShareableResource

use of org.btrplace.model.view.ShareableResource in project scheduler by btrplace.

the class COverbookTest method testGetMisplaced.

@Test
public void testGetMisplaced() 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();
    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, vm5, vm6);
    ShareableResource rcCPU = new ShareableResource("cpu", 1, 1);
    mo.attach(rcCPU);
    Overbook o1 = new Overbook(n1, "cpu", 1);
    Overbook o2 = new Overbook(n2, "cpu", 2);
    Overbook o3 = new Overbook(n3, "cpu", 3);
    COverbook co1 = new COverbook(o1);
    COverbook co2 = new COverbook(o2);
    COverbook co3 = new COverbook(o3);
    Instance i = new Instance(mo, Collections.emptyList(), new MinMTTR());
    Assert.assertTrue(co1.getMisPlacedVMs(i).isEmpty());
    Assert.assertTrue(co2.getMisPlacedVMs(i).isEmpty());
    Assert.assertEquals(o3.getInvolvedVMs(), co3.getMisPlacedVMs(i));
}
Also used : BootVM(org.btrplace.plan.event.BootVM) ShutdownVM(org.btrplace.plan.event.ShutdownVM) ShareableResource(org.btrplace.model.view.ShareableResource) Test(org.testng.annotations.Test)

Example 32 with ShareableResource

use of org.btrplace.model.view.ShareableResource in project scheduler by btrplace.

the class COverbookTest method testMultipleOverbook.

/**
 * One overbook factor per node.
 *
 * @throws org.btrplace.scheduler.SchedulerException should not occur
 */
@Test
public void testMultipleOverbook() throws SchedulerException {
    Node[] nodes = new Node[3];
    VM[] vms = new VM[11];
    Model mo = new DefaultModel();
    Mapping m = mo.getMapping();
    ShareableResource rcCPU = new ShareableResource("cpu");
    for (int i = 0; i < vms.length; i++) {
        if (i < nodes.length) {
            nodes[i] = mo.newNode();
            rcCPU.setCapacity(nodes[i], 2);
            m.addOnlineNode(nodes[i]);
        }
        vms[i] = mo.newVM();
        rcCPU.setConsumption(vms[i], 1);
        m.addReadyVM(vms[i]);
    }
    mo.attach(rcCPU);
    Collection<SatConstraint> c = new HashSet<>();
    c.add(new Overbook(nodes[0], "cpu", 1));
    c.add(new Overbook(nodes[1], "cpu", 2));
    c.add(new Overbook(nodes[2], "cpu", 3));
    c.addAll(Running.newRunning(m.getAllVMs()));
    c.add(new Preserve(vms[0], "cpu", 1));
    DefaultChocoScheduler cra = new DefaultChocoScheduler();
    cra.setTimeLimit(-1);
    ReconfigurationPlan p = cra.solve(mo, c);
    Assert.assertNotNull(p);
/*for (SatConstraint cstr : c) {
            Assert.assertEquals(SatConstraint.Sat.SATISFIED, cstr.isSatisfied(p.getResult()));
        } */
}
Also used : ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) ShareableResource(org.btrplace.model.view.ShareableResource) org.btrplace.model.constraint(org.btrplace.model.constraint) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) BootVM(org.btrplace.plan.event.BootVM) ShutdownVM(org.btrplace.plan.event.ShutdownVM) Test(org.testng.annotations.Test)

Example 33 with ShareableResource

use of org.btrplace.model.view.ShareableResource in project scheduler by btrplace.

the class CResourceCapacityTest method testGetMisplaced.

@Test
public void testGetMisplaced() {
    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 m = mo.getMapping().on(n1, n2, n3).run(n1, vm1, vm2, vm3).run(n2, vm4).ready(vm5);
    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);
    ResourceCapacity c = new ResourceCapacity(m.getAllNodes(), "cpu", 10);
    CResourceCapacity cc = new CResourceCapacity(c);
    Instance i = new Instance(mo, Collections.emptyList(), new MinMTTR());
    Assert.assertTrue(cc.getMisPlacedVMs(i).isEmpty());
    m.addRunningVM(vm5, n3);
    Assert.assertEquals(cc.getMisPlacedVMs(i), m.getAllVMs());
}
Also used : ShareableResource(org.btrplace.model.view.ShareableResource) Test(org.testng.annotations.Test)

Example 34 with ShareableResource

use of org.btrplace.model.view.ShareableResource in project scheduler by btrplace.

the class CResourceCapacityTest 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));
    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, 1);
    mo.attach(rc);
    List<SatConstraint> l = new ArrayList<>();
    ResourceCapacity x = new ResourceCapacity(on, "cpu", 9);
    x.setContinuous(false);
    l.add(x);
    ChocoScheduler cra = new DefaultChocoScheduler();
    ReconfigurationPlan plan = cra.solve(mo, l);
    Assert.assertNotNull(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)

Example 35 with ShareableResource

use of org.btrplace.model.view.ShareableResource in project scheduler by btrplace.

the class CResourceCapacityTest method testDiscreteUnsolvable.

@Test
public void testDiscreteUnsolvable() throws SchedulerException {
    Model mo = new DefaultModel();
    VM vm1 = mo.newVM();
    VM vm2 = mo.newVM();
    Node n1 = mo.newNode();
    mo.getMapping().on(n1).run(n1, vm1, vm2);
    org.btrplace.model.view.ShareableResource rc = new ShareableResource("cpu", 5, 5);
    rc.setConsumption(vm1, 3);
    rc.setConsumption(vm2, 2);
    mo.attach(rc);
    ResourceCapacity s = new ResourceCapacity(n1, "cpu", 3);
    ChocoScheduler cra = new DefaultChocoScheduler();
    ReconfigurationPlan p = cra.solve(mo, Collections.singleton(s));
    Assert.assertNull(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) ShareableResource(org.btrplace.model.view.ShareableResource) Test(org.testng.annotations.Test)

Aggregations

ShareableResource (org.btrplace.model.view.ShareableResource)86 Test (org.testng.annotations.Test)61 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)47 DefaultChocoScheduler (org.btrplace.scheduler.choco.DefaultChocoScheduler)41 SatConstraint (org.btrplace.model.constraint.SatConstraint)32 ArrayList (java.util.ArrayList)31 ChocoScheduler (org.btrplace.scheduler.choco.ChocoScheduler)29 VM (org.btrplace.model.VM)27 Model (org.btrplace.model.Model)25 Node (org.btrplace.model.Node)25 DefaultModel (org.btrplace.model.DefaultModel)22 MigrateVM (org.btrplace.plan.event.MigrateVM)16 Mapping (org.btrplace.model.Mapping)13 Network (org.btrplace.model.view.network.Network)12 Switch (org.btrplace.model.view.network.Switch)12 Offline (org.btrplace.model.constraint.Offline)11 MinMTTRMig (org.btrplace.model.constraint.migration.MinMTTRMig)10 SchedulerException (org.btrplace.scheduler.SchedulerException)10 Fence (org.btrplace.model.constraint.Fence)7 Preserve (org.btrplace.model.constraint.Preserve)7