Search in sources :

Example 11 with DefaultReconfigurationPlan

use of org.btrplace.plan.DefaultReconfigurationPlan in project scheduler by btrplace.

the class NoDelayTest method testIsSatisfied.

@Test
public void testIsSatisfied() {
    // Create a new default model
    Model mo = new DefaultModel();
    Mapping map = mo.getMapping();
    // Create 4 nodes
    List<Node> ns = Util.newNodes(mo, 4);
    // Create 2 vms
    List<VM> vms = Util.newVMs(mo, 2);
    // Set the nodes online
    map.addOnlineNode(ns.get(0));
    map.addOnlineNode(ns.get(1));
    map.addOnlineNode(ns.get(2));
    map.addOnlineNode(ns.get(3));
    // Run the 2 vms on the two first nodes
    map.addRunningVM(vms.get(0), ns.get(0));
    map.addRunningVM(vms.get(1), ns.get(1));
    // Set as initial plan
    ReconfigurationPlan plan = new DefaultReconfigurationPlan(mo);
    // Create a NoDelay constraint by constraining the first VM
    NoDelay nd = new NoDelay(vms.get(0));
    // The constraint should be satisfied by default
    Assert.assertEquals(nd.isSatisfied(plan), true);
    // Migrate the first VM (constrained) at t=0 to the third node
    plan.add(new MigrateVM(vms.get(0), ns.get(0), ns.get(2), 0, 1));
    Assert.assertEquals(nd.isSatisfied(plan), true);
    // Migrate the second VM at t=0 to the last node
    plan.add(new MigrateVM(vms.get(1), ns.get(1), ns.get(3), 0, 1));
    Assert.assertEquals(nd.isSatisfied(plan), true);
    // Re-Migrate the second VM at t=1 to the second node
    plan.add(new MigrateVM(vms.get(1), ns.get(3), ns.get(1), 1, 2));
    Assert.assertEquals(nd.isSatisfied(plan), true);
    // Re-Migrate the first VM (constrained) at t=1 to the first node
    plan.add(new MigrateVM(vms.get(0), ns.get(2), ns.get(0), 1, 2));
    Assert.assertEquals(nd.isSatisfied(plan), false);
// Shutdown node
// plan.add(new ShutdownNode(ns.get(2), 0, 1));
// Assert.assertEquals(nd.isSatisfied(plan), true);
// Boot node
// plan.add(new BootNode(ns.get(2), 1, 3));
// Assert.assertEquals(nd.isSatisfied(plan), false);
}
Also used : DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) MigrateVM(org.btrplace.plan.event.MigrateVM) DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) MigrateVM(org.btrplace.plan.event.MigrateVM) Test(org.testng.annotations.Test)

Example 12 with DefaultReconfigurationPlan

use of org.btrplace.plan.DefaultReconfigurationPlan in project scheduler by btrplace.

the class OfflineTest method testContinuousIsSatisfied.

@Test
public void testContinuousIsSatisfied() {
    Model mo = new DefaultModel();
    List<Node> ns = Util.newNodes(mo, 10);
    List<VM> vms = Util.newVMs(mo, 10);
    Mapping map = mo.getMapping();
    map.addOnlineNode(ns.get(0));
    map.addOnlineNode(ns.get(1));
    Offline off = new Offline(ns.get(0));
    map.addRunningVM(vms.get(0), ns.get(0));
    ReconfigurationPlan plan = new DefaultReconfigurationPlan(mo);
    Assert.assertEquals(off.isSatisfied(plan), false);
    plan.add(new ShutdownNode(ns.get(1), 0, 1));
    plan.add(new ShutdownVM(vms.get(0), ns.get(0), 0, 1));
    Assert.assertEquals(off.isSatisfied(plan), false);
    plan.add(new ShutdownNode(ns.get(0), 1, 2));
    Assert.assertEquals(off.isSatisfied(plan), true);
}
Also used : DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) ShutdownNode(org.btrplace.plan.event.ShutdownNode) ShutdownVM(org.btrplace.plan.event.ShutdownVM) DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) ShutdownNode(org.btrplace.plan.event.ShutdownNode) ShutdownVM(org.btrplace.plan.event.ShutdownVM) Test(org.testng.annotations.Test)

Example 13 with DefaultReconfigurationPlan

use of org.btrplace.plan.DefaultReconfigurationPlan in project scheduler by btrplace.

the class PreserveTest method testIsSatisfied.

@Test(dependsOnMethods = { "testInstantiation" })
public void testIsSatisfied() {
    Model m = new DefaultModel();
    List<VM> vms = Util.newVMs(m, 5);
    List<Node> ns = Util.newNodes(m, 5);
    ShareableResource rc = new ShareableResource("cpu", 3, 3);
    Mapping map = m.getMapping();
    map.addOnlineNode(ns.get(0));
    map.addOnlineNode(ns.get(1));
    map.addRunningVM(vms.get(0), ns.get(0));
    map.addSleepingVM(vms.get(1), ns.get(0));
    map.addRunningVM(vms.get(2), ns.get(0));
    m.attach(rc);
    Preserve p = new Preserve(vms.get(0), "cpu", 3);
    rc.setConsumption(vms.get(0), 3);
    // Not running so we don't care
    rc.setConsumption(vms.get(1), 1);
    rc.setConsumption(vms.get(2), 3);
    Assert.assertEquals(true, p.isSatisfied(m));
    // Set to 3 by default
    rc.unset(vms.get(2));
    Assert.assertEquals(true, p.isSatisfied(m));
    Assert.assertEquals(false, new Preserve(vms.get(2), "mem", 3).isSatisfied(m));
    ReconfigurationPlan plan = new DefaultReconfigurationPlan(m);
    rc.setConsumption(vms.get(1), 1);
    Assert.assertFalse(new Preserve(vms.get(2), "cpu", 4).isSatisfied(plan));
    plan.add(new Allocate(vms.get(2), ns.get(0), "cpu", 7, 5, 7));
    Assert.assertTrue(p.isSatisfied(plan));
    rc.setConsumption(vms.get(0), 1);
    AllocateEvent e = new AllocateEvent(vms.get(0), "cpu", 4);
    Assert.assertFalse(p.isSatisfied(plan));
    MigrateVM mig = new MigrateVM(vms.get(0), ns.get(0), ns.get(1), 0, 3);
    mig.addEvent(Action.Hook.POST, e);
    plan.add(mig);
    Assert.assertTrue(p.isSatisfied(plan));
}
Also used : DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) MigrateVM(org.btrplace.plan.event.MigrateVM) ShareableResource(org.btrplace.model.view.ShareableResource) DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) MigrateVM(org.btrplace.plan.event.MigrateVM) Allocate(org.btrplace.plan.event.Allocate) AllocateEvent(org.btrplace.plan.event.AllocateEvent) Test(org.testng.annotations.Test)

