Search in sources :

Example 1 with NodeTransition

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

the class CPowerView method inject.

@Override
public boolean inject(Parameters ps, ReconfigurationProblem rp) throws SchedulerException {
    powerStarts = new TIntObjectHashMap<>(rp.getNodes().size());
    powerEnds = new TIntObjectHashMap<>(rp.getNodes().size());
    for (Node n : rp.getNodes()) {
        NodeTransition na = rp.getNodeAction(n);
        if (na instanceof ShutdownableNode) {
            powerStarts.put(rp.getNode(n), rp.getStart());
            IntVar powerEnd = rp.makeUnboundedDuration("NodeActionType(", n, ").Pe");
            TaskMonitor.build(na.getHostingEnd(), na.getDuration(), powerEnd);
            powerEnds.put(rp.getNode(n), powerEnd);
            rp.getModel().post(rp.getModel().arithm(powerEnd, "<=", rp.getEnd()));
        } else if (na instanceof BootableNode) {
            powerStarts.put(rp.getNode(n), na.getStart());
            powerEnds.put(rp.getNode(n), rp.getEnd());
        }
    }
    return true;
}
Also used : ShutdownableNode(org.btrplace.scheduler.choco.transition.ShutdownableNode) BootableNode(org.btrplace.scheduler.choco.transition.BootableNode) Node(org.btrplace.model.Node) NodeTransition(org.btrplace.scheduler.choco.transition.NodeTransition) ShutdownableNode(org.btrplace.scheduler.choco.transition.ShutdownableNode) BootableNode(org.btrplace.scheduler.choco.transition.BootableNode) IntVar(org.chocosolver.solver.variables.IntVar)

Example 2 with NodeTransition

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

the class COffline method inject.

@Override
public boolean inject(Parameters ps, ReconfigurationProblem rp) throws SchedulerException {
    if (cstr.isContinuous() && !cstr.getChecker().startsWith(rp.getSourceModel())) {
        rp.getLogger().debug("Constraint {} is not satisfied initially", cstr);
        return false;
    }
    Node nId = cstr.getInvolvedNodes().iterator().next();
    int id = rp.getNode(nId);
    NodeTransition m = rp.getNodeAction(nId);
    try {
        m.getState().instantiateTo(0, Cause.Null);
        if (rp.getSourceModel().getMapping().isOffline(nId)) {
            m.getStart().instantiateTo(0, Cause.Null);
        }
    } catch (ContradictionException ex) {
        rp.getLogger().debug("Unable to force node '" + nId + "' at being offline", ex);
        return false;
    }
    for (VMTransition am : rp.getVMActions()) {
        Slice s = am.getDSlice();
        if (s != null) {
            try {
                s.getHoster().removeValue(id, Cause.Null);
            } catch (ContradictionException e) {
                rp.getLogger().debug("Unable to remove " + am.getVM() + " of node " + nId, e);
            }
        }
    }
    return true;
}
Also used : ContradictionException(org.chocosolver.solver.exception.ContradictionException) Slice(org.btrplace.scheduler.choco.Slice) Node(org.btrplace.model.Node) NodeTransition(org.btrplace.scheduler.choco.transition.NodeTransition) VMTransition(org.btrplace.scheduler.choco.transition.VMTransition)

Example 3 with NodeTransition

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

the class DefaultReconfigurationProblemTest method testNodeOn.

@Test
public void testNodeOn() throws SchedulerException {
    Model mo = new DefaultModel();
    Mapping m = mo.getMapping();
    Node n1 = mo.newNode();
    m.addOnlineNode(n1);
    DefaultReconfigurationProblem rp = new DefaultReconfigurationProblemBuilder(mo).setNextVMsStates(new HashSet<>(), new HashSet<>(), new HashSet<>(), new HashSet<>()).build();
    NodeTransition a = rp.getNodeActions().get(0);
    Assert.assertEquals(a, rp.getNodeAction(n1));
    Assert.assertEquals(ShutdownableNode.class, a.getClass());
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) ShutdownableNode(org.btrplace.scheduler.choco.transition.ShutdownableNode) Node(org.btrplace.model.Node) BootableNode(org.btrplace.scheduler.choco.transition.BootableNode) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) NodeTransition(org.btrplace.scheduler.choco.transition.NodeTransition) Mapping(org.btrplace.model.Mapping) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 4 with NodeTransition

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

