Search in sources :

Example 36 with Parameters

use of org.btrplace.scheduler.choco.Parameters 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));
}
Also used : Parameters(org.btrplace.scheduler.choco.Parameters) DefaultParameters(org.btrplace.scheduler.choco.DefaultParameters) BootNode(org.btrplace.plan.event.BootNode) ShutdownNode(org.btrplace.plan.event.ShutdownNode) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) ReconfigurationProblem(org.btrplace.scheduler.choco.ReconfigurationProblem) DefaultParameters(org.btrplace.scheduler.choco.DefaultParameters) ShutdownVM(org.btrplace.plan.event.ShutdownVM) DurationEvaluators(org.btrplace.scheduler.choco.duration.DurationEvaluators) DefaultReconfigurationProblemBuilder(org.btrplace.scheduler.choco.DefaultReconfigurationProblemBuilder) Test(org.testng.annotations.Test)

Aggregations

Parameters (org.btrplace.scheduler.choco.Parameters)36 ReconfigurationProblem (org.btrplace.scheduler.choco.ReconfigurationProblem)31 Test (org.testng.annotations.Test)31 DefaultParameters (org.btrplace.scheduler.choco.DefaultParameters)29 DefaultReconfigurationProblemBuilder (org.btrplace.scheduler.choco.DefaultReconfigurationProblemBuilder)28 DurationEvaluators (org.btrplace.scheduler.choco.duration.DurationEvaluators)28 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)27 CMinMTTR (org.btrplace.scheduler.choco.constraint.mttr.CMinMTTR)14 HashSet (java.util.HashSet)13 Model (org.btrplace.model.Model)12 Mapping (org.btrplace.model.Mapping)11 VM (org.btrplace.model.VM)11 ShutdownNode (org.btrplace.plan.event.ShutdownNode)10 BootNode (org.btrplace.plan.event.BootNode)9 DefaultModel (org.btrplace.model.DefaultModel)8 Action (org.btrplace.plan.event.Action)8 Node (org.btrplace.model.Node)7 MigrateVM (org.btrplace.plan.event.MigrateVM)7 ArrayList (java.util.ArrayList)5 Instance (org.btrplace.model.Instance)5