use of org.btrplace.scheduler.choco.transition.NodeTransition in project scheduler by btrplace.
the class IssuesTest method issue33.
@Test
public void issue33() throws SchedulerException, ContradictionException {
Model mo = new DefaultModel();
Node n = mo.newNode();
VM v = mo.newVM();
mo.getMapping().addOnlineNode(n);
mo.getMapping().addRunningVM(v, n);
ReconfigurationProblem rp = new DefaultReconfigurationProblemBuilder(mo).setNextVMsStates(Collections.emptySet(), Collections.emptySet(), Collections.singleton(v), Collections.emptySet()).build();
NodeTransition na = rp.getNodeAction(n);
na.getStart().instantiateTo(0, Cause.Null);
na.getEnd().instantiateTo(1, Cause.Null);
VMTransition vma = rp.getVMAction(v);
vma.getStart().instantiateTo(0, Cause.Null);
vma.getEnd().instantiateTo(1, Cause.Null);
ReconfigurationPlan plan = rp.solve(0, false);
Assert.assertEquals(plan, null);
}
use of org.btrplace.scheduler.choco.transition.NodeTransition in project scheduler by btrplace.
the class COnline 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();
NodeTransition m = rp.getNodeAction(nId);
try {
m.getState().instantiateTo(1, Cause.Null);
if (rp.getSourceModel().getMapping().isOnline(nId)) {
m.getStart().instantiateTo(0, Cause.Null);
}
} catch (ContradictionException ex) {
rp.getLogger().error("Unable to force node '" + nId + "' at being online", ex);
return false;
}
return true;
}
Aggregations