public class MaxPerHostnameRule extends MaxPerRule
MaxPerHostnameRule
with a limit of 2 and a regex of
'c-.*'. In this case, we're ensuring that no more than 2 tasks starting with 'c-' can be launched
on any given host. Among the above three hosts, any offers from host-1 and host-3 will be
accepted and offers from host-2 will be denied.max
Constructor and Description |
---|
MaxPerHostnameRule(int maxTasksPerSelectedHostname)
Creates a new rule which will block deployment on tasks which already have N instances
running against a specified attribute, with no filtering on task names (all tasks across the
service are counted against the max).
|
MaxPerHostnameRule(int maxTasksPerSelectedHostname,
StringMatcher taskFilter)
Creates a new rule which will block deployment on tasks which already have N instances
running against a specified hostname.
|
Modifier and Type | Method and Description |
---|---|
EvaluationOutcome |
filter(Offer offer,
PodInstance podInstance,
java.util.Collection<TaskInfo> tasks)
Returns whether the provided
Offer , combined with the accompanying
TaskInfo s, passes or fails this placement constraint. |
java.util.Collection<java.lang.String> |
getKeys(Offer offer) |
java.util.Collection<java.lang.String> |
getKeys(TaskInfo taskInfo) |
java.util.Collection<PlacementField> |
getPlacementFields()
Returns the
PlacementField s to which this rule applies. |
java.lang.String |
toString() |
equals, getTaskFilter, hashCode, isAcceptable
public MaxPerHostnameRule(int maxTasksPerSelectedHostname)
maxTasksPerSelectedHostname
- the maximum number of tasks which may be run on a selected
agentpublic MaxPerHostnameRule(int maxTasksPerSelectedHostname, StringMatcher taskFilter)
maxTasksPerSelectedHostname
- the maximum number of tasks which may be run on a selected
agenttaskFilter
- a filter on task names to determine which tasks are included in the count,
for example counting all tasks, or just counting tasks of a given typepublic EvaluationOutcome filter(Offer offer, PodInstance podInstance, java.util.Collection<TaskInfo> tasks)
PlacementRule
Offer
, combined with the accompanying
TaskInfo
s, passes or fails this placement constraint.offer
- the offer to be examinedtasks
- the currently deployed tasks in the system, possibly including a duplicate
of the task being launched as represented in the offerRequirement. Use
PlacementUtils.areEquivalent(TaskInfo, PodInstance)
to detect
duplicatesEvaluationOutcome
object describing whether the placement succeeded or failed and whypublic java.util.Collection<PlacementField> getPlacementFields()
PlacementRule
PlacementField
s to which this rule applies.public java.util.Collection<java.lang.String> getKeys(TaskInfo taskInfo)
getKeys
in class MaxPerRule
public java.util.Collection<java.lang.String> getKeys(Offer offer)
getKeys
in class MaxPerRule
public java.lang.String toString()
toString
in class java.lang.Object