Search in sources :

Example 26 with Mapping

use of org.btrplace.model.Mapping in project scheduler by btrplace.

the class FixedSizePartitioning method split.

@Override
public List<Instance> split(Parameters ps, Instance i) throws SchedulerException {
    Mapping map = i.getModel().getMapping();
    setPartitions(random ? randomPartitions(ps.getRandomSeed(), map) : linearPartitions(map));
    return super.split(ps, i);
}
Also used : Mapping(org.btrplace.model.Mapping)

Example 27 with Mapping

use of org.btrplace.model.Mapping in project scheduler by btrplace.

the class Instances method makeVMIndex.

/**
 * Make an index revealing the position of each VM in a collection
 * of disjoint instances
 *
 * @param instances the collection to browse. Instances are supposed to be disjoint
 * @return the index of every VM. Format {@code VM#id() -> position}
 */
public static TIntIntHashMap makeVMIndex(Collection<Instance> instances) {
    TIntIntHashMap index = new TIntIntHashMap();
    int p = 0;
    for (Instance i : instances) {
        Mapping m = i.getModel().getMapping();
        for (Node n : m.getOnlineNodes()) {
            for (VM v : m.getRunningVMs(n)) {
                index.put(v.id(), p);
            }
            for (VM v : m.getSleepingVMs(n)) {
                index.put(v.id(), p);
            }
        }
        for (VM v : m.getReadyVMs()) {
            index.put(v.id(), p);
        }
        p++;
    }
    return index;
}
Also used : Instance(org.btrplace.model.Instance) Node(org.btrplace.model.Node) VM(org.btrplace.model.VM) Mapping(org.btrplace.model.Mapping) TIntIntHashMap(gnu.trove.map.hash.TIntIntHashMap)

Example 28 with Mapping

use of org.btrplace.model.Mapping in project scheduler by btrplace.

the class Instances method makeNodeIndex.

/**
 * Make an index revealing the position of each node in a collection
 * of disjoint instances
 *
 * @param instances the collection to browse. Instances are supposed to be disjoint
 * @return the index of every node. Format {@code Node#id() -> position}
 */
public static TIntIntHashMap makeNodeIndex(Collection<Instance> instances) {
    TIntIntHashMap index = new TIntIntHashMap();
    int p = 0;
    for (Instance i : instances) {
        Mapping m = i.getModel().getMapping();
        for (Node n : m.getOfflineNodes()) {
            index.put(n.id(), p);
        }
        for (Node n : m.getOnlineNodes()) {
            index.put(n.id(), p);
        }
        p++;
    }
    return index;
}
Also used : Instance(org.btrplace.model.Instance) Node(org.btrplace.model.Node) Mapping(org.btrplace.model.Mapping) TIntIntHashMap(gnu.trove.map.hash.TIntIntHashMap)

Example 29 with Mapping

use of org.btrplace.model.Mapping in project scheduler by btrplace.

the class DefaultReconfigurationProblem method makeVMTransitions.

private void makeVMTransitions() {
    Mapping map = model.getMapping();
    vmActions = new ArrayList<>(vms.size());
    for (VM vmId : vms) {
        VMState curState = map.getState(vmId);
        if (curState == null) {
            curState = VMState.INIT;
        }
        VMState nextState;
        if (running.contains(vmId)) {
            nextState = VMState.RUNNING;
        } else if (sleeping.contains(vmId)) {
            nextState = VMState.SLEEPING;
        } else if (ready.contains(vmId)) {
            nextState = VMState.READY;
        } else if (killed.contains(vmId)) {
            nextState = VMState.KILLED;
        } else {
            // by default, maintain state
            nextState = curState;
            switch(nextState) {
                case READY:
                    ready.add(vmId);
                    break;
                case RUNNING:
                    running.add(vmId);
                    break;
                case SLEEPING:
                    sleeping.add(vmId);
                    break;
                default:
                    throw new LifeCycleViolationException(model, vmId, curState, nextState);
            }
        }
        VMTransitionBuilder am = amFactory.getBuilder(curState, nextState);
        if (am == null) {
            throw new LifeCycleViolationException(model, vmId, curState, nextState);
        }
        VMTransition t = am.build(this, vmId);
        vmActions.add(t);
        if (t.isManaged()) {
            manageable.add(vmId);
        }
    }
}
Also used : VM(org.btrplace.model.VM) VMTransition(org.btrplace.scheduler.choco.transition.VMTransition) Mapping(org.btrplace.model.Mapping) VMTransitionBuilder(org.btrplace.scheduler.choco.transition.VMTransitionBuilder) VMState(org.btrplace.model.VMState)

Example 30 with Mapping

use of org.btrplace.model.Mapping in project scheduler by btrplace.

the class DefaultReconfigurationProblem method makeNodeTransitions.

private void makeNodeTransitions() {
    Mapping m = model.getMapping();
    nodeActions = new ArrayList<>(nodes.size());
    for (Node nId : nodes) {
        NodeState state = m.getState(nId);
        NodeTransitionBuilder b = amFactory.getBuilder(state);
        if (b == null) {
            throw new LifeCycleViolationException(model, nId, state, EnumSet.of(NodeState.OFFLINE, NodeState.ONLINE));
        }
        nodeActions.add(b.build(this, nId));
    }
}
Also used : NodeState(org.btrplace.model.NodeState) NodeTransitionBuilder(org.btrplace.scheduler.choco.transition.NodeTransitionBuilder) Node(org.btrplace.model.Node) Mapping(org.btrplace.model.Mapping)

Aggregations

Mapping (org.btrplace.model.Mapping)83 Node (org.btrplace.model.Node)68 VM (org.btrplace.model.VM)62 Model (org.btrplace.model.Model)42 DefaultModel (org.btrplace.model.DefaultModel)39 Test (org.testng.annotations.Test)39 HashSet (java.util.HashSet)29 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)23 ShareableResource (org.btrplace.model.view.ShareableResource)16 RelocatableVM (org.btrplace.scheduler.choco.transition.RelocatableVM)16 BootableNode (org.btrplace.scheduler.choco.transition.BootableNode)15 ShutdownableNode (org.btrplace.scheduler.choco.transition.ShutdownableNode)15 VMTransition (org.btrplace.scheduler.choco.transition.VMTransition)15 IntVar (org.chocosolver.solver.variables.IntVar)15 SatConstraint (org.btrplace.model.constraint.SatConstraint)14 BootVM (org.btrplace.scheduler.choco.transition.BootVM)14 ForgeVM (org.btrplace.scheduler.choco.transition.ForgeVM)14 KillVM (org.btrplace.scheduler.choco.transition.KillVM)14 ResumeVM (org.btrplace.scheduler.choco.transition.ResumeVM)14 ShutdownVM (org.btrplace.scheduler.choco.transition.ShutdownVM)14