use of org.btrplace.scheduler.choco.duration.DurationEvaluators in project scheduler by btrplace.
the class ShutdownableNodeTest method testShutdownBeforeVMsLeave.
@Test
public void testShutdownBeforeVMsLeave() throws SchedulerException, ContradictionException {
Model mo = new DefaultModel();
Mapping map = mo.getMapping();
final VM vm1 = mo.newVM();
Node n1 = mo.newNode();
map.addOnlineNode(n1);
map.addRunningVM(vm1, n1);
Parameters ps = new DefaultParameters();
DurationEvaluators dev = ps.getDurationEvaluators();
dev.register(ShutdownVM.class, new ConstantActionDuration<>(2));
dev.register(ShutdownNode.class, new ConstantActionDuration<>(5));
ReconfigurationProblem rp = new DefaultReconfigurationProblemBuilder(mo).setNextVMsStates(Collections.singleton(vm1), Collections.emptySet(), Collections.emptySet(), Collections.emptySet()).setParams(ps).build();
ShutdownableNode ma1 = (ShutdownableNode) rp.getNodeAction(n1);
ma1.getState().instantiateTo(0, Cause.Null);
ma1.getHostingEnd().instantiateTo(0, Cause.Null);
rp.getEnd().updateUpperBound(10, Cause.Null);
ReconfigurationPlan p = rp.solve(0, false);
Assert.assertNull(p);
}
use of org.btrplace.scheduler.choco.duration.DurationEvaluators in project scheduler by btrplace.
the class ShutdownableNodeTest method testScheduledShutdown.
@Test
public void testScheduledShutdown() throws SchedulerException, ContradictionException {
Model mo = new DefaultModel();
Mapping map = mo.getMapping();
final VM vm1 = mo.newVM();
Node n1 = mo.newNode();
map.addOnlineNode(n1);
map.addRunningVM(vm1, n1);
Parameters ps = new DefaultParameters();
DurationEvaluators dev = ps.getDurationEvaluators();
dev.register(ShutdownVM.class, new ConstantActionDuration<>(2));
dev.register(ShutdownNode.class, new ConstantActionDuration<>(5));
ReconfigurationProblem rp = new DefaultReconfigurationProblemBuilder(mo).setParams(ps).setNextVMsStates(Collections.singleton(vm1), Collections.emptySet(), Collections.emptySet(), Collections.emptySet()).build();
ShutdownableNode ma = (ShutdownableNode) rp.getNodeAction(n1);
ma.getState().instantiateTo(0, Cause.Null);
ReconfigurationPlan p = rp.solve(0, false);
Assert.assertNotNull(p);
Assert.assertEquals(ma.getState().getValue(), 0);
Assert.assertEquals(ma.getDuration().getValue(), 5);
Assert.assertEquals(ma.getStart().getValue(), 2);
Assert.assertEquals(ma.getEnd().getValue(), 7);
Assert.assertEquals(ma.getHostingStart().getValue(), 0);
Assert.assertEquals(ma.getHostingEnd().getValue(), 2);
Model res = p.getResult();
Assert.assertTrue(res.getMapping().getOfflineNodes().contains(n1));
}
Aggregations