software.amazon.awssdk.services.autoscaling.model.TargetTrackingConfiguration Maven / Gradle / Ivy
Show all versions of autoscaling 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.autoscaling.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.Consumer;
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;
/**
*
* Represents a target tracking scaling policy configuration to use with Amazon EC2 Auto Scaling.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class TargetTrackingConfiguration implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField PREDEFINED_METRIC_SPECIFICATION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO)
.memberName("PredefinedMetricSpecification")
.getter(getter(TargetTrackingConfiguration::predefinedMetricSpecification))
.setter(setter(Builder::predefinedMetricSpecification))
.constructor(PredefinedMetricSpecification::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PredefinedMetricSpecification")
.build()).build();
private static final SdkField CUSTOMIZED_METRIC_SPECIFICATION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO)
.memberName("CustomizedMetricSpecification")
.getter(getter(TargetTrackingConfiguration::customizedMetricSpecification))
.setter(setter(Builder::customizedMetricSpecification))
.constructor(CustomizedMetricSpecification::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CustomizedMetricSpecification")
.build()).build();
private static final SdkField TARGET_VALUE_FIELD = SdkField. builder(MarshallingType.DOUBLE)
.memberName("TargetValue").getter(getter(TargetTrackingConfiguration::targetValue))
.setter(setter(Builder::targetValue))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TargetValue").build()).build();
private static final SdkField DISABLE_SCALE_IN_FIELD = SdkField. builder(MarshallingType.BOOLEAN)
.memberName("DisableScaleIn").getter(getter(TargetTrackingConfiguration::disableScaleIn))
.setter(setter(Builder::disableScaleIn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DisableScaleIn").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(
PREDEFINED_METRIC_SPECIFICATION_FIELD, CUSTOMIZED_METRIC_SPECIFICATION_FIELD, TARGET_VALUE_FIELD,
DISABLE_SCALE_IN_FIELD));
private static final Map> SDK_NAME_TO_FIELD = Collections
.unmodifiableMap(new HashMap>() {
{
put("PredefinedMetricSpecification", PREDEFINED_METRIC_SPECIFICATION_FIELD);
put("CustomizedMetricSpecification", CUSTOMIZED_METRIC_SPECIFICATION_FIELD);
put("TargetValue", TARGET_VALUE_FIELD);
put("DisableScaleIn", DISABLE_SCALE_IN_FIELD);
}
});
private static final long serialVersionUID = 1L;
private final PredefinedMetricSpecification predefinedMetricSpecification;
private final CustomizedMetricSpecification customizedMetricSpecification;
private final Double targetValue;
private final Boolean disableScaleIn;
private TargetTrackingConfiguration(BuilderImpl builder) {
this.predefinedMetricSpecification = builder.predefinedMetricSpecification;
this.customizedMetricSpecification = builder.customizedMetricSpecification;
this.targetValue = builder.targetValue;
this.disableScaleIn = builder.disableScaleIn;
}
/**
*
* A predefined metric. You must specify either a predefined metric or a customized metric.
*
*
* @return A predefined metric. You must specify either a predefined metric or a customized metric.
*/
public final PredefinedMetricSpecification predefinedMetricSpecification() {
return predefinedMetricSpecification;
}
/**
*
* A customized metric. You must specify either a predefined metric or a customized metric.
*
*
* @return A customized metric. You must specify either a predefined metric or a customized metric.
*/
public final CustomizedMetricSpecification customizedMetricSpecification() {
return customizedMetricSpecification;
}
/**
*
* The target value for the metric.
*
*
*
* Some metrics are based on a count instead of a percentage, such as the request count for an Application Load
* Balancer or the number of messages in an SQS queue. If the scaling policy specifies one of these metrics, specify
* the target utilization as the optimal average request or message count per instance during any one-minute
* interval.
*
*
*
* @return The target value for the metric.
*
* Some metrics are based on a count instead of a percentage, such as the request count for an Application
* Load Balancer or the number of messages in an SQS queue. If the scaling policy specifies one of these
* metrics, specify the target utilization as the optimal average request or message count per instance
* during any one-minute interval.
*
*/
public final Double targetValue() {
return targetValue;
}
/**
*
* Indicates whether scaling in by the target tracking scaling policy is disabled. If scaling in is disabled, the
* target tracking scaling policy doesn't remove instances from the Auto Scaling group. Otherwise, the target
* tracking scaling policy can remove instances from the Auto Scaling group. The default is false
.
*
*
* @return Indicates whether scaling in by the target tracking scaling policy is disabled. If scaling in is
* disabled, the target tracking scaling policy doesn't remove instances from the Auto Scaling group.
* Otherwise, the target tracking scaling policy can remove instances from the Auto Scaling group. The
* default is false
.
*/
public final Boolean disableScaleIn() {
return disableScaleIn;
}
@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(predefinedMetricSpecification());
hashCode = 31 * hashCode + Objects.hashCode(customizedMetricSpecification());
hashCode = 31 * hashCode + Objects.hashCode(targetValue());
hashCode = 31 * hashCode + Objects.hashCode(disableScaleIn());
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 TargetTrackingConfiguration)) {
return false;
}
TargetTrackingConfiguration other = (TargetTrackingConfiguration) obj;
return Objects.equals(predefinedMetricSpecification(), other.predefinedMetricSpecification())
&& Objects.equals(customizedMetricSpecification(), other.customizedMetricSpecification())
&& Objects.equals(targetValue(), other.targetValue()) && Objects.equals(disableScaleIn(), other.disableScaleIn());
}
/**
* 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("TargetTrackingConfiguration")
.add("PredefinedMetricSpecification", predefinedMetricSpecification())
.add("CustomizedMetricSpecification", customizedMetricSpecification()).add("TargetValue", targetValue())
.add("DisableScaleIn", disableScaleIn()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "PredefinedMetricSpecification":
return Optional.ofNullable(clazz.cast(predefinedMetricSpecification()));
case "CustomizedMetricSpecification":
return Optional.ofNullable(clazz.cast(customizedMetricSpecification()));
case "TargetValue":
return Optional.ofNullable(clazz.cast(targetValue()));
case "DisableScaleIn":
return Optional.ofNullable(clazz.cast(disableScaleIn()));
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