Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for "--replicas-max-per-node" #1383

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ public class ServicePlacement implements Serializable {
@JsonProperty("Platforms")
private List<SwarmNodePlatform> platforms;

/**
* @since 1.40
*/
@JsonProperty("MaxReplicas")
private Integer maxReplicas;

/**
* @see #constraints
*/
Expand All @@ -54,4 +60,31 @@ public List<SwarmNodePlatform> getPlatforms() {
public void setPlatforms(List<SwarmNodePlatform> platforms) {
this.platforms = platforms;
}

/**
* Specifies the maximum amount of replicas / tasks that can run on one node.
* 0 means unlimited replicas per node.
*
* @param maxReplicas Max number of replicas
* @return This instance of ServicePlacement
* @throws IllegalArgumentException if maxReplicas is less than 0
*/
public ServicePlacement withMaxReplicas(int maxReplicas) {
if (maxReplicas < 0) {
throw new IllegalArgumentException("The Value for MaxReplicas must be greater or equal to 0");
}

this.maxReplicas = maxReplicas;
return this;
}

/**
* Getter for maxReplicas
*
* @return The maximum amount of replicas / tasks that can run on one node.
*/
public Integer getMaxReplicas() {
return this.maxReplicas;
}

}