Search in sources :

Example 6 with ShutdownVM

use of org.btrplace.plan.event.ShutdownVM 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 7 with ShutdownVM

use of org.btrplace.plan.event.ShutdownVM 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 8 with ShutdownVM

use of org.btrplace.plan.event.ShutdownVM 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 9 with ShutdownVM

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

the class ReconfigurationPlanFuzzer method setDestinationState.

private void setDestinationState(ReconfigurationPlan p, VM v) {
    Mapping map = p.getOrigin().getMapping();
    Node host = map.getVMLocation(v);
    int n = rnd.nextInt(dstReadyVMs + dstRunningVMs + dstSleepingVMs);
    int[] bounds = schedule();
    int duration = bounds[1] - bounds[0];
    if (n < dstReadyVMs) {
        if (host != null) {
            p.add(new ShutdownVM(v, host, bounds[0], bounds[1]));
            p.getOrigin().getAttributes().put(v, "shutdown", duration);
        }
    } else if (n < dstReadyVMs + dstRunningVMs) {
        if (host == null) {
            p.add(new BootVM(v, pick(map.getAllNodes()), bounds[0], bounds[1]));
            p.getOrigin().getAttributes().put(v, "boot", duration);
        } else {
            // was running -> migrate
            if (map.isRunning(v)) {
                Node dst = pick(map.getAllNodes());
                if (!host.equals(dst)) {
                    p.add(new MigrateVM(v, host, dst, bounds[0], bounds[1]));
                    p.getOrigin().getAttributes().put(v, "migrate", duration);
                }
            } else {
                // was sleeping -> resume
                p.add(new ResumeVM(v, host, pick(map.getAllNodes()), bounds[0], bounds[1]));
                p.getOrigin().getAttributes().put(v, "resume", duration);
            }
        }
    } else {
        // moving to sleeping state
        if (map.isRunning(v)) {
            p.add(new SuspendVM(v, host, host, bounds[0], bounds[1]));
            p.getOrigin().getAttributes().put(v, "sleeping", duration);
        }
    }
}
Also used : ResumeVM(org.btrplace.plan.event.ResumeVM) SuspendVM(org.btrplace.plan.event.SuspendVM) Node(org.btrplace.model.Node) BootNode(org.btrplace.plan.event.BootNode) ShutdownNode(org.btrplace.plan.event.ShutdownNode) BootVM(org.btrplace.plan.event.BootVM) Mapping(org.btrplace.model.Mapping) MigrateVM(org.btrplace.plan.event.MigrateVM) ShutdownVM(org.btrplace.plan.event.ShutdownVM)

Example 10 with ShutdownVM

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

the class CRunningCapacityTest method testSingleContinuousResolution.

@Test
public void testSingleContinuousResolution() throws SchedulerException {
    Model mo = new DefaultModel();
    VM vm1 = mo.newVM();
    VM vm2 = mo.newVM();
    VM vm3 = mo.newVM();
    Node n1 = mo.newNode();
    mo.getMapping().on(n1).run(n1, vm1, vm2).ready(vm3);
    List<SatConstraint> l = new ArrayList<>();
    l.add(new Running(vm1));
    l.add(new Ready(vm2));
    l.add(new Running(vm3));
    RunningCapacity sc = new RunningCapacity(Collections.singleton(n1), 2, true);
    sc.setContinuous(true);
    l.add(sc);
    ChocoScheduler cra = new DefaultChocoScheduler();
    cra.setTimeLimit(3);
    cra.getDurationEvaluators().register(ShutdownVM.class, new ConstantActionDuration<>(10));
    ReconfigurationPlan plan = cra.solve(mo, l);
    Assert.assertNotNull(plan);
    Iterator<Action> ite = plan.iterator();
    Assert.assertEquals(2, plan.getSize());
    Action a1 = ite.next();
    Action a2 = ite.next();
    Assert.assertTrue(a1 instanceof ShutdownVM);
    Assert.assertTrue(a2 instanceof BootVM);
    Assert.assertTrue(a1.getEnd() <= a2.getStart());
}
Also used : Action(org.btrplace.plan.event.Action) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) BootVM(org.btrplace.plan.event.BootVM) ShutdownVM(org.btrplace.plan.event.ShutdownVM) BootVM(org.btrplace.plan.event.BootVM) ShutdownVM(org.btrplace.plan.event.ShutdownVM) Test(org.testng.annotations.Test)

Aggregations

ShutdownVM (org.btrplace.plan.event.ShutdownVM)10 Test (org.testng.annotations.Test)9 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)8 DefaultReconfigurationPlan (org.btrplace.plan.DefaultReconfigurationPlan)6 BootVM (org.btrplace.plan.event.BootVM)6 MigrateVM (org.btrplace.plan.event.MigrateVM)5 Allocate (org.btrplace.plan.event.Allocate)3 ShutdownNode (org.btrplace.plan.event.ShutdownNode)3 SuspendVM (org.btrplace.plan.event.SuspendVM)3 HashSet (java.util.HashSet)2 Node (org.btrplace.model.Node)2 ShareableResource (org.btrplace.model.view.ShareableResource)2 Action (org.btrplace.plan.event.Action)2 BootNode (org.btrplace.plan.event.BootNode)2 ResumeVM (org.btrplace.plan.event.ResumeVM)2 ChocoScheduler (org.btrplace.scheduler.choco.ChocoScheduler)2 DefaultChocoScheduler (org.btrplace.scheduler.choco.DefaultChocoScheduler)2 DefaultModel (org.btrplace.model.DefaultModel)1 Mapping (org.btrplace.model.Mapping)1 Model (org.btrplace.model.Model)1