Search in sources :

Example 1 with DefaultReconfigurationPlan

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

the class AmongTest method testContinuousIsSatisfied.

@Test(dependsOnMethods = { "testInstantiation" })
public void testContinuousIsSatisfied() {
    Model mo = new DefaultModel();
    List<Node> ns = Util.newNodes(mo, 10);
    List<VM> vms = Util.newVMs(mo, 10);
    Collection<Node> s1 = new HashSet<>(Arrays.asList(ns.get(0), ns.get(1)));
    Collection<Node> s2 = new HashSet<>(Collections.singletonList(ns.get(2)));
    Collection<Collection<Node>> pGrps = Arrays.asList(s1, s2);
    Set<VM> vs = new HashSet<>(Arrays.asList(vms.get(0), vms.get(1), vms.get(2)));
    Among a = new Among(vs, pGrps, true);
    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.addRunningVM(vms.get(2), ns.get(1));
    ReconfigurationPlan plan = new DefaultReconfigurationPlan(mo);
    Assert.assertEquals(a.isSatisfied(plan), true);
    plan.add(new MigrateVM(vms.get(2), ns.get(1), ns.get(2), 0, 1));
    plan.add(new MigrateVM(vms.get(2), ns.get(2), ns.get(1), 1, 2));
    // At moment 1, the constraint will be violated
    Assert.assertEquals(a.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) Test(org.testng.annotations.Test)

Example 2 with DefaultReconfigurationPlan

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

the class BanTest method testIsSatisfied.

@Test
public void testIsSatisfied() {
    Model m = new DefaultModel();
    List<VM> vms = Util.newVMs(m, 10);
    List<Node> ns = Util.newNodes(m, 10);
    Mapping map = m.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.addRunningVM(vms.get(2), ns.get(2));
    Set<Node> nodes = new HashSet<>(Collections.singletonList(ns.get(0)));
    Ban b = new Ban(vms.get(2), nodes);
    Assert.assertEquals(b.isSatisfied(m), true);
    map.addRunningVM(vms.get(2), ns.get(0));
    Assert.assertEquals(new Ban(vms.get(2), nodes).isSatisfied(m), false);
    ReconfigurationPlan plan = new DefaultReconfigurationPlan(m);
    plan.add(new MigrateVM(vms.get(0), ns.get(0), ns.get(1), 0, 3));
    plan.add(new MigrateVM(vms.get(0), ns.get(1), ns.get(0), 3, 6));
    plan.add(new MigrateVM(vms.get(1), ns.get(1), ns.get(2), 3, 6));
    Assert.assertEquals(b.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) Test(org.testng.annotations.Test)

Example 3 with DefaultReconfigurationPlan

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

the class LonelyTest method testContinuousIsSatisfied.

@Test(dependsOnMethods = { "testInstantiation" })
public void testContinuousIsSatisfied() {
    Model mo = new DefaultModel();
    List<VM> vms = Util.newVMs(mo, 10);
    List<Node> ns = Util.newNodes(mo, 10);
    Set<VM> s = new HashSet<>(Arrays.asList(vms.get(0), vms.get(1)));
    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(0));
    map.addRunningVM(vms.get(2), ns.get(1));
    map.addRunningVM(vms.get(3), ns.get(1));
    Lonely l = new Lonely(s, true);
    ReconfigurationPlan p = new DefaultReconfigurationPlan(mo);
    Assert.assertEquals(l.isSatisfied(p), true);
    p.add(new MigrateVM(vms.get(1), ns.get(0), ns.get(1), 2, 4));
    Assert.assertEquals(l.isSatisfied(p), false);
    p.add(new ShutdownVM(vms.get(2), ns.get(1), 0, 1));
    Assert.assertEquals(l.isSatisfied(p), false);
    p.add(new MigrateVM(vms.get(3), ns.get(1), ns.get(2), 1, 2));
    Assert.assertEquals(l.isSatisfied(p), true);
}
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) ShutdownVM(org.btrplace.plan.event.ShutdownVM) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 4 with DefaultReconfigurationPlan

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

