Search in sources :

Example 6 with BootVM

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

the class ReconfigurationPlanCheckerTest method testSequencing.

@Test(dependsOnMethods = { "tesAddandRemove" })
public void testSequencing() throws SatConstraintViolationException {
    Model mo = new DefaultModel();
    List<Node> ns = Util.newNodes(mo, 10);
    List<VM> vms = Util.newVMs(mo, 10);
    Mapping m = mo.getMapping();
    m.addOnlineNode(ns.get(0));
    m.addOnlineNode(ns.get(1));
    m.addOfflineNode(ns.get(3));
    m.addReadyVM(vms.get(1));
    m.addRunningVM(vms.get(0), ns.get(0));
    ReconfigurationPlan p = new DefaultReconfigurationPlan(mo);
    SatConstraintChecker<?> chk = mock(SatConstraintChecker.class);
    MigrateVM m1 = new MigrateVM(vms.get(0), ns.get(0), ns.get(1), 0, 3);
    BootVM b1 = new BootVM(vms.get(1), ns.get(0), 1, 5);
    BootNode bn = new BootNode(ns.get(3), 3, 6);
    p.add(m1);
    p.add(b1);
    p.add(bn);
    Model res = p.getResult();
    Assert.assertNotNull(res);
    ReconfigurationPlanChecker rc = new ReconfigurationPlanChecker();
    rc.addChecker(chk);
    InOrder order = inOrder(chk);
    rc.check(p);
    order.verify(chk).startsWith(mo);
    order.verify(chk).start(m1);
    order.verify(chk).start(b1);
    order.verify(chk).end(m1);
    order.verify(chk).start(bn);
    order.verify(chk).end(b1);
    order.verify(chk).end(bn);
    order.verify(chk).endsWith(res);
}
Also used : InOrder(org.mockito.InOrder) BootNode(org.btrplace.plan.event.BootNode) BootNode(org.btrplace.plan.event.BootNode) MigrateVM(org.btrplace.plan.event.MigrateVM) MigrateVM(org.btrplace.plan.event.MigrateVM) BootVM(org.btrplace.plan.event.BootVM) BootVM(org.btrplace.plan.event.BootVM) Test(org.testng.annotations.Test)

Example 7 with BootVM

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

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

BootVM (org.btrplace.plan.event.BootVM)8 Test (org.testng.annotations.Test)7 MigrateVM (org.btrplace.plan.event.MigrateVM)6 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)5 ShutdownVM (org.btrplace.plan.event.ShutdownVM)5 DefaultReconfigurationPlan (org.btrplace.plan.DefaultReconfigurationPlan)4 BootNode (org.btrplace.plan.event.BootNode)4 HashSet (java.util.HashSet)2 Node (org.btrplace.model.Node)2 Allocate (org.btrplace.plan.event.Allocate)2 ResumeVM (org.btrplace.plan.event.ResumeVM)2 ShutdownNode (org.btrplace.plan.event.ShutdownNode)2 SuspendVM (org.btrplace.plan.event.SuspendVM)2 DefaultModel (org.btrplace.model.DefaultModel)1 Mapping (org.btrplace.model.Mapping)1 Model (org.btrplace.model.Model)1 VM (org.btrplace.model.VM)1 Action (org.btrplace.plan.event.Action)1 AllocateEvent (org.btrplace.plan.event.AllocateEvent)1 ForgeVM (org.btrplace.plan.event.ForgeVM)1