use of org.btrplace.scheduler.choco.Slice in project scheduler by btrplace.
the class MovementGraph method make.
public void make() {
incoming.clear();
outgoings.clear();
for (VMTransition a : rp.getVMActions()) {
Slice cSlice = a.getCSlice();
Slice dSlice = a.getDSlice();
if (cSlice != null) {
addOutgoing(cSlice);
}
if (dSlice != null) {
addIncoming(dSlice);
}
}
}
use of org.btrplace.scheduler.choco.Slice in project scheduler by btrplace.
the class AbstractCumulatives method inject.
@Override
public boolean inject(Parameters ps, ReconfigurationProblem rp) throws SchedulerException {
cUsages = new ArrayList<>();
dUsages = new ArrayList<>();
List<Slice> dS = new ArrayList<>();
List<Slice> cS = new ArrayList<>();
non = new HashMap<>();
int dIdx = 0;
int cIdx = 0;
for (VMTransition a : rp.getVMActions()) {
Slice c = a.getCSlice();
Slice d = a.getDSlice();
if (d != null && c != null) {
non.put(a.getVM(), new int[] { dIdx, cIdx });
}
if (d != null) {
dS.add(dIdx, d);
dIdx++;
}
if (c != null) {
cS.add(cIdx, c);
cIdx++;
}
}
int i = 0;
cHosts = new IntVar[cS.size()];
cEnds = new IntVar[cS.size()];
for (Slice s : cS) {
cHosts[i] = s.getHoster();
cEnds[i] = s.getEnd();
i++;
}
i = 0;
dStarts = new IntVar[dS.size()];
dHosts = new IntVar[dS.size()];
for (Slice s : dS) {
dHosts[i] = s.getHoster();
dStarts[i] = s.getStart();
i++;
}
associations = makeAssociations();
return true;
}
use of org.btrplace.scheduler.choco.Slice 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.scheduler.choco.Slice in project scheduler by btrplace.
the class COffline method inject.
@Override
public boolean inject(Parameters ps, ReconfigurationProblem rp) throws SchedulerException {
if (cstr.isContinuous() && !cstr.getChecker().startsWith(rp.getSourceModel())) {
rp.getLogger().error("Constraint {} is not satisfied initially", cstr);
return false;
}
Node nId = cstr.getInvolvedNodes().iterator().next();
int id = rp.getNode(nId);
NodeTransition m = rp.getNodeAction(nId);
try {
m.getState().instantiateTo(0, Cause.Null);
if (rp.getSourceModel().getMapping().isOffline(nId)) {
m.getStart().instantiateTo(0, Cause.Null);
}
} catch (ContradictionException ex) {
rp.getLogger().error("Unable to force node '" + nId + "' at being offline", ex);
return false;
}
for (VMTransition am : rp.getVMActions()) {
Slice s = am.getDSlice();
if (s != null) {
try {
s.getHoster().removeValue(id, Cause.Null);
} catch (ContradictionException e) {
rp.getLogger().error("Unable to remove " + am.getVM() + " of node " + nId, e);
}
}
}
return true;
}
use of org.btrplace.scheduler.choco.Slice 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