Interface Constraint
- All Known Implementing Classes:
BudgetConstraint, ComplianceZonesConstraint, EveryMetroUsedConstraint, ExcludedMetrosConstraint, ExcludedRegionsConstraint, FailoverGeoZonesConstraint, GeoZonesConstraint, MaxSiteLatencyConstraint, MetroCountConstraint, MinimumRedundancyConstraint, MinSurvivalConstraint, PinnedWorkloadsConstraint, RequiredCloudsConstraint, RequiredMetrosConstraint, RequiredRegionsConstraint, WorkloadLatencyConstraint
public interface Constraint
A hard limit. A portfolio that fails any constraint is never offered, whatever its objectives
say. Implementations must be pure functions of their arguments.
-
Method Summary
Modifier and TypeMethodDescriptiondefault booleanadmits(MetroFacts metro, DesignContext context) Cheap per-metro pruning before portfolios are formed.check(MetroPortfolio portfolio, DesignContext context) Checks a whole portfolio.id()default booleanusesCost()Whethercheck(MetroPortfolio, DesignContext)prices the portfolio throughDesignContext.costModel().
-
Method Details
-
id
String id()- Returns:
- a stable id, lower_snake_case (for example
max_latency)
-
admits
Cheap per-metro pruning before portfolios are formed. Returnfalseonly when no portfolio containing this metro could ever satisfy the constraint (an excluded metro, a metro outside every allowed zone). The default admits every metro.- Parameters:
metro- a candidate metrocontext- the facts of this run- Returns:
- whether the metro may appear in a portfolio
-
check
Checks a whole portfolio.- Parameters:
portfolio- the candidate designcontext- the facts of this run- Returns:
- the verdict with its reason
-
usesCost
default boolean usesCost()Whethercheck(MetroPortfolio, DesignContext)prices the portfolio throughDesignContext.costModel(). A solver uses it to price ahead, in one batch, the portfolios that reach a pricing constraint (CostModel.prepare(Collection, DesignContext)); the verdicts are the same either way. The default isfalse: a pricing constraint that says so is only slower, never wrong.- Returns:
truewhen checking needs prices
-