Search in sources :

Example 36 with MigrateVM

use of org.btrplace.plan.event.MigrateVM 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 : DefaultModel(org.btrplace.model.DefaultModel) Node(org.btrplace.model.Node) DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) Mapping(org.btrplace.model.Mapping) MigrateVM(org.btrplace.plan.event.MigrateVM) ShareableResource(org.btrplace.model.view.ShareableResource) DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) MigrateVM(org.btrplace.plan.event.MigrateVM) VM(org.btrplace.model.VM) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Allocate(org.btrplace.plan.event.Allocate) AllocateEvent(org.btrplace.plan.event.AllocateEvent) Test(org.testng.annotations.Test)

Example 37 with MigrateVM

use of org.btrplace.plan.event.MigrateVM 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 : DefaultModel(org.btrplace.model.DefaultModel) DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) Node(org.btrplace.model.Node) VM(org.btrplace.model.VM) MigrateVM(org.btrplace.plan.event.MigrateVM) DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Mapping(org.btrplace.model.Mapping) MigrateVM(org.btrplace.plan.event.MigrateVM) Test(org.testng.annotations.Test)

Example 38 with MigrateVM

use of org.btrplace.plan.event.MigrateVM in project scheduler by btrplace.

the class GatherTest method testContinuousIsSatisfied.

@Test(dependsOnMethods = { "testDiscreteIsSatisfied" })
public void testContinuousIsSatisfied() {
    Model mo = new DefaultModel();
    List<Node> ns = Util.newNodes(mo, 10);
    List<VM> vms = Util.newVMs(mo, 10);
    Set<VM> s = new HashSet<>(Arrays.asList(vms.get(0), vms.get(1)));
    Gather g = new Gather(s);
    g.setContinuous(true);
    Mapping map = mo.getMapping();
    map.addOnlineNode(ns.get(0));
    map.addOnlineNode(ns.get(1));
    map.addRunningVM(vms.get(0), ns.get(0));
    map.addReadyVM(vms.get(1));
    map.addRunningVM(vms.get(1), ns.get(1));
    ReconfigurationPlan plan = new DefaultReconfigurationPlan(mo);
    Assert.assertEquals(g.isSatisfied(plan), false);
    map.addReadyVM(vms.get(1));
    Assert.assertEquals(g.isSatisfied(plan), true);
    plan.add(new BootVM(vms.get(1), ns.get(0), 0, 1));
    Assert.assertEquals(g.isSatisfied(plan), true);
    map.addRunningVM(vms.get(1), ns.get(0));
    plan = new DefaultReconfigurationPlan(mo);
    plan.add(new MigrateVM(vms.get(1), ns.get(0), ns.get(1), 0, 1));
    plan.add(new MigrateVM(vms.get(0), ns.get(0), ns.get(1), 0, 1));
    Assert.assertEquals(g.isSatisfied(plan), false);
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Node(org.btrplace.model.Node) DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) Mapping(org.btrplace.model.Mapping) MigrateVM(org.btrplace.plan.event.MigrateVM) DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) MigrateVM(org.btrplace.plan.event.MigrateVM) BootVM(org.btrplace.plan.event.BootVM) VM(org.btrplace.model.VM) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) BootVM(org.btrplace.plan.event.BootVM) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Aggregations

MigrateVM (org.btrplace.plan.event.MigrateVM)38 Test (org.testng.annotations.Test)31 Model (org.btrplace.model.Model)30 Node (org.btrplace.model.Node)29 VM (org.btrplace.model.VM)29 DefaultModel (org.btrplace.model.DefaultModel)28 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)27 Mapping (org.btrplace.model.Mapping)25 DefaultReconfigurationPlan (org.btrplace.plan.DefaultReconfigurationPlan)15 BootVM (org.btrplace.plan.event.BootVM)13 ShutdownVM (org.btrplace.plan.event.ShutdownVM)12 ShareableResource (org.btrplace.model.view.ShareableResource)11 Allocate (org.btrplace.plan.event.Allocate)11 BootNode (org.btrplace.plan.event.BootNode)10 SatConstraint (org.btrplace.model.constraint.SatConstraint)9 ShutdownNode (org.btrplace.plan.event.ShutdownNode)9 SuspendVM (org.btrplace.plan.event.SuspendVM)9 DefaultChocoScheduler (org.btrplace.scheduler.choco.DefaultChocoScheduler)9 ArrayList (java.util.ArrayList)7 HashSet (java.util.HashSet)7