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));
}
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;
}
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;
}
Aggregations