com.github.dockerjava.api.model.ServicePlacement Maven / Gradle / Ivy
package com.github.dockerjava.api.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import javax.annotation.CheckForNull;
import java.io.Serializable;
import java.util.List;
/**
* @since {@link RemoteApiVersion#VERSION_1_24}
*/
@EqualsAndHashCode
@ToString
public class ServicePlacement extends DockerObject implements Serializable {
public static final long serialVersionUID = 1L;
/**
* @since 1.24
*/
@JsonProperty("Constraints")
private List constraints;
/**
* @since 1.30
*/
@JsonProperty("Platforms")
private List platforms;
/**
* @since 1.40
*/
@JsonProperty("MaxReplicas")
private Integer maxReplicas;
/**
* @see #constraints
*/
@CheckForNull
public List getConstraints() {
return constraints;
}
/**
* @see #constraints
*/
public ServicePlacement withConstraints(List constraints) {
this.constraints = constraints;
return this;
}
/**
* @see #platforms
*/
public List getPlatforms() {
return platforms;
}
public void setPlatforms(List 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;
}
}