Search in sources :

Example 21 with ReconfigurationPlan

use of org.btrplace.plan.ReconfigurationPlan in project scheduler by btrplace.

the class BootableNodeTest method testForcingOffline.

@Test
public void testForcingOffline() throws SchedulerException, ContradictionException {
    Model mo = new DefaultModel();
    Mapping map = mo.getMapping();
    Node n1 = mo.newNode();
    map.addOfflineNode(n1);
    Parameters ps = new DefaultParameters();
    DurationEvaluators dev = ps.getDurationEvaluators();
    dev.register(BootNode.class, new ConstantActionDuration<>(5));
    ReconfigurationProblem rp = new DefaultReconfigurationProblemBuilder(mo).setParams(ps).build();
    BootableNode na = (BootableNode) rp.getNodeAction(n1);
    na.getState().instantiateTo(0, Cause.Null);
    ReconfigurationPlan p = rp.solve(0, false);
    Assert.assertNotNull(p);
    Assert.assertEquals(na.getDuration().getValue(), 0);
    Assert.assertEquals(na.getStart().getValue(), 0);
    Assert.assertEquals(na.getEnd().getValue(), 0);
    Assert.assertEquals(na.getHostingStart().getValue(), rp.getEnd().getValue());
    Assert.assertEquals(na.getHostingEnd().getValue(), rp.getEnd().getValue());
    Assert.assertNotNull(p);
    Assert.assertEquals(p.getSize(), 0);
    Model res = p.getResult();
    Assert.assertTrue(res.getMapping().getOfflineNodes().contains(n1));
}
Also used : BootNode(org.btrplace.plan.event.BootNode) ShutdownNode(org.btrplace.plan.event.ShutdownNode) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) DurationEvaluators(org.btrplace.scheduler.choco.duration.DurationEvaluators) Test(org.testng.annotations.Test)

Example 22 with ReconfigurationPlan

use of org.btrplace.plan.ReconfigurationPlan in project scheduler by btrplace.

the class BootableNodeTest method testRequiredOnline.

@Test
public void testRequiredOnline() throws SchedulerException {
    Model mo = new DefaultModel();
    Mapping map = mo.getMapping();
    VM vm1 = mo.newVM();
    Node n1 = mo.newNode();
    map.addOfflineNode(n1);
    map.addReadyVM(vm1);
    ChocoScheduler s = new DefaultChocoScheduler();
    Parameters ps = s.getParameters();
    DurationEvaluators dev = ps.getDurationEvaluators();
    dev.register(BootNode.class, new ConstantActionDuration<>(5));
    dev.register(BootVM.class, new ConstantActionDuration<>(2));
    ReconfigurationPlan plan = s.solve(mo, Collections.singleton(new Running(vm1)));
    Assert.assertNotNull(plan);
    Assert.assertEquals(plan.getSize(), 2);
    for (Action a : plan.getActions()) {
        if (a instanceof BootNode) {
            Assert.assertEquals(a.getStart(), 0);
            Assert.assertEquals(a.getEnd(), 5);
        } else {
            Assert.assertEquals(a.getStart(), 5);
            Assert.assertEquals(a.getEnd(), 7);
        }
    }
}
Also used : Action(org.btrplace.plan.event.Action) BootNode(org.btrplace.plan.event.BootNode) BootNode(org.btrplace.plan.event.BootNode) ShutdownNode(org.btrplace.plan.event.ShutdownNode) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) BootVM(org.btrplace.plan.event.BootVM) Running(org.btrplace.model.constraint.Running) DurationEvaluators(org.btrplace.scheduler.choco.duration.DurationEvaluators) Test(org.testng.annotations.Test)

Example 23 with ReconfigurationPlan

use of org.btrplace.plan.ReconfigurationPlan in project scheduler by btrplace.

the class BootableNodeTest method testDelayedBooting.

@Test
public void testDelayedBooting() throws ContradictionException, SchedulerException {
    Model mo = new DefaultModel();
    Mapping map = mo.getMapping();
    Node n2 = mo.newNode();
    map.addOfflineNode(n2);
    Parameters ps = new DefaultParameters();
    DurationEvaluators dev = ps.getDurationEvaluators();
    dev.register(BootNode.class, new ConstantActionDuration<>(2));
    ReconfigurationProblem rp = new DefaultReconfigurationProblemBuilder(mo).setParams(ps).build();
    BootableNode ma2 = (BootableNode) rp.getNodeAction(n2);
    ma2.getState().instantiateTo(1, Cause.Null);
    ma2.getStart().updateLowerBound(5, Cause.Null);
    new CMinMTTR().inject(ps, rp);
    ReconfigurationPlan p = rp.solve(0, false);
    // ChocoLogging.flushLogs();
    Assert.assertNotNull(p);
}
Also used : BootNode(org.btrplace.plan.event.BootNode) ShutdownNode(org.btrplace.plan.event.ShutdownNode) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) DurationEvaluators(org.btrplace.scheduler.choco.duration.DurationEvaluators) CMinMTTR(org.btrplace.scheduler.choco.constraint.mttr.CMinMTTR) Test(org.testng.annotations.Test)

Example 24 with ReconfigurationPlan

use of org.btrplace.plan.ReconfigurationPlan in project scheduler by btrplace.

the class BootableNodeTest method testActionDurationSimple.

/**
 * Unit test for issue #3
 */
