use of com.mesosphere.sdk.offer.evaluate.EvaluationOutcome in project dcos-commons by mesosphere.
the class OrRule method filter.
@Override
public EvaluationOutcome filter(Offer offer, PodInstance podInstance, Collection<TaskInfo> tasks) {
int passingCount = 0;
Collection<EvaluationOutcome> children = new ArrayList<>();
for (PlacementRule rule : rules) {
EvaluationOutcome child = rule.filter(offer, podInstance, tasks);
if (child.isPassing()) {
passingCount++;
}
children.add(child);
}
if (passingCount != 0) {
return EvaluationOutcome.pass(this, "%d of %d rules are passing:", passingCount, rules.size()).addAllChildren(children).build();
} else {
return EvaluationOutcome.fail(this, "%d of %d rules are passing:", passingCount, rules.size()).addAllChildren(children).build();
}
}
use of com.mesosphere.sdk.offer.evaluate.EvaluationOutcome in project dcos-commons by mesosphere.
the class AndRule method filter.
@Override
public EvaluationOutcome filter(Offer offer, PodInstance podInstance, Collection<TaskInfo> tasks) {
if (rules.isEmpty()) {
return EvaluationOutcome.fail(this, "No rules to AND together is treated as 'always fail'").build();
}
int passingCount = 0;
Collection<EvaluationOutcome> children = new ArrayList<>();
for (PlacementRule rule : rules) {
EvaluationOutcome child = rule.filter(offer, podInstance, tasks);
if (child.isPassing()) {
passingCount++;
}
children.add(child);
}
if (passingCount == rules.size()) {
return EvaluationOutcome.pass(this, "%d of %d rules are passing:", passingCount, rules.size()).addAllChildren(children).build();
} else {
return EvaluationOutcome.fail(this, "%d of %d rules are passing:", passingCount, rules.size()).addAllChildren(children).build();
}
}
use of com.mesosphere.sdk.offer.evaluate.EvaluationOutcome in project dcos-commons by mesosphere.
the class IsLocalRegionRuleTest method offerLacksDomain.
@Test
public void offerLacksDomain() {
EvaluationOutcome outcome = rule.filter(getOffer(), null, null);
Assert.assertTrue(outcome.isPassing());
}
use of com.mesosphere.sdk.offer.evaluate.EvaluationOutcome in project dcos-commons by mesosphere.
the class IsLocalRegionRuleTest method offerMismatchesLocalDomain.
@Test
public void offerMismatchesLocalDomain() {
IsLocalRegionRule.setLocalDomain(TestConstants.LOCAL_DOMAIN_INFO);
EvaluationOutcome outcome = rule.filter(getOffer(TestConstants.REMOTE_DOMAIN_INFO), null, null);
Assert.assertFalse(outcome.isPassing());
}
Aggregations