Search in sources :

Example 6 with BootNode

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

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

the class TimeBasedPlanApplierTest method makePlan.

private static ReconfigurationPlan makePlan(Model mo, List<Node> ns, List<VM> vms) {
    Mapping map = mo.getMapping();
    map.addOnlineNode(ns.get(0));
    map.addOnlineNode(ns.get(1));
    map.addOnlineNode(ns.get(2));
    map.addOfflineNode(ns.get(3));
    map.addRunningVM(vms.get(0), ns.get(2));
    map.addRunningVM(vms.get(1), ns.get(0));
    map.addRunningVM(vms.get(2), ns.get(1));
    map.addRunningVM(vms.get(3), ns.get(1));
    BootNode bN4 = new BootNode(ns.get(3), 3, 5);
    MigrateVM mVM1 = new MigrateVM(vms.get(0), ns.get(2), ns.get(3), 6, 7);
    Allocate aVM3 = new Allocate(vms.get(2), ns.get(1), "cpu", 7, 8, 9);
    MigrateVM mVM2 = new MigrateVM(vms.get(1), ns.get(0), ns.get(1), 1, 3);
    MigrateVM mVM4 = new MigrateVM(vms.get(3), ns.get(1), ns.get(2), 1, 7);
    ShutdownNode sN1 = new ShutdownNode(ns.get(0), 5, 7);
    ShareableResource rc = new ShareableResource("cpu");
    rc.setConsumption(vms.get(2), 3);
    mo.attach(rc);
    ReconfigurationPlan plan = new DefaultReconfigurationPlan(mo);
    plan.add(bN4);
    plan.add(mVM1);
    plan.add(aVM3);
    plan.add(mVM2);
    plan.add(mVM4);
    plan.add(sN1);
    return plan;
}
Also used : BootNode(org.btrplace.plan.event.BootNode) ShutdownNode(org.btrplace.plan.event.ShutdownNode) MigrateVM(org.btrplace.plan.event.MigrateVM) ShareableResource(org.btrplace.model.view.ShareableResource) Allocate(org.btrplace.plan.event.Allocate)

Example 8 with BootNode

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

the class ReconfigurationPlanFuzzer method addNode.

private boolean addNode(Node n, ReconfigurationPlan p) {
    double src = rnd.nextDouble();
    double dst = rnd.nextDouble();
    int[] bounds = schedule();
    if (src < srcOffNodes) {
        p.getOrigin().getMapping().addOfflineNode(n);
        if (dst > dstOffNodes) {
            p.add(new BootNode(n, bounds[0], bounds[1]));
            p.getOrigin().getAttributes().put(n, "boot", bounds[1] - bounds[0]);
            return true;
        }
    } else {
        p.getOrigin().getMapping().addOnlineNode(n);
        if (dst < srcOffNodes) {
            p.add(new ShutdownNode(n, bounds[0], bounds[1]));
            p.getOrigin().getAttributes().put(n, "shutdown", bounds[1] - bounds[0]);
        }
    }
    return false;
}
Also used : BootNode(org.btrplace.plan.event.BootNode) ShutdownNode(org.btrplace.plan.event.ShutdownNode)

Aggregations

BootNode (org.btrplace.plan.event.BootNode)8 ShutdownNode (org.btrplace.plan.event.ShutdownNode)6 Test (org.testng.annotations.Test)6 MigrateVM (org.btrplace.plan.event.MigrateVM)5 Allocate (org.btrplace.plan.event.Allocate)4 BootVM (org.btrplace.plan.event.BootVM)4 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)3 HashSet (java.util.HashSet)2 DefaultModel (org.btrplace.model.DefaultModel)2 Model (org.btrplace.model.Model)2 Node (org.btrplace.model.Node)2 ShareableResource (org.btrplace.model.view.ShareableResource)2 DefaultReconfigurationPlan (org.btrplace.plan.DefaultReconfigurationPlan)2 Mapping (org.btrplace.model.Mapping)1 VM (org.btrplace.model.VM)1 Running (org.btrplace.model.constraint.Running)1 Action (org.btrplace.plan.event.Action)1 AllocateEvent (org.btrplace.plan.event.AllocateEvent)1 ForgeVM (org.btrplace.plan.event.ForgeVM)1 KillVM (org.btrplace.plan.event.KillVM)1