Search in sources :

Example 16 with MigrateVM

use of org.btrplace.plan.event.MigrateVM 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 17 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 : 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 18 with MigrateVM

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

the class SplitAmongTest method testContinuousIsSatisfied.

@Test
public void testContinuousIsSatisfied() {
    Model mo = new DefaultModel();
    List<Node> ns = Util.newNodes(mo, 5);
    List<VM> vms = Util.newVMs(mo, 5);
    Collection<VM> vs1 = Arrays.asList(vms.get(0), vms.get(1));
    Collection<VM> vs2 = Arrays.asList(vms.get(2), vms.get(3));
    Collection<Collection<VM>> vGrps = Arrays.asList(vs1, vs2);
    Collection<Node> ps1 = Arrays.asList(ns.get(0), ns.get(1));
    Collection<Node> ps2 = Arrays.asList(ns.get(2), ns.get(3));
    Collection<Collection<Node>> pGrps = Arrays.asList(ps1, ps2);
    Mapping map = mo.getMapping();
    map.addOnlineNode(ns.get(0));
    map.addOnlineNode(ns.get(1));
    map.addOnlineNode(ns.get(2));
    map.addOnlineNode(ns.get(3));
    map.addRunningVM(vms.get(0), ns.get(0));
    map.addRunningVM(vms.get(1), ns.get(0));
    map.addRunningVM(vms.get(2), ns.get(2));
    map.addRunningVM(vms.get(3), ns.get(3));
    SplitAmong sp = new SplitAmong(vGrps, pGrps, true);
    ReconfigurationPlan plan = new DefaultReconfigurationPlan(mo);
    Assert.assertEquals(sp.isSatisfied(plan), true);
    plan.add(new MigrateVM(vms.get(0), ns.get(0), ns.get(1), 3, 4));
    Assert.assertEquals(sp.isSatisfied(plan), true);
    map.addRunningVM(vms.get(4), ns.get(3));
    Assert.assertEquals(sp.isSatisfied(plan), true);
    plan.add(new MigrateVM(vms.get(1), ns.get(0), ns.get(2), 0, 2));
    Assert.assertEquals(sp.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) MigrateVM(org.btrplace.plan.event.MigrateVM) Collection(java.util.Collection) Test(org.testng.annotations.Test)

Example 19 with MigrateVM

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

the class SplitTest method testContinuousIsSatisfied.

@Test
public void testContinuousIsSatisfied() {
    Model mo = new DefaultModel();
    Mapping map = mo.getMapping();
    List<Node> ns = Util.newNodes(mo, 3);
    List<VM> vms = Util.newVMs(mo, 5);
    map.addOnlineNode(ns.get(0));
    map.addOnlineNode(ns.get(1));
    map.addOnlineNode(ns.get(2));
    Collection<VM> s1 = Arrays.asList(vms.get(0), vms.get(1));
    Collection<VM> s2 = Arrays.asList(vms.get(2), vms.get(3));
    Collection<VM> s3 = Collections.singleton(vms.get(4));
    Collection<Collection<VM>> args = Arrays.asList(s1, s2, s3);
    map.addRunningVM(vms.get(0), ns.get(0));
    map.addRunningVM(vms.get(1), ns.get(0));
    map.addRunningVM(vms.get(2), ns.get(1));
    map.addRunningVM(vms.get(3), ns.get(1));
    Split sp = new Split(args, true);
    ReconfigurationPlan plan = new DefaultReconfigurationPlan(mo);
    Assert.assertEquals(sp.isSatisfied(plan), true);
    // Violation
    map.addRunningVM(vms.get(2), ns.get(0));
    Assert.assertEquals(sp.isSatisfied(plan), false);
    plan.add(new MigrateVM(vms.get(2), ns.get(0), ns.get(1), 0, 1));
    // False cause there is the initial violation
    Assert.assertEquals(sp.isSatisfied(plan), false);
    sp.setContinuous(false);
    Assert.assertEquals(sp.isSatisfied(plan), true);
    sp.setContinuous(true);
    // Temporary overlap
    plan.add(new MigrateVM(vms.get(2), ns.get(1), ns.get(0), 5, 6));
    plan.add(new MigrateVM(vms.get(2), ns.get(0), ns.get(1), 6, 7));
    Assert.assertEquals(sp.isSatisfied(plan), false);
    // Liberate ns.get(0) from vms.get(0) and vms.get(1) before
    plan.add(new SuspendVM(vms.get(0), ns.get(0), ns.get(0), 2, 3));
    plan.add(new ShutdownVM(vms.get(1), ns.get(0), 2, 3));
    sp.setContinuous(false);
    Assert.assertEquals(sp.isSatisfied(plan), true);
}
Also used : DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) MigrateVM(org.btrplace.plan.event.MigrateVM) DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) SuspendVM(org.btrplace.plan.event.SuspendVM) ShutdownVM(org.btrplace.plan.event.ShutdownVM) MigrateVM(org.btrplace.plan.event.MigrateVM) SuspendVM(org.btrplace.plan.event.SuspendVM) ShutdownVM(org.btrplace.plan.event.ShutdownVM) Test(org.testng.annotations.Test)

