use of org.btrplace.model.Node 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;
}
use of org.btrplace.model.Node in project scheduler by btrplace.
the class CRunningCapacity method filterWithSingleNode.
private boolean filterWithSingleNode(ReconfigurationProblem rp) {
Node n = cstr.getInvolvedNodes().iterator().next();
IntVar v = rp.getNbRunningVMs().get(rp.getNode(n));
Model csp = rp.getModel();
csp.post(csp.arithm(v, "<=", cstr.getAmount()));
return !cstr.isContinuous() || injectContinuous(rp);
}
use of org.btrplace.model.Node in project scheduler by btrplace.
the class CRunningCapacity method getMisPlacedVMs.
@Override
public Set<VM> getMisPlacedVMs(Instance i) {
Mapping map = i.getModel().getMapping();
Set<VM> bad = new HashSet<>();
int remainder = cstr.getAmount();
for (Node n : cstr.getInvolvedNodes()) {
remainder -= map.getRunningVMs(n).size();
if (remainder < 0) {
for (Node n2 : cstr.getInvolvedNodes()) {
bad.addAll(map.getRunningVMs(n2));
}
return bad;
}
}
return bad;
}
use of org.btrplace.model.Node in project scheduler by btrplace.
the class CSplit method getMisPlacedVMs.
@Override
public Set<VM> getMisPlacedVMs(Instance i) {
Mapping map = i.getModel().getMapping();
List<Collection<VM>> groups = new ArrayList<>(cstr.getSets());
// Bad contains the VMs on nodes that host VMs from different groups.
Set<VM> bad = new HashSet<>();
for (Collection<VM> grp : groups) {
for (VM vm : grp) {
if (map.isRunning(vm)) {
Node n = map.getVMLocation(vm);
Set<VM> allOnN = map.getRunningVMs(n);
for (VM vmOnN : allOnN) {
if (inOtherGroup(groups, grp, vmOnN)) {
// The VM belong to another group
bad.add(vm);
bad.add(vmOnN);
}
}
}
}
}
return bad;
}
use of org.btrplace.model.Node in project scheduler by btrplace.
the class AllowAllConstraintCheckerTest method testMyVMsTracking.
@Test(dependsOnMethods = "testInstantiation")
public void testMyVMsTracking() {
SatConstraint cstr = mock(SatConstraint.class);
Model mo = new DefaultModel();
List<VM> vms = Util.newVMs(mo, 10);
List<Node> ns = Util.newNodes(mo, 10);
when(cstr.getInvolvedNodes()).thenReturn(ns);
when(cstr.getInvolvedVMs()).thenReturn(vms);
AllowAllConstraintChecker<SatConstraint> c = new AllowAllConstraintChecker<>(cstr);
// VM1 (one of the involved vms) has to be removed to be substituted by vms.get(0)0
c.consume(new SubstitutedVMEvent(vms.get(0), vms.get(9)));
Assert.assertTrue(c.getVMs().contains(vms.get(9)));
Assert.assertFalse(c.getVMs().contains(vms.get(0)));
// VM5 is not involved, no removal
VM v = mo.newVM();
c.consume(new SubstitutedVMEvent(vms.get(0), v));
Assert.assertFalse(c.getVMs().contains(vms.get(0)));
Assert.assertFalse(c.getVMs().contains(v));
}
Aggregations