use of org.btrplace.model.VM in project scheduler by btrplace.
the class MovingVMs method setToNextMovingVM.
@SuppressWarnings("squid:S3346")
private boolean setToNextMovingVM(IntVar[] scopes) {
assert actions.size() == scopes.length;
for (int i = idx.get(); i < scopes.length; i++) {
IntVar h = scopes[i];
if (!h.isInstantiated()) {
VM vm = actions.get(i).getVM();
Node nId = map.getVMLocation(vm);
if (!h.contains(rp.getNode(nId))) {
// VM was running, otherwise -1 so not inside h
idx.set(i);
return true;
}
}
i++;
}
return false;
}
use of org.btrplace.model.VM in project scheduler by btrplace.
the class RandomVMPlacement method selectValue.
@Override
public int selectValue(IntVar x) {
if (stay) {
VM vm = vmPlacement.get(x);
int nIdx = canStay(rp, vm);
if (nIdx >= 0) {
Node n = rp.getSourceModel().getMapping().getVMLocation(vm);
return nodeMap[n.id()];
}
}
if (!x.isInstantiated()) {
int nIdx;
if (ranks != null) {
nIdx = randomWithRankedValues(x);
} else {
nIdx = randomValue(x);
}
return nIdx;
}
return x.getValue();
}
use of org.btrplace.model.VM in project scheduler by btrplace.
the class VMPlacementUtils method makePlacementMap.
/**
* Map a map where keys are the placement variable of the future-running VMs
* and values are the VM identifier.
*
* @param rp the problem
* @return the resulting map.
*/
public static Map<IntVar, VM> makePlacementMap(ReconfigurationProblem rp) {
Map<IntVar, VM> m = new HashMap<>(rp.getFutureRunningVMs().size());
for (VM vm : rp.getFutureRunningVMs()) {
IntVar v = rp.getVMAction(vm).getDSlice().getHoster();
m.put(v, vm);
}
return m;
}
use of org.btrplace.model.VM in project scheduler by btrplace.
the class WorstFit method selectValue.
@Override
public int selectValue(IntVar v) {
VM vm = vmMap.get(v);
if (stayFirst && canStay(vm)) {
return rp.getNode(rp.getSourceModel().getMapping().getVMLocation(vm));
}
// Get the load
int leastId = v.getLB();
double minLoad = 2;
IStateInt[] loads = new IStateInt[rcs.size()];
for (int nId = v.getLB(); nId <= v.getUB(); nId = v.nextValue(nId)) {
for (int d = 0; d < rcs.size(); d++) {
loads[d] = packing.assignedLoad()[d][nId];
}
double global = loadWith(nId, loads, vm);
if (global < minLoad) {
leastId = nId;
minLoad = global;
}
}
return leastId;
}
use of org.btrplace.model.VM in project scheduler by btrplace.
the class InstanceSolverRunner method checkUnknownVMsInMapping.
private static void checkUnknownVMsInMapping(Model m, Collection<VM> vms) throws SchedulerException {
for (VM v : vms) {
// This loop prevent from a useless allocation of memory when there is no issue
if (!m.getMapping().contains(v)) {
Set<VM> unknown = new HashSet<>(vms);
unknown.removeAll(m.getMapping().getAllVMs());
throw new SchedulerModelingException(m, "Unknown VMs: " + unknown);
}
}
}
Aggregations