You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fhermeni edited this page Oct 28, 2014
·
3 revisions
Custom Duration Evaluators
There is only a few implementations of DurationEvaluator. If you need to develop your own, just make a new implementation and register it inside the DurationEvaluators associated to the scheduler. There must be exactly one evaluator per action used the reconfiguration algorithm.
The following snippet makes a new evaluator and associates it to the ForgeVM action. This evaluator states the action duration depends on the template of the given VM that is provided through a standard attribute.
publicclassMyForgeEvaluatorimplementsDurationEvaluator<VM> {
@Overridepublicintevaluate(Modelmo, VMe) {
Attributesattrs = mo.getAttributes();
Stringtpl = attrs.isSet(e, "template") ? attrs.getString(e, "template") : "default";
switch (tpl) {
case"small":
return2;
case"large":
return6;
default:
return -1; //To signal an error
}
}
}
//Associate the evaluator to the ForgeVM actionSchedulers = newDefaultChocoScheduler();
s.getDurationEvaluators.register(ForgeVM.class, newMyForgeEvaluator());