Search in sources :

Example 6 with ShutdownNode

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

the class DefaultReconfigurationPlanTest method testDumb.

@Test
public void testDumb() {
    Model mo = new DefaultModel();
    VM v = mo.newVM();
    Node n1 = mo.newNode();
    Node n2 = mo.newNode();
    mo.getMapping().addOnlineNode(n1);
    mo.getMapping().addOnlineNode(n2);
    mo.getMapping().addRunningVM(v, n1);
    ReconfigurationPlan p1 = new DefaultReconfigurationPlan(mo);
    Action a1 = new SuspendVM(v, n1, n1, 0, 1);
    Action a2 = new ShutdownNode(n1, 1, 2);
    Action a3 = new ShutdownNode(n2, 1, 2);
    Assert.assertTrue(p1.add(a1));
    Assert.assertTrue(p1.add(a2));
    Assert.assertTrue(p1.add(a3));
    Assert.assertTrue(p1.getActions().contains(a1));
    Assert.assertTrue(p1.getActions().contains(a2));
    Assert.assertTrue(p1.getActions().contains(a3));
}
Also used : Action(org.btrplace.plan.event.Action) SuspendVM(org.btrplace.plan.event.SuspendVM) MigrateVM(org.btrplace.plan.event.MigrateVM) SuspendVM(org.btrplace.plan.event.SuspendVM) ShutdownNode(org.btrplace.plan.event.ShutdownNode) ShutdownNode(org.btrplace.plan.event.ShutdownNode) Test(org.testng.annotations.Test)

Example 7 with ShutdownNode

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

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

ShutdownNode (org.btrplace.plan.event.ShutdownNode)8 Test (org.testng.annotations.Test)6 BootNode (org.btrplace.plan.event.BootNode)5 MigrateVM (org.btrplace.plan.event.MigrateVM)5 Allocate (org.btrplace.plan.event.Allocate)3 SuspendVM (org.btrplace.plan.event.SuspendVM)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 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)2 ShutdownVM (org.btrplace.plan.event.ShutdownVM)2 Mapping (org.btrplace.model.Mapping)1 VM (org.btrplace.model.VM)1 Action (org.btrplace.plan.event.Action)1 AllocateEvent (org.btrplace.plan.event.AllocateEvent)1 BootVM (org.btrplace.plan.event.BootVM)1 ForgeVM (org.btrplace.plan.event.ForgeVM)1