
org.cdk8s.plus31.k8s.PodAntiAffinity Maven / Gradle / Ivy
package org.cdk8s.plus31.k8s;
/**
* Pod anti affinity is a group of inter pod anti affinity scheduling rules.
*/
@javax.annotation.Generated(value = "jsii-pacmak/1.104.0 (build e79254c)", date = "2024-10-12T12:14:17.695Z")
@software.amazon.jsii.Jsii(module = org.cdk8s.plus31.$Module.class, fqn = "cdk8s-plus-31.k8s.PodAntiAffinity")
@software.amazon.jsii.Jsii.Proxy(PodAntiAffinity.Jsii$Proxy.class)
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public interface PodAntiAffinity extends software.amazon.jsii.JsiiSerializable {
/**
* The scheduler will prefer to schedule pods to nodes that satisfy the anti-affinity expressions specified by this field, but it may choose a node that violates one or more of the expressions.
*
* The node that is most preferred is the one with the greatest sum of weights, i.e. for each node that meets all of the scheduling requirements (resource request, requiredDuringScheduling anti-affinity expressions, etc.), compute a sum by iterating through the elements of this field and adding "weight" to the sum if the node has pods which matches the corresponding podAffinityTerm; the node(s) with the highest sum are the most preferred.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
default @org.jetbrains.annotations.Nullable java.util.List getPreferredDuringSchedulingIgnoredDuringExecution() {
return null;
}
/**
* If the anti-affinity requirements specified by this field are not met at scheduling time, the pod will not be scheduled onto the node.
*
* If the anti-affinity requirements specified by this field cease to be met at some point during pod execution (e.g. due to a pod label update), the system may or may not try to eventually evict the pod from its node. When there are multiple elements, the lists of nodes corresponding to each podAffinityTerm are intersected, i.e. all terms must be satisfied.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
default @org.jetbrains.annotations.Nullable java.util.List getRequiredDuringSchedulingIgnoredDuringExecution() {
return null;
}
/**
* @return a {@link Builder} of {@link PodAntiAffinity}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
static Builder builder() {
return new Builder();
}
/**
* A builder for {@link PodAntiAffinity}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public static final class Builder implements software.amazon.jsii.Builder {
java.util.List preferredDuringSchedulingIgnoredDuringExecution;
java.util.List requiredDuringSchedulingIgnoredDuringExecution;
/**
* Sets the value of {@link PodAntiAffinity#getPreferredDuringSchedulingIgnoredDuringExecution}
* @param preferredDuringSchedulingIgnoredDuringExecution The scheduler will prefer to schedule pods to nodes that satisfy the anti-affinity expressions specified by this field, but it may choose a node that violates one or more of the expressions.
* The node that is most preferred is the one with the greatest sum of weights, i.e. for each node that meets all of the scheduling requirements (resource request, requiredDuringScheduling anti-affinity expressions, etc.), compute a sum by iterating through the elements of this field and adding "weight" to the sum if the node has pods which matches the corresponding podAffinityTerm; the node(s) with the highest sum are the most preferred.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
@SuppressWarnings("unchecked")
public Builder preferredDuringSchedulingIgnoredDuringExecution(java.util.List extends org.cdk8s.plus31.k8s.WeightedPodAffinityTerm> preferredDuringSchedulingIgnoredDuringExecution) {
this.preferredDuringSchedulingIgnoredDuringExecution = (java.util.List)preferredDuringSchedulingIgnoredDuringExecution;
return this;
}
/**
* Sets the value of {@link PodAntiAffinity#getRequiredDuringSchedulingIgnoredDuringExecution}
* @param requiredDuringSchedulingIgnoredDuringExecution If the anti-affinity requirements specified by this field are not met at scheduling time, the pod will not be scheduled onto the node.
* If the anti-affinity requirements specified by this field cease to be met at some point during pod execution (e.g. due to a pod label update), the system may or may not try to eventually evict the pod from its node. When there are multiple elements, the lists of nodes corresponding to each podAffinityTerm are intersected, i.e. all terms must be satisfied.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
@SuppressWarnings("unchecked")
public Builder requiredDuringSchedulingIgnoredDuringExecution(java.util.List extends org.cdk8s.plus31.k8s.PodAffinityTerm> requiredDuringSchedulingIgnoredDuringExecution) {
this.requiredDuringSchedulingIgnoredDuringExecution = (java.util.List)requiredDuringSchedulingIgnoredDuringExecution;
return this;
}
/**
* Builds the configured instance.
* @return a new instance of {@link PodAntiAffinity}
* @throws NullPointerException if any required attribute was not provided
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
@Override
public PodAntiAffinity build() {
return new Jsii$Proxy(this);
}
}
/**
* An implementation for {@link PodAntiAffinity}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
@software.amazon.jsii.Internal
final class Jsii$Proxy extends software.amazon.jsii.JsiiObject implements PodAntiAffinity {
private final java.util.List preferredDuringSchedulingIgnoredDuringExecution;
private final java.util.List requiredDuringSchedulingIgnoredDuringExecution;
/**
* Constructor that initializes the object based on values retrieved from the JsiiObject.
* @param objRef Reference to the JSII managed object.
*/
protected Jsii$Proxy(final software.amazon.jsii.JsiiObjectRef objRef) {
super(objRef);
this.preferredDuringSchedulingIgnoredDuringExecution = software.amazon.jsii.Kernel.get(this, "preferredDuringSchedulingIgnoredDuringExecution", software.amazon.jsii.NativeType.listOf(software.amazon.jsii.NativeType.forClass(org.cdk8s.plus31.k8s.WeightedPodAffinityTerm.class)));
this.requiredDuringSchedulingIgnoredDuringExecution = software.amazon.jsii.Kernel.get(this, "requiredDuringSchedulingIgnoredDuringExecution", software.amazon.jsii.NativeType.listOf(software.amazon.jsii.NativeType.forClass(org.cdk8s.plus31.k8s.PodAffinityTerm.class)));
}
/**
* Constructor that initializes the object based on literal property values passed by the {@link Builder}.
*/
@SuppressWarnings("unchecked")
protected Jsii$Proxy(final Builder builder) {
super(software.amazon.jsii.JsiiObject.InitializationMode.JSII);
this.preferredDuringSchedulingIgnoredDuringExecution = (java.util.List)builder.preferredDuringSchedulingIgnoredDuringExecution;
this.requiredDuringSchedulingIgnoredDuringExecution = (java.util.List)builder.requiredDuringSchedulingIgnoredDuringExecution;
}
@Override
public final java.util.List getPreferredDuringSchedulingIgnoredDuringExecution() {
return this.preferredDuringSchedulingIgnoredDuringExecution;
}
@Override
public final java.util.List getRequiredDuringSchedulingIgnoredDuringExecution() {
return this.requiredDuringSchedulingIgnoredDuringExecution;
}
@Override
@software.amazon.jsii.Internal
public com.fasterxml.jackson.databind.JsonNode $jsii$toJson() {
final com.fasterxml.jackson.databind.ObjectMapper om = software.amazon.jsii.JsiiObjectMapper.INSTANCE;
final com.fasterxml.jackson.databind.node.ObjectNode data = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode();
if (this.getPreferredDuringSchedulingIgnoredDuringExecution() != null) {
data.set("preferredDuringSchedulingIgnoredDuringExecution", om.valueToTree(this.getPreferredDuringSchedulingIgnoredDuringExecution()));
}
if (this.getRequiredDuringSchedulingIgnoredDuringExecution() != null) {
data.set("requiredDuringSchedulingIgnoredDuringExecution", om.valueToTree(this.getRequiredDuringSchedulingIgnoredDuringExecution()));
}
final com.fasterxml.jackson.databind.node.ObjectNode struct = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode();
struct.set("fqn", om.valueToTree("cdk8s-plus-31.k8s.PodAntiAffinity"));
struct.set("data", data);
final com.fasterxml.jackson.databind.node.ObjectNode obj = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode();
obj.set("$jsii.struct", struct);
return obj;
}
@Override
public final boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
PodAntiAffinity.Jsii$Proxy that = (PodAntiAffinity.Jsii$Proxy) o;
if (this.preferredDuringSchedulingIgnoredDuringExecution != null ? !this.preferredDuringSchedulingIgnoredDuringExecution.equals(that.preferredDuringSchedulingIgnoredDuringExecution) : that.preferredDuringSchedulingIgnoredDuringExecution != null) return false;
return this.requiredDuringSchedulingIgnoredDuringExecution != null ? this.requiredDuringSchedulingIgnoredDuringExecution.equals(that.requiredDuringSchedulingIgnoredDuringExecution) : that.requiredDuringSchedulingIgnoredDuringExecution == null;
}
@Override
public final int hashCode() {
int result = this.preferredDuringSchedulingIgnoredDuringExecution != null ? this.preferredDuringSchedulingIgnoredDuringExecution.hashCode() : 0;
result = 31 * result + (this.requiredDuringSchedulingIgnoredDuringExecution != null ? this.requiredDuringSchedulingIgnoredDuringExecution.hashCode() : 0);
return result;
}
}
}