the class OverbookTest method testContinuousIsSatisfied.

@Test
public void testContinuousIsSatisfied() {
    Model mo = new DefaultModel();
    List<VM> vms = Util.newVMs(mo, 10);
    Node n0 = mo.newNode();
    Node n1 = mo.newNode();
    Model i = new DefaultModel();
    Mapping cfg = i.getMapping();
    cfg.addOnlineNode(n0);
    cfg.addOnlineNode(n1);
    ShareableResource rc = new ShareableResource("cpu");
    rc.setCapacity(n0, 1);
    rc.setCapacity(n1, 4);
    rc.setConsumption(vms.get(0), 2);
    rc.setConsumption(vms.get(1), 2);
    rc.setConsumption(vms.get(2), 4);
    cfg.addRunningVM(vms.get(0), n0);
    cfg.addRunningVM(vms.get(1), n1);
    cfg.addRunningVM(vms.get(2), n1);
    cfg.addRunningVM(vms.get(3), n1);
    i.attach(rc);
    Overbook o = new Overbook(n1, "cpu", 2);
    o.setContinuous(true);
    ReconfigurationPlan p = new DefaultReconfigurationPlan(i);
    Assert.assertEquals(o.isSatisfied(p), true);
    p.add(new Allocate(vms.get(0), n0, "cpu", 1, 2, 5));
    Assert.assertEquals(o.isSatisfied(p), true);
    p.add(new Allocate(vms.get(1), n1, "cpu", 5, 2, 5));
    Assert.assertEquals(o.isSatisfied(p), false);
    p.add(new Allocate(vms.get(2), n1, "cpu", 2, 0, 1));
    Assert.assertEquals(o.isSatisfied(p), true);
    p.add(new Allocate(vms.get(3), n1, "cpu", 3, 4, 6));
    Assert.assertEquals(o.isSatisfied(p), false);
    p.add(new ShutdownVM(vms.get(2), n1, 2, 3));
    Assert.assertEquals(o.isSatisfied(p), true);
}
Also used : DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) ShutdownVM(org.btrplace.plan.event.ShutdownVM) DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) ShareableResource(org.btrplace.model.view.ShareableResource) ShutdownVM(org.btrplace.plan.event.ShutdownVM) Allocate(org.btrplace.plan.event.Allocate) Test(org.testng.annotations.Test)

Example 5 with DefaultReconfigurationPlan

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

the class ResourceCapacityTest 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));
    map.addOnlineNode(ns.get(2));
    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(2));
    map.addReadyVM(vms.get(4));
    ShareableResource rc = new ShareableResource("foo", 1, 1);
    mo.attach(rc);
    Set<Node> nodes = new HashSet<>(Arrays.asList(ns.get(0), ns.get(1)));
    ResourceCapacity cc = new ResourceCapacity(nodes, "foo", 4, true);
    ReconfigurationPlan plan = new DefaultReconfigurationPlan(mo);
    Assert.assertEquals(cc.isSatisfied(plan), true);
    // 3/4
    MigrateVM m = new MigrateVM(vms.get(3), ns.get(2), ns.get(1), 0, 1);
    m.addEvent(Action.Hook.POST, new AllocateEvent(vms.get(3), "foo", 2));
    plan.add(m);
    // 5/4
    plan.add(new ShutdownVM(vms.get(2), ns.get(1), 1, 2));
    // 4/4
    plan.add(new BootVM(vms.get(4), ns.get(2), 2, 3));
    // 4/4
    plan.add(new Allocate(vms.get(1), ns.get(0), "foo", 2, 2, 3));
    // 5/4
    plan.add(new MigrateVM(vms.get(0), ns.get(0), ns.get(2), 3, 4));
    System.out.println(plan);
    Assert.assertEquals(cc.isSatisfied(plan), true);
}
Also used : DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) ShareableResource(org.btrplace.model.view.ShareableResource) DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) HashSet(java.util.HashSet) 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