Example 14 with DefaultReconfigurationPlan

use of org.btrplace.plan.DefaultReconfigurationPlan in project scheduler by btrplace.

the class QuarantineTest method testContinuousIsSatisfied.

@Test
public void testContinuousIsSatisfied() {
    Model mo = new DefaultModel();
    List<VM> vms = Util.newVMs(mo, 5);
    List<Node> ns = Util.newNodes(mo, 5);
    Mapping map = mo.getMapping();
    map.addOnlineNode(ns.get(0));
    map.addOnlineNode(ns.get(1));
    map.addOnlineNode(ns.get(2));
    map.addRunningVM(vms.get(0), ns.get(0));
    map.addRunningVM(vms.get(1), ns.get(1));
    map.addReadyVM(vms.get(2));
    map.addRunningVM(vms.get(3), ns.get(2));
    Quarantine q = new Quarantine(ns.get(0));
    ReconfigurationPlan plan = new DefaultReconfigurationPlan(mo);
    Assert.assertEquals(q.isSatisfied(plan), true);
    plan.add(new ShutdownVM(vms.get(1), ns.get(1), 1, 2));
    Assert.assertEquals(q.isSatisfied(plan), true);
    plan.add(new BootVM(vms.get(2), ns.get(0), 0, 1));
    Assert.assertEquals(q.isSatisfied(plan), false);
    plan = new DefaultReconfigurationPlan(mo);
    plan.add(new BootVM(vms.get(2), ns.get(2), 0, 1));
    Assert.assertEquals(new Quarantine(ns.get(1)).isSatisfied(plan), true);
    plan.add(new MigrateVM(vms.get(3), ns.get(2), ns.get(1), 0, 1));
    Assert.assertEquals(new Quarantine(ns.get(1)).isSatisfied(plan), false);
    plan = new DefaultReconfigurationPlan(mo);
    plan.add(new MigrateVM(vms.get(1), ns.get(1), ns.get(0), 0, 1));
    Assert.assertEquals(q.isSatisfied(plan), false);
}
Also used : DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) MigrateVM(org.btrplace.plan.event.MigrateVM) DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) ShutdownVM(org.btrplace.plan.event.ShutdownVM) MigrateVM(org.btrplace.plan.event.MigrateVM) BootVM(org.btrplace.plan.event.BootVM) BootVM(org.btrplace.plan.event.BootVM) ShutdownVM(org.btrplace.plan.event.ShutdownVM) Test(org.testng.annotations.Test)

Example 15 with DefaultReconfigurationPlan

use of org.btrplace.plan.DefaultReconfigurationPlan in project scheduler by btrplace.

the class RootTest method testContinuousIsSatisfied.

@Test
public void testContinuousIsSatisfied() {
    Model mo = new DefaultModel();
    Mapping map = mo.getMapping();
    List<Node> ns = Util.newNodes(mo, 3);
    VM vm1 = mo.newVM();
    map.addOnlineNode(ns.get(0));
    map.addOnlineNode(ns.get(1));
    map.addRunningVM(vm1, ns.get(0));
    ReconfigurationPlan p = new DefaultReconfigurationPlan(mo);
    Root r = new Root(vm1);
    Assert.assertEquals(r.isSatisfied(p), true);
    p.add(new MigrateVM(vm1, ns.get(0), ns.get(1), 1, 2));
    Assert.assertEquals(r.isSatisfied(p), false);
}
Also used : DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) MigrateVM(org.btrplace.plan.event.MigrateVM) DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) MigrateVM(org.btrplace.plan.event.MigrateVM) Test(org.testng.annotations.Test)

Aggregations

DefaultReconfigurationPlan (org.btrplace.plan.DefaultReconfigurationPlan)24 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)24 Test (org.testng.annotations.Test)21 MigrateVM (org.btrplace.plan.event.MigrateVM)12 ShutdownVM (org.btrplace.plan.event.ShutdownVM)6 HashSet (java.util.HashSet)4 DefaultModel (org.btrplace.model.DefaultModel)4 Model (org.btrplace.model.Model)4 BootVM (org.btrplace.plan.event.BootVM)4 ShareableResource (org.btrplace.model.view.ShareableResource)3 Allocate (org.btrplace.plan.event.Allocate)3 BootNode (org.btrplace.plan.event.BootNode)3 ShutdownNode (org.btrplace.plan.event.ShutdownNode)3 Node (org.btrplace.model.Node)2 Action (org.btrplace.plan.event.Action)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Instance (org.btrplace.model.Instance)1 Mapping (org.btrplace.model.Mapping)1 MinMTTR (org.btrplace.model.constraint.MinMTTR)1