the class DefaultReconfigurationProblemTest method testNodeOff.

@Test
public void testNodeOff() throws SchedulerException {
    Model mo = new DefaultModel();
    VM vm1 = mo.newVM();
    VM vm2 = mo.newVM();
    VM vm3 = mo.newVM();
    VM vm4 = mo.newVM();
    VM vm5 = mo.newVM();
    VM vm6 = mo.newVM();
    Node n1 = mo.newNode();
    Node n2 = mo.newNode();
    Node n3 = mo.newNode();
    Mapping map = mo.getMapping();
    map.addOnlineNode(n1);
    map.addOnlineNode(n2);
    map.addOfflineNode(n3);
    map.addRunningVM(vm1, n1);
    map.addRunningVM(vm2, n1);
    map.addRunningVM(vm3, n2);
    map.addSleepingVM(vm4, n2);
    map.addReadyVM(vm5);
    map.addReadyVM(vm6);
    Mapping m = mo.getMapping();
    m.addOfflineNode(n1);
    DefaultReconfigurationProblem rp = new DefaultReconfigurationProblemBuilder(mo).setNextVMsStates(new HashSet<>(), new HashSet<>(), new HashSet<>(), new HashSet<>()).build();
    NodeTransition a = rp.getNodeActions().get(rp.getNode(n3));
    Assert.assertEquals(a, rp.getNodeAction(n3));
    Assert.assertEquals(BootableNode.class, a.getClass());
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) SuspendVM(org.btrplace.scheduler.choco.transition.SuspendVM) RelocatableVM(org.btrplace.scheduler.choco.transition.RelocatableVM) VM(org.btrplace.model.VM) StayAwayVM(org.btrplace.scheduler.choco.transition.StayAwayVM) ResumeVM(org.btrplace.scheduler.choco.transition.ResumeVM) KillVM(org.btrplace.scheduler.choco.transition.KillVM) BootVM(org.btrplace.scheduler.choco.transition.BootVM) ForgeVM(org.btrplace.scheduler.choco.transition.ForgeVM) ShutdownVM(org.btrplace.scheduler.choco.transition.ShutdownVM) ShutdownableNode(org.btrplace.scheduler.choco.transition.ShutdownableNode) Node(org.btrplace.model.Node) BootableNode(org.btrplace.scheduler.choco.transition.BootableNode) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) NodeTransition(org.btrplace.scheduler.choco.transition.NodeTransition) Mapping(org.btrplace.model.Mapping) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 5 with NodeTransition

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

the class CMinMTTRMig method inject.

@Override
public boolean inject(Parameters ps, ReconfigurationProblem rp) throws SchedulerException {
    this.rp = rp;
    List<IntVar> endVars = new ArrayList<>();
    // Define the cost constraint: sum of all actions' end time
    for (VMTransition m : rp.getVMActions()) {
        endVars.add(m.getEnd());
    }
    for (NodeTransition m : rp.getNodeActions()) {
        endVars.add(m.getEnd());
    }
    IntVar[] costs = endVars.toArray(new IntVar[endVars.size()]);
    IntVar cost = rp.getModel().intVar(rp.makeVarLabel("costEndVars"), 0, Integer.MAX_VALUE / 100, true);
    costConstraints.add(rp.getModel().sum(costs, "=", cost));
    // Set the objective, minimize the cost
    rp.setObjective(true, cost);
    // Inject the scheduling heuristic
    injectSchedulingHeuristic(cost);
    // Post the cost constraint
    postCostConstraints();
    return true;
}
Also used : ArrayList(java.util.ArrayList) VMTransition(org.btrplace.scheduler.choco.transition.VMTransition) NodeTransition(org.btrplace.scheduler.choco.transition.NodeTransition) IntVar(org.chocosolver.solver.variables.IntVar)

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