@Test
public void testActionDurationSimple() throws SchedulerException, ContradictionException {
    Model model = new DefaultModel();
    Mapping map = model.getMapping();
    Node n1 = model.newNode();
    Node n4 = model.newNode();
    map.addOnlineNode(n1);
    map.addOfflineNode(n4);
    Parameters ps = new DefaultParameters();
    DurationEvaluators dev = ps.getDurationEvaluators();
    dev.register(ShutdownNode.class, new ConstantActionDuration<>(5));
    dev.register(BootNode.class, new ConstantActionDuration<>(3));
    ReconfigurationProblem rp = new DefaultReconfigurationProblemBuilder(model).setParams(ps).build();
    ShutdownableNode sn1 = (ShutdownableNode) rp.getNodeAction(n1);
    sn1.getState().instantiateTo(0, Cause.Null);
    BootableNode bn4 = (BootableNode) rp.getNodeAction(n4);
    bn4.getState().instantiateTo(0, Cause.Null);
    new CMinMTTR().inject(ps, rp);
    ReconfigurationPlan p = rp.solve(0, false);
    Assert.assertNotNull(p);
    Assert.assertEquals(bn4.getStart().getValue(), 0);
    Assert.assertEquals(bn4.getDuration().getValue(), 0);
    Assert.assertEquals(bn4.getEnd().getValue(), 0);
    Assert.assertEquals(bn4.getHostingStart().getValue(), 0);
    Assert.assertEquals(bn4.getHostingEnd().getValue(), 0);
    Assert.assertEquals(p.getSize(), 1);
    Model res = p.getResult();
    Assert.assertTrue(res.getMapping().getOfflineNodes().contains(n1));
    Assert.assertTrue(res.getMapping().getOfflineNodes().contains(n4));
}
Also used : BootNode(org.btrplace.plan.event.BootNode) ShutdownNode(org.btrplace.plan.event.ShutdownNode) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) DurationEvaluators(org.btrplace.scheduler.choco.duration.DurationEvaluators) CMinMTTR(org.btrplace.scheduler.choco.constraint.mttr.CMinMTTR) Test(org.testng.annotations.Test)

Example 25 with ReconfigurationPlan

use of org.btrplace.plan.ReconfigurationPlan in project scheduler by btrplace.

the class ForgeVMTest method testResolution.

@Test
public void testResolution() throws SchedulerException, ContradictionException {
    Model mo = new DefaultModel();
    Mapping m = mo.getMapping();
    final VM vm1 = mo.newVM();
    Node n1 = mo.newNode();
    m.addOnlineNode(n1);
    mo.getAttributes().put(vm1, "template", "small");
    Parameters ps = new DefaultParameters();
    DurationEvaluators dev = ps.getDurationEvaluators();
    dev.register(org.btrplace.plan.event.ForgeVM.class, new ConstantActionDuration<>(7));
    dev.register(ShutdownNode.class, new ConstantActionDuration<>(20));
    ReconfigurationProblem rp = new DefaultReconfigurationProblemBuilder(mo).setParams(ps).setNextVMsStates(Collections.singleton(vm1), Collections.emptySet(), Collections.emptySet(), Collections.emptySet()).build();
    // Force the node to get offline
    ShutdownableNode n = (ShutdownableNode) rp.getNodeAction(n1);
    n.getState().instantiateTo(0, Cause.Null);
    new CMinMTTR().inject(ps, rp);
    ReconfigurationPlan p = rp.solve(0, false);
    Assert.assertNotNull(p);
    Assert.assertEquals(p.getDuration(), 20);
    for (Action a : p) {
        if (a instanceof org.btrplace.plan.event.ForgeVM) {
            org.btrplace.plan.event.ForgeVM action = (org.btrplace.plan.event.ForgeVM) a;
            Assert.assertTrue(p.getResult().getMapping().isReady(vm1));
            Assert.assertEquals(action.getVM(), vm1);
            Assert.assertEquals(action.getEnd(), 7);
            Assert.assertEquals(action.getStart(), 0);
        }
    }
}
Also used : Action(org.btrplace.plan.event.Action) Parameters(org.btrplace.scheduler.choco.Parameters) DefaultParameters(org.btrplace.scheduler.choco.DefaultParameters) ShutdownNode(org.btrplace.plan.event.ShutdownNode) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) ReconfigurationProblem(org.btrplace.scheduler.choco.ReconfigurationProblem) DefaultParameters(org.btrplace.scheduler.choco.DefaultParameters) DurationEvaluators(org.btrplace.scheduler.choco.duration.DurationEvaluators) DefaultReconfigurationProblemBuilder(org.btrplace.scheduler.choco.DefaultReconfigurationProblemBuilder) CMinMTTR(org.btrplace.scheduler.choco.constraint.mttr.CMinMTTR) Test(org.testng.annotations.Test)

Aggregations

ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)185 Test (org.testng.annotations.Test)160 DefaultChocoScheduler (org.btrplace.scheduler.choco.DefaultChocoScheduler)94 ChocoScheduler (org.btrplace.scheduler.choco.ChocoScheduler)74 SatConstraint (org.btrplace.model.constraint.SatConstraint)53 ShareableResource (org.btrplace.model.view.ShareableResource)52 Model (org.btrplace.model.Model)49 ArrayList (java.util.ArrayList)46 Node (org.btrplace.model.Node)45 DefaultModel (org.btrplace.model.DefaultModel)44 VM (org.btrplace.model.VM)41 MigrateVM (org.btrplace.plan.event.MigrateVM)37 DurationEvaluators (org.btrplace.scheduler.choco.duration.DurationEvaluators)34 DefaultParameters (org.btrplace.scheduler.choco.DefaultParameters)32 Parameters (org.btrplace.scheduler.choco.Parameters)29 ReconfigurationProblem (org.btrplace.scheduler.choco.ReconfigurationProblem)29 DefaultReconfigurationProblemBuilder (org.btrplace.scheduler.choco.DefaultReconfigurationProblemBuilder)28 DefaultReconfigurationPlan (org.btrplace.plan.DefaultReconfigurationPlan)24 Mapping (org.btrplace.model.Mapping)23 HashSet (java.util.HashSet)22