Skip to content

Commit 732c0f5

Browse files
Added support for "--replicas-max-per-node" (docker-java#1383)
* 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>
1 parent c285fe5 commit 732c0f5

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

docker-java-api/src/main/java/com/github/dockerjava/api/model/ServicePlacement.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ public class ServicePlacement implements Serializable {
2828
@JsonProperty("Platforms")
2929
private List<SwarmNodePlatform> platforms;
3030

31+
/**
32+
* @since 1.40
33+
*/
34+
@JsonProperty("MaxReplicas")
35+
private Integer maxReplicas;
36+
3137
/**
3238
* @see #constraints
3339
*/
@@ -54,4 +60,31 @@ public List<SwarmNodePlatform> getPlatforms() {
5460
public void setPlatforms(List<SwarmNodePlatform> platforms) {
5561
this.platforms = platforms;
5662
}
63+
64+
/**
65+
* Specifies the maximum amount of replicas / tasks that can run on one node.
66+
* 0 means unlimited replicas per node.
67+
*
68+
* @param maxReplicas Max number of replicas
69+
* @return This instance of ServicePlacement
70+
* @throws IllegalArgumentException if maxReplicas is less than 0
71+
*/
72+
public ServicePlacement withMaxReplicas(int maxReplicas) {
73+
if (maxReplicas < 0) {
74+
throw new IllegalArgumentException("The Value for MaxReplicas must be greater or equal to 0");
75+
}
76+
77+
this.maxReplicas = maxReplicas;
78+
return this;
79+
}
80+
81+
/**
82+
* Getter for maxReplicas
83+
*
84+
* @return The maximum amount of replicas / tasks that can run on one node.
85+
*/
86+
public Integer getMaxReplicas() {
87+
return this.maxReplicas;
88+
}
89+
5790
}

0 commit comments

Comments
 (0)