Example 20 with MigrateVM

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

the class SpreadTest method testContinuousIsSatisfied.

@Test
public void testContinuousIsSatisfied() {
    Model mo = new DefaultModel();
    List<Node> ns = Util.newNodes(mo, 4);
    List<VM> vms = Util.newVMs(mo, 4);
    Mapping map = mo.getMapping();
    map.addOnlineNode(ns.get(0));
    map.addOnlineNode(ns.get(1));
    map.addOnlineNode(ns.get(2));
    map.addOnlineNode(ns.get(3));
    map.addRunningVM(vms.get(0), ns.get(0));
    map.addRunningVM(vms.get(1), ns.get(1));
    Spread s = new Spread(map.getAllVMs());
    ReconfigurationPlan p = new DefaultReconfigurationPlan(mo);
    Assert.assertEquals(s.isSatisfied(p), true);
    MigrateVM m1 = new MigrateVM(vms.get(0), ns.get(0), ns.get(1), 1, 2);
    p.add(m1);
    Assert.assertEquals(s.isSatisfied(p), false);
    // No overlapping at moment 1
    MigrateVM m2 = new MigrateVM(vms.get(1), ns.get(1), ns.get(2), 0, 1);
    p.add(m2);
    Assert.assertEquals(s.isSatisfied(p), true);
    map.addRunningVM(vms.get(2), ns.get(1));
    s = new Spread(map.getAllVMs());
    p = new DefaultReconfigurationPlan(mo);
    System.out.println(p.getOrigin() + "\n" + p.getResult());
    Assert.assertEquals(s.isSatisfied(p), false);
    p.add(new MigrateVM(vms.get(2), ns.get(1), ns.get(2), 0, 5));
    Assert.assertEquals(s.isSatisfied(p), true);
}
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

MigrateVM (org.btrplace.plan.event.MigrateVM)31 Test (org.testng.annotations.Test)25 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)24 DefaultReconfigurationPlan (org.btrplace.plan.DefaultReconfigurationPlan)12 ShareableResource (org.btrplace.model.view.ShareableResource)10 DefaultChocoScheduler (org.btrplace.scheduler.choco.DefaultChocoScheduler)9 SatConstraint (org.btrplace.model.constraint.SatConstraint)8 ArrayList (java.util.ArrayList)7 Network (org.btrplace.model.view.network.Network)7 BootVM (org.btrplace.plan.event.BootVM)7 Node (org.btrplace.model.Node)6 Allocate (org.btrplace.plan.event.Allocate)6 BootNode (org.btrplace.plan.event.BootNode)6 ShutdownVM (org.btrplace.plan.event.ShutdownVM)6 List (java.util.List)5 Model (org.btrplace.model.Model)5 VM (org.btrplace.model.VM)5 MinMTTRMig (org.btrplace.model.constraint.migration.MinMTTRMig)5 Switch (org.btrplace.model.view.network.Switch)5 Action (org.btrplace.plan.event.Action)5