Search in sources :

Example 86 with ReconfigurationPlan

use of org.btrplace.plan.ReconfigurationPlan 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 : 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) BootVM(org.btrplace.plan.event.BootVM) BootVM(org.btrplace.plan.event.BootVM) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 87 with ReconfigurationPlan

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

the class MaxOnlineTest method isSatisfiedReconfigurationPlan.

@Test
public void isSatisfiedReconfigurationPlan() {
    Model model = new DefaultModel();
    Mapping map = model.getMapping();
    Node n1 = model.newNode();
    Node n2 = model.newNode();
    Node n3 = model.newNode();
    map.addOnlineNode(n1);
    map.addOnlineNode(n2);
    map.addOfflineNode(n3);
    Set<Node> s = new HashSet<>(Arrays.asList(n1, n2, n3));
    MaxOnline mo = new MaxOnline(s, 2);
    ReconfigurationPlan plan = new DefaultReconfigurationPlan(model);
    Assert.assertTrue(mo.isSatisfied(plan));
    plan.add(new BootNode(n3, 3, 9));
    Assert.assertFalse(mo.isSatisfied(plan));
    plan.add(new ShutdownNode(n2, 0, 5));
    Assert.assertTrue(mo.isSatisfied(plan));
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) BootNode(org.btrplace.plan.event.BootNode) Node(org.btrplace.model.Node) BootNode(org.btrplace.plan.event.BootNode) ShutdownNode(org.btrplace.plan.event.ShutdownNode) DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) ShutdownNode(org.btrplace.plan.event.ShutdownNode) Mapping(org.btrplace.model.Mapping) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 88 with ReconfigurationPlan

use of org.btrplace.plan.ReconfigurationPlan 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 89 with ReconfigurationPlan

use of org.btrplace.plan.ReconfigurationPlan 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 90 with ReconfigurationPlan

use of org.btrplace.plan.ReconfigurationPlan 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)

Aggregations

ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)185 Test (org.testng.annotations.Test)160 DefaultChocoScheduler (org.btrplace.scheduler.choco.DefaultChocoScheduler)94 ChocoScheduler (org.btrplace.scheduler.choco.ChocoScheduler)74 SatConstraint (org.btrplace.model.constraint.SatConstraint)53 ShareableResource (org.btrplace.model.view.ShareableResource)52 Model (org.btrplace.model.Model)49 ArrayList (java.util.ArrayList)46 Node (org.btrplace.model.Node)45 DefaultModel (org.btrplace.model.DefaultModel)44 VM (org.btrplace.model.VM)41 MigrateVM (org.btrplace.plan.event.MigrateVM)37 DurationEvaluators (org.btrplace.scheduler.choco.duration.DurationEvaluators)34 DefaultParameters (org.btrplace.scheduler.choco.DefaultParameters)32 Parameters (org.btrplace.scheduler.choco.Parameters)29 ReconfigurationProblem (org.btrplace.scheduler.choco.ReconfigurationProblem)29 DefaultReconfigurationProblemBuilder (org.btrplace.scheduler.choco.DefaultReconfigurationProblemBuilder)28 DefaultReconfigurationPlan (org.btrplace.plan.DefaultReconfigurationPlan)24 Mapping (org.btrplace.model.Mapping)23 HashSet (java.util.HashSet)22