Search in sources :

Example 91 with ReconfigurationPlan

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

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

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

the class RunningCapacityTest method testContinuousIsSatisfied.

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

Example 94 with ReconfigurationPlan

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

the class SeqTest method testContinuousIsSatisfied.

@Test
public void testContinuousIsSatisfied() {
    Model mo = new DefaultModel();
    List<Node> ns = Util.newNodes(mo, 5);
    List<VM> vms = Util.newVMs(mo, 5);
    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.addSleepingVM(vms.get(2), ns.get(0));
    map.addRunningVM(vms.get(3), ns.get(0));
    List<VM> l = Arrays.asList(vms.get(0), vms.get(1), vms.get(2), vms.get(3));
    Seq c = new Seq(l);
    ReconfigurationPlan plan = new DefaultReconfigurationPlan(mo);
    plan.add(new MigrateVM(vms.get(3), ns.get(0), ns.get(1), 0, 1));
    plan.add(new SuspendVM(vms.get(0), ns.get(0), ns.get(0), 2, 3));
    plan.add(new BootVM(vms.get(1), ns.get(0), 3, 4));
    plan.add(new ResumeVM(vms.get(2), ns.get(0), ns.get(0), 4, 5));
    Assert.assertEquals(c.isSatisfied(plan), true);
    // Overlap
    plan = new DefaultReconfigurationPlan(mo);
    plan.add(new BootVM(vms.get(1), ns.get(0), 3, 4));
    plan.add(new ResumeVM(vms.get(2), ns.get(0), ns.get(0), 3, 5));
    Assert.assertEquals(c.isSatisfied(plan), false);
    // Not the right precedence
    plan = new DefaultReconfigurationPlan(mo);
    plan.add(new BootVM(vms.get(1), ns.get(0), 3, 4));
    plan.add(new ResumeVM(vms.get(2), ns.get(0), ns.get(0), 0, 1));
    Assert.assertEquals(c.isSatisfied(plan), false);
}
Also used : DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) Test(org.testng.annotations.Test)

Example 95 with ReconfigurationPlan

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

the class SeqTest method testContinuousSatisfied2.

@Test
public void testContinuousSatisfied2() {
    Model mo = new DefaultModel();
    List<Node> ns = Util.newNodes(mo, 5);
    List<VM> vms = Util.newVMs(mo, 5);
    Mapping map = mo.getMapping();
    map.addOnlineNode(ns.get(0));
    map.addOnlineNode(ns.get(1));
    map.addReadyVM(vms.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(0));
    ReconfigurationPlan p = new DefaultReconfigurationPlan(mo);
    p.add(new BootVM(vms.get(0), ns.get(0), 0, 1));
    p.add(new SuspendVM(vms.get(2), ns.get(1), ns.get(1), 1, 2));
    p.add(new ShutdownVM(vms.get(3), ns.get(0), 2, 3));
    List<VM> seq = Arrays.asList(vms.get(0), vms.get(1), vms.get(2), vms.get(3));
    Seq cstr = new Seq(seq);
    Assert.assertEquals(cstr.isSatisfied(p), true);
}
Also used : DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) 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