Skip to content

Commit

Permalink
Added support for "--replicas-max-per-node" (#1383)
Browse files Browse the repository at this point in the history
* Added support for "--replicas-max-per-node"

* Update ServicePlacement.java

Replaced DockerClientException with IllegalArgumentException

* Update ServicePlacement.java

Co-authored-by: Sergei Egorov <bsideup@gmail.com>
  • Loading branch information
derteufelqwe and bsideup committed Jun 4, 2020
1 parent c285fe5 commit 732c0f5
Showing 1 changed file with 33 additions and 0 deletions.
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;
}

}

0 comments on commit 732c0f5

Please sign in to comment.