Search in sources :

Example 11 with CMinMTTR

use of org.btrplace.scheduler.choco.constraint.mttr.CMinMTTR in project scheduler by btrplace.

the class SuspendVMTest method testSuspendSequences.

/**
 * Test that check that the action duration is lesser than
 * the cSlice duration. This allows actions scheduling
 * In practice, for this test, 2 suspend actions have to be executed sequentially
 */
@Test
public void testSuspendSequences() throws SchedulerException, ContradictionException {
    Model mo = new DefaultModel();
    VM vm1 = mo.newVM();
    VM vm2 = mo.newVM();
    Node n1 = mo.newNode();
    Mapping map = mo.getMapping();
    map.addOnlineNode(n1);
    map.addRunningVM(vm1, n1);
    map.addRunningVM(vm2, n1);
    Parameters ps = new DefaultParameters();
    DurationEvaluators dev = ps.getDurationEvaluators();
    dev.register(org.btrplace.plan.event.SuspendVM.class, new ConstantActionDuration<>(5));
    ReconfigurationProblem rp = new DefaultReconfigurationProblemBuilder(mo).setParams(ps).setNextVMsStates(new HashSet<>(), new HashSet<>(), map.getAllVMs(), new HashSet<>()).build();
    SuspendVM m1 = (SuspendVM) rp.getVMActions().get(rp.getVM(vm1));
    SuspendVM m2 = (SuspendVM) rp.getVMActions().get(rp.getVM(vm2));
    rp.getNodeActions().get(0).getState().instantiateTo(1, Cause.Null);
    org.chocosolver.solver.Model csp = rp.getModel();
    csp.post(csp.arithm(m2.getStart(), ">=", m1.getEnd()));
    new CMinMTTR().inject(ps, rp);
    ReconfigurationPlan p = rp.solve(0, false);
    Assert.assertNotNull(p);
    Iterator<Action> ite = p.iterator();
    org.btrplace.plan.event.SuspendVM b1 = (org.btrplace.plan.event.SuspendVM) ite.next();
    org.btrplace.plan.event.SuspendVM b2 = (org.btrplace.plan.event.SuspendVM) ite.next();
    Assert.assertEquals(vm1, b1.getVM());
    Assert.assertEquals(vm2, b2.getVM());
    Assert.assertTrue(b1.getEnd() <= b2.getStart());
    Assert.assertEquals(5, b1.getEnd() - b1.getStart());
    Assert.assertEquals(5, b2.getEnd() - b2.getStart());
}
Also used : Action(org.btrplace.plan.event.Action) Parameters(org.btrplace.scheduler.choco.Parameters) DefaultParameters(org.btrplace.scheduler.choco.DefaultParameters) 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) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 12 with CMinMTTR

use of org.btrplace.scheduler.choco.constraint.mttr.CMinMTTR in project scheduler by btrplace.

the class SuspendVMTest method testBasic.

@Test
public void testBasic() throws ContradictionException, SchedulerException {
    Model mo = new DefaultModel();
    VM vm1 = mo.newVM();
    Node n1 = mo.newNode();
    Mapping map = mo.getMapping();
    map.addOnlineNode(n1);
    map.addRunningVM(vm1, n1);
    Parameters ps = new DefaultParameters();
    DurationEvaluators dev = ps.getDurationEvaluators();
    dev.register(org.btrplace.plan.event.SuspendVM.class, new ConstantActionDuration<>(5));
    ReconfigurationProblem rp = new DefaultReconfigurationProblemBuilder(mo).setParams(ps).setNextVMsStates(new HashSet<>(), new HashSet<>(), map.getAllVMs(), new HashSet<>()).build();
    rp.getNodeActions().get(0).getState().instantiateTo(1, Cause.Null);
    SuspendVM m = (SuspendVM) rp.getVMActions().get(0);
    Assert.assertEquals(vm1, m.getVM());
    Assert.assertNull(m.getDSlice());
    Assert.assertTrue(m.getDuration().isInstantiatedTo(5));
    Assert.assertTrue(m.getState().isInstantiatedTo(0));
    Assert.assertTrue(m.getCSlice().getHoster().isInstantiatedTo(0));
    new CMinMTTR().inject(ps, rp);
    ReconfigurationPlan p = rp.solve(0, false);
    org.btrplace.plan.event.SuspendVM a = (org.btrplace.plan.event.SuspendVM) p.getActions().iterator().next();
    Assert.assertEquals(n1, a.getSourceNode());
    Assert.assertEquals(vm1, a.getVM());
    Assert.assertEquals(5, a.getEnd() - a.getStart());
}
Also used : Parameters(org.btrplace.scheduler.choco.Parameters) DefaultParameters(org.btrplace.scheduler.choco.DefaultParameters) 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) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 13 with CMinMTTR

use of org.btrplace.scheduler.choco.constraint.mttr.CMinMTTR in project scheduler by btrplace.

the class BootVMTest method testBasics.

/**
 * Just boot a VM on a  node.
 */
@Test
public void testBasics() throws SchedulerException, ContradictionException {
    Model mo = new DefaultModel();
    Mapping map = mo.getMapping();
    final VM vm1 = mo.newVM();
    Node n1 = mo.newNode();
    Node n2 = mo.newNode();
    map.addOnlineNode(n1);
    map.addOnlineNode(n2);
    map.addReadyVM(vm1);
    Parameters ps = new DefaultParameters();
    DurationEvaluators dev = ps.getDurationEvaluators();
    dev.register(org.btrplace.plan.event.BootVM.class, new ConstantActionDuration<>(5));
    ReconfigurationProblem rp = new DefaultReconfigurationProblemBuilder(mo).setParams(ps).setNextVMsStates(new HashSet<>(), map.getAllVMs(), new HashSet<>(), new HashSet<>()).build();
    rp.getNodeActions().get(0).getState().instantiateTo(1, Cause.Null);
    rp.getNodeActions().get(1).getState().instantiateTo(1, Cause.Null);
    BootVM m = (BootVM) rp.getVMActions().get(0);
    Assert.assertEquals(vm1, m.getVM());
    Assert.assertNull(m.getCSlice());
    Assert.assertTrue(m.getDuration().isInstantiatedTo(5));
    Assert.assertTrue(m.getState().isInstantiatedTo(1));
    Assert.assertFalse(m.getDSlice().getHoster().isInstantiated());
    Assert.assertFalse(m.getDSlice().getStart().isInstantiated());
    Assert.assertFalse(m.getDSlice().getEnd().isInstantiated());
    new CMinMTTR().inject(ps, rp);
    ReconfigurationPlan p = rp.solve(0, false);
    Assert.assertNotNull(p);
    org.btrplace.plan.event.BootVM a = (org.btrplace.plan.event.BootVM) p.getActions().iterator().next();
    Node dest = rp.getNode(m.getDSlice().getHoster().getValue());
    Assert.assertEquals(vm1, a.getVM());
    Assert.assertEquals(dest, a.getDestinationNode());
    Assert.assertEquals(5, a.getEnd() - a.getStart());
}
Also used : Parameters(org.btrplace.scheduler.choco.Parameters) DefaultParameters(org.btrplace.scheduler.choco.DefaultParameters) 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) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 14 with CMinMTTR

use of org.btrplace.scheduler.choco.constraint.mttr.CMinMTTR in project scheduler by btrplace.

the class BootableNodeTest method testBootCascade.

@Test
public void testBootCascade() throws SchedulerException, ContradictionException {
    Model mo = new DefaultModel();
    Mapping map = mo.getMapping();
    Node n1 = mo.newNode();
    Node n2 = mo.newNode();
    map.addOfflineNode(n1);
    map.addOfflineNode(n2);
    Parameters ps = new DefaultParameters();
    DurationEvaluators dev = ps.getDurationEvaluators();
    dev.register(BootNode.class, new ConstantActionDuration<>(5));
    ReconfigurationProblem rp = new DefaultReconfigurationProblemBuilder(mo).setParams(ps).build();
    BootableNode na1 = (BootableNode) rp.getNodeAction(n1);
    BootableNode na2 = (BootableNode) rp.getNodeAction(n2);
    na1.getState().instantiateTo(1, Cause.Null);
    na2.getState().instantiateTo(1, Cause.Null);
    rp.getModel().post(rp.getModel().arithm(na1.getEnd(), "=", na2.getEnd()));
    new CMinMTTR().inject(ps, rp);
    Assert.assertNotNull(rp.solve(0, false));
}
Also used : BootNode(org.btrplace.plan.event.BootNode) ShutdownNode(org.btrplace.plan.event.ShutdownNode) DurationEvaluators(org.btrplace.scheduler.choco.duration.DurationEvaluators) CMinMTTR(org.btrplace.scheduler.choco.constraint.mttr.CMinMTTR) Test(org.testng.annotations.Test)

Example 15 with CMinMTTR

use of org.btrplace.scheduler.choco.constraint.mttr.CMinMTTR in project scheduler by btrplace.

the class KillVMTest method testBasics.

/**
 * Test the action model with different action models.
 *
 * @throws ContradictionException
 * @throws org.btrplace.scheduler.SchedulerException
 */
@Test
public void testBasics() throws ContradictionException, SchedulerException {
    Model mo = new DefaultModel();
    Mapping map = mo.getMapping();
    Node n1 = mo.newNode();
    map.addOnlineNode(n1);
    VM vm1 = mo.newVM();
    map.addRunningVM(vm1, n1);
    VM vm2 = mo.newVM();
    map.addReadyVM(vm2);
    VM vm3 = mo.newVM();
    map.addSleepingVM(vm3, n1);
    Set<VM> empty = new HashSet<>();
    DurationEvaluators dev = new DurationEvaluators();
    dev.register(org.btrplace.plan.event.KillVM.class, new ConstantActionDuration<>(1));
    Parameters ps = new DefaultParameters();
    ReconfigurationProblem rp = new DefaultReconfigurationProblemBuilder(mo).setNextVMsStates(empty, empty, empty, map.getAllVMs()).setParams(ps).build();
    rp.getNodeAction(n1).getState().instantiateTo(rp.getVM(vm1), Cause.Null);
    // Common stuff
    for (VM vm : map.getAllVMs()) {
        KillVM m = (KillVM) rp.getVMAction(vm);
        Assert.assertEquals(vm, m.getVM());
        Assert.assertTrue(m.getState().isInstantiatedTo(0));
        Assert.assertNull(m.getDSlice());
        Assert.assertTrue(m.getDuration().isInstantiatedTo(1));
        Assert.assertTrue(m.getStart().isInstantiatedTo(0));
        Assert.assertTrue(m.getEnd().isInstantiatedTo(1));
    }
    // The waiting and the sleeping VM have no CSlice
    Assert.assertNull(rp.getVMAction(vm2).getCSlice());
    Assert.assertNull(rp.getVMAction(vm3).getCSlice());
    // The running VM has a CSlice
    Assert.assertNotNull(rp.getVMAction(vm1).getCSlice());
    Assert.assertTrue(rp.getVMAction(vm1).getCSlice().getHoster().isInstantiatedTo(rp.getNode(n1)));
    new CMinMTTR().inject(ps, rp);
    ReconfigurationPlan p = rp.solve(0, false);
    Assert.assertNotNull(p);
    for (Action a : p) {
        if (a instanceof org.btrplace.plan.event.KillVM) {
            org.btrplace.plan.event.KillVM vma = (org.btrplace.plan.event.KillVM) a;
            Assert.assertEquals(1, a.getEnd());
            Assert.assertEquals(0, a.getStart());
            if (vma.getVM().equals(vm1) || vma.getVM().equals(vm3)) {
                Assert.assertEquals(vma.getNode(), n1);
            } else if (vma.getVM().equals(vm2)) {
                Assert.assertNull(vma.getNode());
            } else {
                Assert.fail();
            }
        }
    }
}
Also used : Action(org.btrplace.plan.event.Action) Parameters(org.btrplace.scheduler.choco.Parameters) DefaultParameters(org.btrplace.scheduler.choco.DefaultParameters) 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) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Aggregations

CMinMTTR (org.btrplace.scheduler.choco.constraint.mttr.CMinMTTR)19 Test (org.testng.annotations.Test)19 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)18 DurationEvaluators (org.btrplace.scheduler.choco.duration.DurationEvaluators)17 DefaultParameters (org.btrplace.scheduler.choco.DefaultParameters)14 DefaultReconfigurationProblemBuilder (org.btrplace.scheduler.choco.DefaultReconfigurationProblemBuilder)14 Parameters (org.btrplace.scheduler.choco.Parameters)14 ReconfigurationProblem (org.btrplace.scheduler.choco.ReconfigurationProblem)14 HashSet (java.util.HashSet)8 DefaultModel (org.btrplace.model.DefaultModel)8 Mapping (org.btrplace.model.Mapping)8 Model (org.btrplace.model.Model)8 Node (org.btrplace.model.Node)8 VM (org.btrplace.model.VM)8 Action (org.btrplace.plan.event.Action)7 MigrateVM (org.btrplace.plan.event.MigrateVM)6 ShutdownNode (org.btrplace.plan.event.ShutdownNode)4 BootNode (org.btrplace.plan.event.BootNode)3 IntVar (org.chocosolver.solver.variables.IntVar)2 OptConstraint (org.btrplace.model.constraint.OptConstraint)1