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