use of org.btrplace.plan.event.ShutdownVM in project scheduler by btrplace.
the class QuarantineTest method testContinuousIsSatisfied.
@Test
public void testContinuousIsSatisfied() {
Model mo = new DefaultModel();
List<VM> vms = Util.newVMs(mo, 5);
List<Node> ns = Util.newNodes(mo, 5);
Mapping map = mo.getMapping();
map.addOnlineNode(ns.get(0));
map.addOnlineNode(ns.get(1));
map.addOnlineNode(ns.get(2));
map.addRunningVM(vms.get(0), ns.get(0));
map.addRunningVM(vms.get(1), ns.get(1));
map.addReadyVM(vms.get(2));
map.addRunningVM(vms.get(3), ns.get(2));
Quarantine q = new Quarantine(ns.get(0));
ReconfigurationPlan plan = new DefaultReconfigurationPlan(mo);
Assert.assertEquals(q.isSatisfied(plan), true);
plan.add(new ShutdownVM(vms.get(1), ns.get(1), 1, 2));
Assert.assertEquals(q.isSatisfied(plan), true);
plan.add(new BootVM(vms.get(2), ns.get(0), 0, 1));
Assert.assertEquals(q.isSatisfied(plan), false);
plan = new DefaultReconfigurationPlan(mo);
plan.add(new BootVM(vms.get(2), ns.get(2), 0, 1));
Assert.assertEquals(new Quarantine(ns.get(1)).isSatisfied(plan), true);
plan.add(new MigrateVM(vms.get(3), ns.get(2), ns.get(1), 0, 1));
Assert.assertEquals(new Quarantine(ns.get(1)).isSatisfied(plan), false);
plan = new DefaultReconfigurationPlan(mo);
plan.add(new MigrateVM(vms.get(1), ns.get(1), ns.get(0), 0, 1));
Assert.assertEquals(q.isSatisfied(plan), false);
}
use of org.btrplace.plan.event.ShutdownVM in project scheduler by btrplace.
the class RunningCapacityTest method testContinuousIsSatisfied.
@Test
public void testContinuousIsSatisfied() {
Model mo = new DefaultModel();
Mapping m = mo.getMapping();
List<Node> ns = Util.newNodes(mo, 10);
List<VM> vms = Util.newVMs(mo, 10);
m.addOnlineNode(ns.get(0));
m.addOnlineNode(ns.get(1));
m.addRunningVM(vms.get(0), ns.get(0));
m.addReadyVM(vms.get(1));
m.addRunningVM(vms.get(2), ns.get(1));
m.addReadyVM(vms.get(3));
RunningCapacity c = new RunningCapacity(m.getAllNodes(), 2);
c.setContinuous(true);
ReconfigurationPlan plan = new DefaultReconfigurationPlan(mo);
Assert.assertEquals(c.isSatisfied(plan), true);
plan.add(new BootVM(vms.get(3), ns.get(1), 2, 4));
Assert.assertEquals(c.isSatisfied(plan), false);
plan.add(new ShutdownVM(vms.get(0), ns.get(0), 0, 1));
Assert.assertEquals(c.isSatisfied(plan), true);
}
use of org.btrplace.plan.event.ShutdownVM in project scheduler by btrplace.
the class SplitTest method testContinuousIsSatisfied.
@Test
public void testContinuousIsSatisfied() {
Model mo = new DefaultModel();
Mapping map = mo.getMapping();
List<Node> ns = Util.newNodes(mo, 3);
List<VM> vms = Util.newVMs(mo, 5);
map.addOnlineNode(ns.get(0));
map.addOnlineNode(ns.get(1));
map.addOnlineNode(ns.get(2));
Collection<VM> s1 = Arrays.asList(vms.get(0), vms.get(1));
Collection<VM> s2 = Arrays.asList(vms.get(2), vms.get(3));
Collection<VM> s3 = Collections.singleton(vms.get(4));
Collection<Collection<VM>> args = Arrays.asList(s1, s2, s3);
map.addRunningVM(vms.get(0), ns.get(0));
map.addRunningVM(vms.get(1), ns.get(0));
map.addRunningVM(vms.get(2), ns.get(1));
map.addRunningVM(vms.get(3), ns.get(1));
Split sp = new Split(args, true);
ReconfigurationPlan plan = new DefaultReconfigurationPlan(mo);
Assert.assertEquals(sp.isSatisfied(plan), true);
// Violation
map.addRunningVM(vms.get(2), ns.get(0));
Assert.assertEquals(sp.isSatisfied(plan), false);
plan.add(new MigrateVM(vms.get(2), ns.get(0), ns.get(1), 0, 1));
// False cause there is the initial violation
Assert.assertEquals(sp.isSatisfied(plan), false);
sp.setContinuous(false);
Assert.assertEquals(sp.isSatisfied(plan), true);
sp.setContinuous(true);
// Temporary overlap
plan.add(new MigrateVM(vms.get(2), ns.get(1), ns.get(0), 5, 6));
plan.add(new MigrateVM(vms.get(2), ns.get(0), ns.get(1), 6, 7));
Assert.assertEquals(sp.isSatisfied(plan), false);
// Liberate ns.get(0) from vms.get(0) and vms.get(1) before
plan.add(new SuspendVM(vms.get(0), ns.get(0), ns.get(0), 2, 3));
plan.add(new ShutdownVM(vms.get(1), ns.get(0), 2, 3));
sp.setContinuous(false);
Assert.assertEquals(sp.isSatisfied(plan), true);
}
use of org.btrplace.plan.event.ShutdownVM 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.ShutdownVM 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