software.amazon.awssdk.services.applicationautoscaling.model.TargetTrackingScalingPolicyConfiguration Maven / Gradle / Ivy
Show all versions of applicationautoscaling 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.applicationautoscaling.model;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
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 Application Auto Scaling.
*
*
* For more information, see Target tracking scaling policies in the Application Auto Scaling User Guide.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class TargetTrackingScalingPolicyConfiguration implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField TARGET_VALUE_FIELD = SdkField. builder(MarshallingType.DOUBLE)
.memberName("TargetValue").getter(getter(TargetTrackingScalingPolicyConfiguration::targetValue))
.setter(setter(Builder::targetValue))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TargetValue").build()).build();
private static final SdkField PREDEFINED_METRIC_SPECIFICATION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO)
.memberName("PredefinedMetricSpecification")
.getter(getter(TargetTrackingScalingPolicyConfiguration::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(TargetTrackingScalingPolicyConfiguration::customizedMetricSpecification))
.setter(setter(Builder::customizedMetricSpecification))
.constructor(CustomizedMetricSpecification::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CustomizedMetricSpecification")
.build()).build();
private static final SdkField SCALE_OUT_COOLDOWN_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("ScaleOutCooldown").getter(getter(TargetTrackingScalingPolicyConfiguration::scaleOutCooldown))
.setter(setter(Builder::scaleOutCooldown))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ScaleOutCooldown").build()).build();
private static final SdkField SCALE_IN_COOLDOWN_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("ScaleInCooldown").getter(getter(TargetTrackingScalingPolicyConfiguration::scaleInCooldown))
.setter(setter(Builder::scaleInCooldown))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ScaleInCooldown").build()).build();
private static final SdkField DISABLE_SCALE_IN_FIELD = SdkField. builder(MarshallingType.BOOLEAN)
.memberName("DisableScaleIn").getter(getter(TargetTrackingScalingPolicyConfiguration::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(TARGET_VALUE_FIELD,
PREDEFINED_METRIC_SPECIFICATION_FIELD, CUSTOMIZED_METRIC_SPECIFICATION_FIELD, SCALE_OUT_COOLDOWN_FIELD,
SCALE_IN_COOLDOWN_FIELD, DISABLE_SCALE_IN_FIELD));
private static final long serialVersionUID = 1L;
private final Double targetValue;
private final PredefinedMetricSpecification predefinedMetricSpecification;
private final CustomizedMetricSpecification customizedMetricSpecification;
private final Integer scaleOutCooldown;
private final Integer scaleInCooldown;
private final Boolean disableScaleIn;
private TargetTrackingScalingPolicyConfiguration(BuilderImpl builder) {
this.targetValue = builder.targetValue;
this.predefinedMetricSpecification = builder.predefinedMetricSpecification;
this.customizedMetricSpecification = builder.customizedMetricSpecification;
this.scaleOutCooldown = builder.scaleOutCooldown;
this.scaleInCooldown = builder.scaleInCooldown;
this.disableScaleIn = builder.disableScaleIn;
}
/**
*
* The target value for the metric. Although this property accepts numbers of type Double, it won't accept values
* that are either too small or too large. Values must be in the range of -2^360 to 2^360. The value must be a valid
* number based on the choice of metric. For example, if the metric is CPU utilization, then the target value is a
* percent value that represents how much of the CPU can be used before scaling out.
*
*
*
* If the scaling policy specifies the ALBRequestCountPerTarget
predefined metric, specify the target
* utilization as the optimal average request count per target during any one-minute interval.
*
*
*
* @return The target value for the metric. Although this property accepts numbers of type Double, it won't accept
* values that are either too small or too large. Values must be in the range of -2^360 to 2^360. The value
* must be a valid number based on the choice of metric. For example, if the metric is CPU utilization, then
* the target value is a percent value that represents how much of the CPU can be used before scaling out.
*
*
* If the scaling policy specifies the ALBRequestCountPerTarget
predefined metric, specify the
* target utilization as the optimal average request count per target during any one-minute interval.
*
*/
public final Double targetValue() {
return targetValue;
}
/**
*
* A predefined metric. You can specify either a predefined metric or a customized metric.
*
*
* @return A predefined metric. You can specify either a predefined metric or a customized metric.
*/
public final PredefinedMetricSpecification predefinedMetricSpecification() {
return predefinedMetricSpecification;
}
/**
*
* A customized metric. You can specify either a predefined metric or a customized metric.
*
*
* @return A customized metric. You can specify either a predefined metric or a customized metric.
*/
public final CustomizedMetricSpecification customizedMetricSpecification() {
return customizedMetricSpecification;
}
/**
*
* The amount of time, in seconds, to wait for a previous scale-out activity to take effect. For more information
* and for default values, see Define cooldown periods in the Application Auto Scaling User Guide.
*
*
* @return The amount of time, in seconds, to wait for a previous scale-out activity to take effect. For more
* information and for default values, see Define cooldown periods in the Application Auto Scaling User Guide.
*/
public final Integer scaleOutCooldown() {
return scaleOutCooldown;
}
/**
*
* The amount of time, in seconds, after a scale-in activity completes before another scale-in activity can start.
* For more information and for default values, see Define cooldown periods in the Application Auto Scaling User Guide.
*
*
* @return The amount of time, in seconds, after a scale-in activity completes before another scale-in activity can
* start. For more information and for default values, see Define cooldown periods in the Application Auto Scaling User Guide.
*/
public final Integer scaleInCooldown() {
return scaleInCooldown;
}
/**
*
* Indicates whether scale in by the target tracking scaling policy is disabled. If the value is true
,
* scale in is disabled and the target tracking scaling policy won't remove capacity from the scalable target.
* Otherwise, scale in is enabled and the target tracking scaling policy can remove capacity from the scalable
* target. The default value is false
.
*
*
* @return Indicates whether scale in by the target tracking scaling policy is disabled. If the value is
* true
, scale in is disabled and the target tracking scaling policy won't remove capacity from
* the scalable target. Otherwise, scale in is enabled and the target tracking scaling policy can remove
* capacity from the scalable target. The default value 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(targetValue());
hashCode = 31 * hashCode + Objects.hashCode(predefinedMetricSpecification());
hashCode = 31 * hashCode + Objects.hashCode(customizedMetricSpecification());
hashCode = 31 * hashCode + Objects.hashCode(scaleOutCooldown());
hashCode = 31 * hashCode + Objects.hashCode(scaleInCooldown());
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 TargetTrackingScalingPolicyConfiguration)) {
return false;
}
TargetTrackingScalingPolicyConfiguration other = (TargetTrackingScalingPolicyConfiguration) obj;
return Objects.equals(targetValue(), other.targetValue())
&& Objects.equals(predefinedMetricSpecification(), other.predefinedMetricSpecification())
&& Objects.equals(customizedMetricSpecification(), other.customizedMetricSpecification())
&& Objects.equals(scaleOutCooldown(), other.scaleOutCooldown())
&& Objects.equals(scaleInCooldown(), other.scaleInCooldown())
&& 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("TargetTrackingScalingPolicyConfiguration").add("TargetValue", targetValue())
.add("PredefinedMetricSpecification", predefinedMetricSpecification())
.add("CustomizedMetricSpecification", customizedMetricSpecification())
.add("ScaleOutCooldown", scaleOutCooldown()).add("ScaleInCooldown", scaleInCooldown())
.add("DisableScaleIn", disableScaleIn()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "TargetValue":
return Optional.ofNullable(clazz.cast(targetValue()));
case "PredefinedMetricSpecification":
return Optional.ofNullable(clazz.cast(predefinedMetricSpecification()));
case "CustomizedMetricSpecification":
return Optional.ofNullable(clazz.cast(customizedMetricSpecification()));
case "ScaleOutCooldown":
return Optional.ofNullable(clazz.cast(scaleOutCooldown()));
case "ScaleInCooldown":
return Optional.ofNullable(clazz.cast(scaleInCooldown()));
case "DisableScaleIn":
return Optional.ofNullable(clazz.cast(disableScaleIn()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function