software.amazon.awssdk.services.elasticloadbalancing.model.HealthCheck Maven / Gradle / Ivy
Show all versions of elasticloadbalancing Show documentation
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package software.amazon.awssdk.services.elasticloadbalancing.model;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Function;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.core.SdkField;
import software.amazon.awssdk.core.SdkPojo;
import software.amazon.awssdk.core.protocol.MarshallLocation;
import software.amazon.awssdk.core.protocol.MarshallingType;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Information about a health check.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class HealthCheck implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField TARGET_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Target")
.getter(getter(HealthCheck::target)).setter(setter(Builder::target))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Target").build()).build();
private static final SdkField INTERVAL_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("Interval").getter(getter(HealthCheck::interval)).setter(setter(Builder::interval))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Interval").build()).build();
private static final SdkField TIMEOUT_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("Timeout").getter(getter(HealthCheck::timeout)).setter(setter(Builder::timeout))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Timeout").build()).build();
private static final SdkField UNHEALTHY_THRESHOLD_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("UnhealthyThreshold").getter(getter(HealthCheck::unhealthyThreshold))
.setter(setter(Builder::unhealthyThreshold))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("UnhealthyThreshold").build())
.build();
private static final SdkField HEALTHY_THRESHOLD_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("HealthyThreshold").getter(getter(HealthCheck::healthyThreshold))
.setter(setter(Builder::healthyThreshold))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("HealthyThreshold").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(TARGET_FIELD, INTERVAL_FIELD,
TIMEOUT_FIELD, UNHEALTHY_THRESHOLD_FIELD, HEALTHY_THRESHOLD_FIELD));
private static final Map> SDK_NAME_TO_FIELD = Collections
.unmodifiableMap(new HashMap>() {
{
put("Target", TARGET_FIELD);
put("Interval", INTERVAL_FIELD);
put("Timeout", TIMEOUT_FIELD);
put("UnhealthyThreshold", UNHEALTHY_THRESHOLD_FIELD);
put("HealthyThreshold", HEALTHY_THRESHOLD_FIELD);
}
});
private static final long serialVersionUID = 1L;
private final String target;
private final Integer interval;
private final Integer timeout;
private final Integer unhealthyThreshold;
private final Integer healthyThreshold;
private HealthCheck(BuilderImpl builder) {
this.target = builder.target;
this.interval = builder.interval;
this.timeout = builder.timeout;
this.unhealthyThreshold = builder.unhealthyThreshold;
this.healthyThreshold = builder.healthyThreshold;
}
/**
*
* The instance being checked. The protocol is either TCP, HTTP, HTTPS, or SSL. The range of valid ports is one (1)
* through 65535.
*
*
* TCP is the default, specified as a TCP: port pair, for example "TCP:5000". In this case, a health check simply
* attempts to open a TCP connection to the instance on the specified port. Failure to connect within the configured
* timeout is considered unhealthy.
*
*
* SSL is also specified as SSL: port pair, for example, SSL:5000.
*
*
* For HTTP/HTTPS, you must include a ping path in the string. HTTP is specified as a HTTP:port;/;PathToPing;
* grouping, for example "HTTP:80/weather/us/wa/seattle". In this case, a HTTP GET request is issued to the instance
* on the given port and path. Any answer other than "200 OK" within the timeout period is considered unhealthy.
*
*
* The total length of the HTTP ping target must be 1024 16-bit Unicode characters or less.
*
*
* @return The instance being checked. The protocol is either TCP, HTTP, HTTPS, or SSL. The range of valid ports is
* one (1) through 65535.
*
* TCP is the default, specified as a TCP: port pair, for example "TCP:5000". In this case, a health check
* simply attempts to open a TCP connection to the instance on the specified port. Failure to connect within
* the configured timeout is considered unhealthy.
*
*
* SSL is also specified as SSL: port pair, for example, SSL:5000.
*
*
* For HTTP/HTTPS, you must include a ping path in the string. HTTP is specified as a
* HTTP:port;/;PathToPing; grouping, for example "HTTP:80/weather/us/wa/seattle". In this case, a HTTP GET
* request is issued to the instance on the given port and path. Any answer other than "200 OK" within the
* timeout period is considered unhealthy.
*
*
* The total length of the HTTP ping target must be 1024 16-bit Unicode characters or less.
*/
public final String target() {
return target;
}
/**
*
* The approximate interval, in seconds, between health checks of an individual instance.
*
*
* @return The approximate interval, in seconds, between health checks of an individual instance.
*/
public final Integer interval() {
return interval;
}
/**
*
* The amount of time, in seconds, during which no response means a failed health check.
*
*
* This value must be less than the Interval
value.
*
*
* @return The amount of time, in seconds, during which no response means a failed health check.
*
* This value must be less than the Interval
value.
*/
public final Integer timeout() {
return timeout;
}
/**
*
* The number of consecutive health check failures required before moving the instance to the Unhealthy
* state.
*
*
* @return The number of consecutive health check failures required before moving the instance to the
* Unhealthy
state.
*/
public final Integer unhealthyThreshold() {
return unhealthyThreshold;
}
/**
*
* The number of consecutive health checks successes required before moving the instance to the Healthy
* state.
*
*
* @return The number of consecutive health checks successes required before moving the instance to the
* Healthy
state.
*/
public final Integer healthyThreshold() {
return healthyThreshold;
}
@Override
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public static Class extends Builder> serializableBuilderClass() {
return BuilderImpl.class;
}
@Override
public final int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(target());
hashCode = 31 * hashCode + Objects.hashCode(interval());
hashCode = 31 * hashCode + Objects.hashCode(timeout());
hashCode = 31 * hashCode + Objects.hashCode(unhealthyThreshold());
hashCode = 31 * hashCode + Objects.hashCode(healthyThreshold());
return hashCode;
}
@Override
public final boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public final boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof HealthCheck)) {
return false;
}
HealthCheck other = (HealthCheck) obj;
return Objects.equals(target(), other.target()) && Objects.equals(interval(), other.interval())
&& Objects.equals(timeout(), other.timeout()) && Objects.equals(unhealthyThreshold(), other.unhealthyThreshold())
&& Objects.equals(healthyThreshold(), other.healthyThreshold());
}
/**
* Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be
* redacted from this string using a placeholder value.
*/
@Override
public final String toString() {
return ToString.builder("HealthCheck").add("Target", target()).add("Interval", interval()).add("Timeout", timeout())
.add("UnhealthyThreshold", unhealthyThreshold()).add("HealthyThreshold", healthyThreshold()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Target":
return Optional.ofNullable(clazz.cast(target()));
case "Interval":
return Optional.ofNullable(clazz.cast(interval()));
case "Timeout":
return Optional.ofNullable(clazz.cast(timeout()));
case "UnhealthyThreshold":
return Optional.ofNullable(clazz.cast(unhealthyThreshold()));
case "HealthyThreshold":
return Optional.ofNullable(clazz.cast(healthyThreshold()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
@Override
public final Map> sdkFieldNameToField() {
return SDK_NAME_TO_FIELD;
}
private static Function