use of org.btrplace.model.VM in project scheduler by btrplace.
the class CGather method getDSlices.
private List<Slice> getDSlices(ReconfigurationProblem rp) {
List<Slice> dSlices = new ArrayList<>();
for (VM vm : cstr.getInvolvedVMs()) {
VMTransition a = rp.getVMAction(vm);
Slice dSlice = a.getDSlice();
if (dSlice != null) {
dSlices.add(dSlice);
}
}
return dSlices;
}
use of org.btrplace.model.VM in project scheduler by btrplace.
the class CLonely method continuousRestriction.
private static void continuousRestriction(ReconfigurationProblem rp, Collection<VM> vms, Set<VM> otherVMs) {
// Get the position of all the others c-slices and their associated end moment
TIntArrayList otherPos = new TIntArrayList();
TIntArrayList minePos = new TIntArrayList();
List<IntVar> otherEnds = new ArrayList<>();
List<IntVar> mineEnds = new ArrayList<>();
Mapping map = rp.getSourceModel().getMapping();
for (Node n : map.getOnlineNodes()) {
for (VM vm : map.getRunningVMs(n)) {
if (!vms.contains(vm)) {
otherPos.add(rp.getNode(map.getVMLocation(vm)));
VMTransition a = rp.getVMAction(vm);
otherEnds.add(a.getCSlice().getEnd());
} else {
minePos.add(rp.getNode(map.getVMLocation(vm)));
VMTransition a = rp.getVMAction(vm);
mineEnds.add(a.getCSlice().getEnd());
}
}
}
for (VM vm : vms) {
VMTransition a = rp.getVMAction(vm);
Precedences p = new Precedences(a.getDSlice().getHoster(), a.getDSlice().getStart(), otherPos.toArray(), otherEnds.toArray(new IntVar[otherEnds.size()]));
rp.getModel().post(p);
}
// TODO: The following reveals a model problem. Too many constraints!!
for (VM vm : otherVMs) {
VMTransition a = rp.getVMAction(vm);
Precedences p = new Precedences(a.getDSlice().getHoster(), a.getDSlice().getStart(), minePos.toArray(), mineEnds.toArray(new IntVar[mineEnds.size()]));
rp.getModel().post(p);
}
}
use of org.btrplace.model.VM in project scheduler by btrplace.
the class CLonely method getMisPlacedVMs.
@Override
public Set<VM> getMisPlacedVMs(Instance i) {
Set<VM> bad = new HashSet<>();
Set<Node> hosts = new HashSet<>();
Collection<VM> vms = cstr.getInvolvedVMs();
Mapping map = i.getModel().getMapping();
for (VM vm : vms) {
if (map.isRunning(vm)) {
hosts.add(map.getVMLocation(vm));
}
}
for (Node n : hosts) {
// is a bad node. All the hosted VMs are candidate for relocation. Not optimal, but safe
for (VM vm : map.getRunningVMs(n)) {
if (!vms.contains(vm)) {
bad.addAll(map.getRunningVMs(n));
break;
}
}
}
return bad;
}
use of org.btrplace.model.VM in project scheduler by btrplace.
the class CResourceCapacity method getMisPlacedVMs.
@Override
public Set<VM> getMisPlacedVMs(Instance i) {
if (cstr.getInvolvedNodes().size() <= 1) {
// If there is only a single node, we delegate this work to CShareableResource.
return Collections.emptySet();
}
Mapping map = i.getModel().getMapping();
ShareableResource rc = ShareableResource.get(i.getModel(), cstr.getResource());
if (rc == null) {
return map.getRunningVMs(cstr.getInvolvedNodes());
}
Set<VM> bad = new HashSet<>();
int remainder = cstr.getAmount();
for (Node n : cstr.getInvolvedNodes()) {
for (VM v : map.getRunningVMs(n)) {
remainder -= rc.getConsumption(v);
if (remainder < 0) {
for (Node n2 : cstr.getInvolvedNodes()) {
bad.addAll(map.getRunningVMs(n2));
}
return bad;
}
}
}
return bad;
}
use of org.btrplace.model.VM in project scheduler by btrplace.
the class CRoot method inject.
@Override
public boolean inject(Parameters ps, ReconfigurationProblem rp) throws SchedulerException {
VM vm = cstr.getInvolvedVMs().iterator().next();
VMTransition m = rp.getVMAction(vm);
Slice cSlice = m.getCSlice();
Slice dSlice = m.getDSlice();
if (cSlice != null && dSlice != null) {
try {
dSlice.getHoster().instantiateTo(cSlice.getHoster().getValue(), Cause.Null);
} catch (ContradictionException ex) {
Node n = rp.getSourceModel().getMapping().getVMLocation(vm);
rp.getLogger().error("Unable to force '" + vm + "' to be running on node '" + n + "'", ex);
return false;
}
}
return true;
}
Aggregations