All Downloads are FREE. Search and download functionalities are using the official Maven repository.

software.amazon.awssdk.services.emr.model.CloudWatchAlarmDefinition Maven / Gradle / Ivy

Go to download

The AWS Java SDK for Amazon EMR module holds the client classes that are used for communicating with Amazon Elastic MapReduce Service

There is a newer version: 2.28.3
Show newest version
/*
 * 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.emr.model;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Collection;
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 java.util.stream.Collectors;
import java.util.stream.Stream;
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.ListTrait;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList;
import software.amazon.awssdk.core.util.SdkAutoConstructList;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;

/**
 * 

* The definition of a CloudWatch metric alarm, which determines when an automatic scaling activity is triggered. When * the defined alarm conditions are satisfied, scaling activity begins. *

*/ @Generated("software.amazon.awssdk:codegen") public final class CloudWatchAlarmDefinition implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField COMPARISON_OPERATOR_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("ComparisonOperator").getter(getter(CloudWatchAlarmDefinition::comparisonOperatorAsString)) .setter(setter(Builder::comparisonOperator)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ComparisonOperator").build()) .build(); private static final SdkField EVALUATION_PERIODS_FIELD = SdkField. builder(MarshallingType.INTEGER) .memberName("EvaluationPeriods").getter(getter(CloudWatchAlarmDefinition::evaluationPeriods)) .setter(setter(Builder::evaluationPeriods)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EvaluationPeriods").build()).build(); private static final SdkField METRIC_NAME_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("MetricName").getter(getter(CloudWatchAlarmDefinition::metricName)).setter(setter(Builder::metricName)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MetricName").build()).build(); private static final SdkField NAMESPACE_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("Namespace").getter(getter(CloudWatchAlarmDefinition::namespace)).setter(setter(Builder::namespace)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Namespace").build()).build(); private static final SdkField PERIOD_FIELD = SdkField. builder(MarshallingType.INTEGER) .memberName("Period").getter(getter(CloudWatchAlarmDefinition::period)).setter(setter(Builder::period)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Period").build()).build(); private static final SdkField STATISTIC_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("Statistic").getter(getter(CloudWatchAlarmDefinition::statisticAsString)) .setter(setter(Builder::statistic)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Statistic").build()).build(); private static final SdkField THRESHOLD_FIELD = SdkField. builder(MarshallingType.DOUBLE) .memberName("Threshold").getter(getter(CloudWatchAlarmDefinition::threshold)).setter(setter(Builder::threshold)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Threshold").build()).build(); private static final SdkField UNIT_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Unit") .getter(getter(CloudWatchAlarmDefinition::unitAsString)).setter(setter(Builder::unit)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Unit").build()).build(); private static final SdkField> DIMENSIONS_FIELD = SdkField .> builder(MarshallingType.LIST) .memberName("Dimensions") .getter(getter(CloudWatchAlarmDefinition::dimensions)) .setter(setter(Builder::dimensions)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Dimensions").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField. builder(MarshallingType.SDK_POJO) .constructor(MetricDimension::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()).build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(COMPARISON_OPERATOR_FIELD, EVALUATION_PERIODS_FIELD, METRIC_NAME_FIELD, NAMESPACE_FIELD, PERIOD_FIELD, STATISTIC_FIELD, THRESHOLD_FIELD, UNIT_FIELD, DIMENSIONS_FIELD)); private static final long serialVersionUID = 1L; private final String comparisonOperator; private final Integer evaluationPeriods; private final String metricName; private final String namespace; private final Integer period; private final String statistic; private final Double threshold; private final String unit; private final List dimensions; private CloudWatchAlarmDefinition(BuilderImpl builder) { this.comparisonOperator = builder.comparisonOperator; this.evaluationPeriods = builder.evaluationPeriods; this.metricName = builder.metricName; this.namespace = builder.namespace; this.period = builder.period; this.statistic = builder.statistic; this.threshold = builder.threshold; this.unit = builder.unit; this.dimensions = builder.dimensions; } /** *

* Determines how the metric specified by MetricName is compared to the value specified by * Threshold. *

*

* If the service returns an enum value that is not available in the current SDK version, * {@link #comparisonOperator} will return {@link ComparisonOperator#UNKNOWN_TO_SDK_VERSION}. The raw value returned * by the service is available from {@link #comparisonOperatorAsString}. *

* * @return Determines how the metric specified by MetricName is compared to the value specified by * Threshold. * @see ComparisonOperator */ public final ComparisonOperator comparisonOperator() { return ComparisonOperator.fromValue(comparisonOperator); } /** *

* Determines how the metric specified by MetricName is compared to the value specified by * Threshold. *

*

* If the service returns an enum value that is not available in the current SDK version, * {@link #comparisonOperator} will return {@link ComparisonOperator#UNKNOWN_TO_SDK_VERSION}. The raw value returned * by the service is available from {@link #comparisonOperatorAsString}. *

* * @return Determines how the metric specified by MetricName is compared to the value specified by * Threshold. * @see ComparisonOperator */ public final String comparisonOperatorAsString() { return comparisonOperator; } /** *

* The number of periods, in five-minute increments, during which the alarm condition must exist before the alarm * triggers automatic scaling activity. The default value is 1. *

* * @return The number of periods, in five-minute increments, during which the alarm condition must exist before the * alarm triggers automatic scaling activity. The default value is 1. */ public final Integer evaluationPeriods() { return evaluationPeriods; } /** *

* The name of the CloudWatch metric that is watched to determine an alarm condition. *

* * @return The name of the CloudWatch metric that is watched to determine an alarm condition. */ public final String metricName() { return metricName; } /** *

* The namespace for the CloudWatch metric. The default is AWS/ElasticMapReduce. *

* * @return The namespace for the CloudWatch metric. The default is AWS/ElasticMapReduce. */ public final String namespace() { return namespace; } /** *

* The period, in seconds, over which the statistic is applied. CloudWatch metrics for Amazon EMR are emitted every * five minutes (300 seconds), so if you specify a CloudWatch metric, specify 300. *

* * @return The period, in seconds, over which the statistic is applied. CloudWatch metrics for Amazon EMR are * emitted every five minutes (300 seconds), so if you specify a CloudWatch metric, specify 300 * . */ public final Integer period() { return period; } /** *

* The statistic to apply to the metric associated with the alarm. The default is AVERAGE. *

*

* If the service returns an enum value that is not available in the current SDK version, {@link #statistic} will * return {@link Statistic#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from * {@link #statisticAsString}. *

* * @return The statistic to apply to the metric associated with the alarm. The default is AVERAGE. * @see Statistic */ public final Statistic statistic() { return Statistic.fromValue(statistic); } /** *

* The statistic to apply to the metric associated with the alarm. The default is AVERAGE. *

*

* If the service returns an enum value that is not available in the current SDK version, {@link #statistic} will * return {@link Statistic#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from * {@link #statisticAsString}. *

* * @return The statistic to apply to the metric associated with the alarm. The default is AVERAGE. * @see Statistic */ public final String statisticAsString() { return statistic; } /** *

* The value against which the specified statistic is compared. *

* * @return The value against which the specified statistic is compared. */ public final Double threshold() { return threshold; } /** *

* The unit of measure associated with the CloudWatch metric being watched. The value specified for * Unit must correspond to the units specified in the CloudWatch metric. *

*

* If the service returns an enum value that is not available in the current SDK version, {@link #unit} will return * {@link Unit#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from * {@link #unitAsString}. *

* * @return The unit of measure associated with the CloudWatch metric being watched. The value specified for * Unit must correspond to the units specified in the CloudWatch metric. * @see Unit */ public final Unit unit() { return Unit.fromValue(unit); } /** *

* The unit of measure associated with the CloudWatch metric being watched. The value specified for * Unit must correspond to the units specified in the CloudWatch metric. *

*

* If the service returns an enum value that is not available in the current SDK version, {@link #unit} will return * {@link Unit#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from * {@link #unitAsString}. *

* * @return The unit of measure associated with the CloudWatch metric being watched. The value specified for * Unit must correspond to the units specified in the CloudWatch metric. * @see Unit */ public final String unitAsString() { return unit; } /** * For responses, this returns true if the service returned a value for the Dimensions property. This DOES NOT check * that the value is non-empty (for which, you should check the {@code isEmpty()} method on the property). This is * useful because the SDK will never return a null collection or map, but you may need to differentiate between the * service returning nothing (or null) and the service returning an empty collection or map. For requests, this * returns true if a value for the property was specified in the request builder, and false if a value was not * specified. */ public final boolean hasDimensions() { return dimensions != null && !(dimensions instanceof SdkAutoConstructList); } /** *

* A CloudWatch metric dimension. *

*

* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. *

*

* This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasDimensions} method. *

* * @return A CloudWatch metric dimension. */ public final List dimensions() { return dimensions; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class serializableBuilderClass() { return BuilderImpl.class; } @Override public final int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + Objects.hashCode(comparisonOperatorAsString()); hashCode = 31 * hashCode + Objects.hashCode(evaluationPeriods()); hashCode = 31 * hashCode + Objects.hashCode(metricName()); hashCode = 31 * hashCode + Objects.hashCode(namespace()); hashCode = 31 * hashCode + Objects.hashCode(period()); hashCode = 31 * hashCode + Objects.hashCode(statisticAsString()); hashCode = 31 * hashCode + Objects.hashCode(threshold()); hashCode = 31 * hashCode + Objects.hashCode(unitAsString()); hashCode = 31 * hashCode + Objects.hashCode(hasDimensions() ? dimensions() : null); 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 CloudWatchAlarmDefinition)) { return false; } CloudWatchAlarmDefinition other = (CloudWatchAlarmDefinition) obj; return Objects.equals(comparisonOperatorAsString(), other.comparisonOperatorAsString()) && Objects.equals(evaluationPeriods(), other.evaluationPeriods()) && Objects.equals(metricName(), other.metricName()) && Objects.equals(namespace(), other.namespace()) && Objects.equals(period(), other.period()) && Objects.equals(statisticAsString(), other.statisticAsString()) && Objects.equals(threshold(), other.threshold()) && Objects.equals(unitAsString(), other.unitAsString()) && hasDimensions() == other.hasDimensions() && Objects.equals(dimensions(), other.dimensions()); } /** * 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("CloudWatchAlarmDefinition").add("ComparisonOperator", comparisonOperatorAsString()) .add("EvaluationPeriods", evaluationPeriods()).add("MetricName", metricName()).add("Namespace", namespace()) .add("Period", period()).add("Statistic", statisticAsString()).add("Threshold", threshold()) .add("Unit", unitAsString()).add("Dimensions", hasDimensions() ? dimensions() : null).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "ComparisonOperator": return Optional.ofNullable(clazz.cast(comparisonOperatorAsString())); case "EvaluationPeriods": return Optional.ofNullable(clazz.cast(evaluationPeriods())); case "MetricName": return Optional.ofNullable(clazz.cast(metricName())); case "Namespace": return Optional.ofNullable(clazz.cast(namespace())); case "Period": return Optional.ofNullable(clazz.cast(period())); case "Statistic": return Optional.ofNullable(clazz.cast(statisticAsString())); case "Threshold": return Optional.ofNullable(clazz.cast(threshold())); case "Unit": return Optional.ofNullable(clazz.cast(unitAsString())); case "Dimensions": return Optional.ofNullable(clazz.cast(dimensions())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((CloudWatchAlarmDefinition) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* Determines how the metric specified by MetricName is compared to the value specified by * Threshold. *

* * @param comparisonOperator * Determines how the metric specified by MetricName is compared to the value specified by * Threshold. * @see ComparisonOperator * @return Returns a reference to this object so that method calls can be chained together. * @see ComparisonOperator */ Builder comparisonOperator(String comparisonOperator); /** *

* Determines how the metric specified by MetricName is compared to the value specified by * Threshold. *

* * @param comparisonOperator * Determines how the metric specified by MetricName is compared to the value specified by * Threshold. * @see ComparisonOperator * @return Returns a reference to this object so that method calls can be chained together. * @see ComparisonOperator */ Builder comparisonOperator(ComparisonOperator comparisonOperator); /** *

* The number of periods, in five-minute increments, during which the alarm condition must exist before the * alarm triggers automatic scaling activity. The default value is 1. *

* * @param evaluationPeriods * The number of periods, in five-minute increments, during which the alarm condition must exist before * the alarm triggers automatic scaling activity. The default value is 1. * @return Returns a reference to this object so that method calls can be chained together. */ Builder evaluationPeriods(Integer evaluationPeriods); /** *

* The name of the CloudWatch metric that is watched to determine an alarm condition. *

* * @param metricName * The name of the CloudWatch metric that is watched to determine an alarm condition. * @return Returns a reference to this object so that method calls can be chained together. */ Builder metricName(String metricName); /** *

* The namespace for the CloudWatch metric. The default is AWS/ElasticMapReduce. *

* * @param namespace * The namespace for the CloudWatch metric. The default is AWS/ElasticMapReduce. * @return Returns a reference to this object so that method calls can be chained together. */ Builder namespace(String namespace); /** *

* The period, in seconds, over which the statistic is applied. CloudWatch metrics for Amazon EMR are emitted * every five minutes (300 seconds), so if you specify a CloudWatch metric, specify 300. *

* * @param period * The period, in seconds, over which the statistic is applied. CloudWatch metrics for Amazon EMR are * emitted every five minutes (300 seconds), so if you specify a CloudWatch metric, specify * 300. * @return Returns a reference to this object so that method calls can be chained together. */ Builder period(Integer period); /** *

* The statistic to apply to the metric associated with the alarm. The default is AVERAGE. *

* * @param statistic * The statistic to apply to the metric associated with the alarm. The default is AVERAGE. * @see Statistic * @return Returns a reference to this object so that method calls can be chained together. * @see Statistic */ Builder statistic(String statistic); /** *

* The statistic to apply to the metric associated with the alarm. The default is AVERAGE. *

* * @param statistic * The statistic to apply to the metric associated with the alarm. The default is AVERAGE. * @see Statistic * @return Returns a reference to this object so that method calls can be chained together. * @see Statistic */ Builder statistic(Statistic statistic); /** *

* The value against which the specified statistic is compared. *

* * @param threshold * The value against which the specified statistic is compared. * @return Returns a reference to this object so that method calls can be chained together. */ Builder threshold(Double threshold); /** *

* The unit of measure associated with the CloudWatch metric being watched. The value specified for * Unit must correspond to the units specified in the CloudWatch metric. *

* * @param unit * The unit of measure associated with the CloudWatch metric being watched. The value specified for * Unit must correspond to the units specified in the CloudWatch metric. * @see Unit * @return Returns a reference to this object so that method calls can be chained together. * @see Unit */ Builder unit(String unit); /** *

* The unit of measure associated with the CloudWatch metric being watched. The value specified for * Unit must correspond to the units specified in the CloudWatch metric. *

* * @param unit * The unit of measure associated with the CloudWatch metric being watched. The value specified for * Unit must correspond to the units specified in the CloudWatch metric. * @see Unit * @return Returns a reference to this object so that method calls can be chained together. * @see Unit */ Builder unit(Unit unit); /** *

* A CloudWatch metric dimension. *

* * @param dimensions * A CloudWatch metric dimension. * @return Returns a reference to this object so that method calls can be chained together. */ Builder dimensions(Collection dimensions); /** *

* A CloudWatch metric dimension. *

* * @param dimensions * A CloudWatch metric dimension. * @return Returns a reference to this object so that method calls can be chained together. */ Builder dimensions(MetricDimension... dimensions); /** *

* A CloudWatch metric dimension. *

* This is a convenience method that creates an instance of the * {@link software.amazon.awssdk.services.emr.model.MetricDimension.Builder} avoiding the need to create one * manually via {@link software.amazon.awssdk.services.emr.model.MetricDimension#builder()}. * *

* When the {@link Consumer} completes, * {@link software.amazon.awssdk.services.emr.model.MetricDimension.Builder#build()} is called immediately and * its result is passed to {@link #dimensions(List)}. * * @param dimensions * a consumer that will call methods on * {@link software.amazon.awssdk.services.emr.model.MetricDimension.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #dimensions(java.util.Collection) */ Builder dimensions(Consumer... dimensions); } static final class BuilderImpl implements Builder { private String comparisonOperator; private Integer evaluationPeriods; private String metricName; private String namespace; private Integer period; private String statistic; private Double threshold; private String unit; private List dimensions = DefaultSdkAutoConstructList.getInstance(); private BuilderImpl() { } private BuilderImpl(CloudWatchAlarmDefinition model) { comparisonOperator(model.comparisonOperator); evaluationPeriods(model.evaluationPeriods); metricName(model.metricName); namespace(model.namespace); period(model.period); statistic(model.statistic); threshold(model.threshold); unit(model.unit); dimensions(model.dimensions); } public final String getComparisonOperator() { return comparisonOperator; } public final void setComparisonOperator(String comparisonOperator) { this.comparisonOperator = comparisonOperator; } @Override public final Builder comparisonOperator(String comparisonOperator) { this.comparisonOperator = comparisonOperator; return this; } @Override public final Builder comparisonOperator(ComparisonOperator comparisonOperator) { this.comparisonOperator(comparisonOperator == null ? null : comparisonOperator.toString()); return this; } public final Integer getEvaluationPeriods() { return evaluationPeriods; } public final void setEvaluationPeriods(Integer evaluationPeriods) { this.evaluationPeriods = evaluationPeriods; } @Override public final Builder evaluationPeriods(Integer evaluationPeriods) { this.evaluationPeriods = evaluationPeriods; return this; } public final String getMetricName() { return metricName; } public final void setMetricName(String metricName) { this.metricName = metricName; } @Override public final Builder metricName(String metricName) { this.metricName = metricName; return this; } public final String getNamespace() { return namespace; } public final void setNamespace(String namespace) { this.namespace = namespace; } @Override public final Builder namespace(String namespace) { this.namespace = namespace; return this; } public final Integer getPeriod() { return period; } public final void setPeriod(Integer period) { this.period = period; } @Override public final Builder period(Integer period) { this.period = period; return this; } public final String getStatistic() { return statistic; } public final void setStatistic(String statistic) { this.statistic = statistic; } @Override public final Builder statistic(String statistic) { this.statistic = statistic; return this; } @Override public final Builder statistic(Statistic statistic) { this.statistic(statistic == null ? null : statistic.toString()); return this; } public final Double getThreshold() { return threshold; } public final void setThreshold(Double threshold) { this.threshold = threshold; } @Override public final Builder threshold(Double threshold) { this.threshold = threshold; return this; } public final String getUnit() { return unit; } public final void setUnit(String unit) { this.unit = unit; } @Override public final Builder unit(String unit) { this.unit = unit; return this; } @Override public final Builder unit(Unit unit) { this.unit(unit == null ? null : unit.toString()); return this; } public final List getDimensions() { List result = MetricDimensionListCopier.copyToBuilder(this.dimensions); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setDimensions(Collection dimensions) { this.dimensions = MetricDimensionListCopier.copyFromBuilder(dimensions); } @Override public final Builder dimensions(Collection dimensions) { this.dimensions = MetricDimensionListCopier.copy(dimensions); return this; } @Override @SafeVarargs public final Builder dimensions(MetricDimension... dimensions) { dimensions(Arrays.asList(dimensions)); return this; } @Override @SafeVarargs public final Builder dimensions(Consumer... dimensions) { dimensions(Stream.of(dimensions).map(c -> MetricDimension.builder().applyMutation(c).build()) .collect(Collectors.toList())); return this; } @Override public CloudWatchAlarmDefinition build() { return new CloudWatchAlarmDefinition(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy