Search in sources :

Example 6 with NodeTransition

use of org.btrplace.scheduler.choco.transition.NodeTransition in project scheduler by btrplace.

the class IssuesTest method issue33.

@Test
public void issue33() throws SchedulerException, ContradictionException {
    Model mo = new DefaultModel();
    Node n = mo.newNode();
    VM v = mo.newVM();
    mo.getMapping().addOnlineNode(n);
    mo.getMapping().addRunningVM(v, n);
    ReconfigurationProblem rp = new DefaultReconfigurationProblemBuilder(mo).setNextVMsStates(Collections.emptySet(), Collections.emptySet(), Collections.singleton(v), Collections.emptySet()).build();
    NodeTransition na = rp.getNodeAction(n);
    na.getStart().instantiateTo(0, Cause.Null);
    na.getEnd().instantiateTo(1, Cause.Null);
    VMTransition vma = rp.getVMAction(v);
    vma.getStart().instantiateTo(0, Cause.Null);
    vma.getEnd().instantiateTo(1, Cause.Null);
    ReconfigurationPlan plan = rp.solve(0, false);
    Assert.assertEquals(plan, null);
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Node(org.btrplace.model.Node) VM(org.btrplace.model.VM) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) NodeTransition(org.btrplace.scheduler.choco.transition.NodeTransition) VMTransition(org.btrplace.scheduler.choco.transition.VMTransition) Test(org.testng.annotations.Test)

Example 7 with NodeTransition

use of org.btrplace.scheduler.choco.transition.NodeTransition in project scheduler by btrplace.

the class COnline method inject.

@Override
public boolean inject(Parameters ps, ReconfigurationProblem rp) throws SchedulerException {
    if (cstr.isContinuous() && !cstr.getChecker().startsWith(rp.getSourceModel())) {
        rp.getLogger().error("Constraint {} is not satisfied initially", cstr);
        return false;
    }
    Node nId = cstr.getInvolvedNodes().iterator().next();
    NodeTransition m = rp.getNodeAction(nId);
    try {
        m.getState().instantiateTo(1, Cause.Null);
        if (rp.getSourceModel().getMapping().isOnline(nId)) {
            m.getStart().instantiateTo(0, Cause.Null);
        }
    } catch (ContradictionException ex) {
        rp.getLogger().error("Unable to force node '" + nId + "' at being online", ex);
        return false;
    }
    return true;
}
Also used : ContradictionException(org.chocosolver.solver.exception.ContradictionException) Node(org.btrplace.model.Node) NodeTransition(org.btrplace.scheduler.choco.transition.NodeTransition)

Aggregations

NodeTransition (org.btrplace.scheduler.choco.transition.NodeTransition)7 Node (org.btrplace.model.Node)6 DefaultModel (org.btrplace.model.DefaultModel)3 Model (org.btrplace.model.Model)3 BootableNode (org.btrplace.scheduler.choco.transition.BootableNode)3 ShutdownableNode (org.btrplace.scheduler.choco.transition.ShutdownableNode)3 VMTransition (org.btrplace.scheduler.choco.transition.VMTransition)3 Test (org.testng.annotations.Test)3 HashSet (java.util.HashSet)2 Mapping (org.btrplace.model.Mapping)2 VM (org.btrplace.model.VM)2 ContradictionException (org.chocosolver.solver.exception.ContradictionException)2 IntVar (org.chocosolver.solver.variables.IntVar)2 ArrayList (java.util.ArrayList)1 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)1 Slice (org.btrplace.scheduler.choco.Slice)1 BootVM (org.btrplace.scheduler.choco.transition.BootVM)1 ForgeVM (org.btrplace.scheduler.choco.transition.ForgeVM)1 KillVM (org.btrplace.scheduler.choco.transition.KillVM)1 RelocatableVM (org.btrplace.scheduler.choco.transition.RelocatableVM)1