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);
}
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;
}
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;
}
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);
}
}
}
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));
}
}
Aggregations