use of org.chocosolver.solver.exception.ContradictionException in project scheduler by btrplace.
the class CQuarantine method inject.
@Override
public boolean inject(Parameters ps, ReconfigurationProblem rp) throws SchedulerException {
// It is just a composition of a root constraint on the VMs on the given nodes (the zone)
// plus a ban on the other VMs to prevent them for being hosted in the zone
Mapping map = rp.getSourceModel().getMapping();
Node n = cstr.getInvolvedNodes().iterator().next();
int nIdx = rp.getNode(n);
for (VM vm : rp.getFutureRunningVMs()) {
if (n.equals(map.getVMLocation(vm))) {
IntVar d = rp.getVMAction(vm).getDSlice().getHoster();
try {
d.instantiateTo(nIdx, Cause.Null);
} catch (ContradictionException e) {
rp.getLogger().error("Unable to root " + vm + " on " + n, e);
return false;
}
} else {
IntVar d = rp.getVMAction(vm).getDSlice().getHoster();
try {
d.removeValue(nIdx, Cause.Null);
} catch (ContradictionException e) {
rp.getLogger().error("Unable to disallow " + vm + " to be hosted on " + n, e);
return false;
}
}
}
return true;
}
Aggregations