software.amazon.awssdk.services.emr.model.InstanceGroupConfig Maven / Gradle / Ivy
/*
* 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;
/**
*
* Configuration defining a new instance group.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class InstanceGroupConfig implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField NAME_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Name")
.getter(getter(InstanceGroupConfig::name)).setter(setter(Builder::name))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Name").build()).build();
private static final SdkField MARKET_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Market")
.getter(getter(InstanceGroupConfig::marketAsString)).setter(setter(Builder::market))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Market").build()).build();
private static final SdkField INSTANCE_ROLE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("InstanceRole").getter(getter(InstanceGroupConfig::instanceRoleAsString))
.setter(setter(Builder::instanceRole))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("InstanceRole").build()).build();
private static final SdkField BID_PRICE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("BidPrice").getter(getter(InstanceGroupConfig::bidPrice)).setter(setter(Builder::bidPrice))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("BidPrice").build()).build();
private static final SdkField INSTANCE_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("InstanceType").getter(getter(InstanceGroupConfig::instanceType)).setter(setter(Builder::instanceType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("InstanceType").build()).build();
private static final SdkField INSTANCE_COUNT_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("InstanceCount").getter(getter(InstanceGroupConfig::instanceCount))
.setter(setter(Builder::instanceCount))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("InstanceCount").build()).build();
private static final SdkField> CONFIGURATIONS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("Configurations")
.getter(getter(InstanceGroupConfig::configurations))
.setter(setter(Builder::configurations))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Configurations").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(Configuration::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField EBS_CONFIGURATION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("EbsConfiguration")
.getter(getter(InstanceGroupConfig::ebsConfiguration)).setter(setter(Builder::ebsConfiguration))
.constructor(EbsConfiguration::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EbsConfiguration").build()).build();
private static final SdkField AUTO_SCALING_POLICY_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("AutoScalingPolicy")
.getter(getter(InstanceGroupConfig::autoScalingPolicy)).setter(setter(Builder::autoScalingPolicy))
.constructor(AutoScalingPolicy::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AutoScalingPolicy").build()).build();
private static final SdkField CUSTOM_AMI_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("CustomAmiId").getter(getter(InstanceGroupConfig::customAmiId)).setter(setter(Builder::customAmiId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CustomAmiId").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(NAME_FIELD, MARKET_FIELD,
INSTANCE_ROLE_FIELD, BID_PRICE_FIELD, INSTANCE_TYPE_FIELD, INSTANCE_COUNT_FIELD, CONFIGURATIONS_FIELD,
EBS_CONFIGURATION_FIELD, AUTO_SCALING_POLICY_FIELD, CUSTOM_AMI_ID_FIELD));
private static final long serialVersionUID = 1L;
private final String name;
private final String market;
private final String instanceRole;
private final String bidPrice;
private final String instanceType;
private final Integer instanceCount;
private final List configurations;
private final EbsConfiguration ebsConfiguration;
private final AutoScalingPolicy autoScalingPolicy;
private final String customAmiId;
private InstanceGroupConfig(BuilderImpl builder) {
this.name = builder.name;
this.market = builder.market;
this.instanceRole = builder.instanceRole;
this.bidPrice = builder.bidPrice;
this.instanceType = builder.instanceType;
this.instanceCount = builder.instanceCount;
this.configurations = builder.configurations;
this.ebsConfiguration = builder.ebsConfiguration;
this.autoScalingPolicy = builder.autoScalingPolicy;
this.customAmiId = builder.customAmiId;
}
/**
*
* Friendly name given to the instance group.
*
*
* @return Friendly name given to the instance group.
*/
public final String name() {
return name;
}
/**
*
* Market type of the Amazon EC2 instances used to create a cluster node.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #market} will
* return {@link MarketType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #marketAsString}.
*
*
* @return Market type of the Amazon EC2 instances used to create a cluster node.
* @see MarketType
*/
public final MarketType market() {
return MarketType.fromValue(market);
}
/**
*
* Market type of the Amazon EC2 instances used to create a cluster node.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #market} will
* return {@link MarketType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #marketAsString}.
*
*
* @return Market type of the Amazon EC2 instances used to create a cluster node.
* @see MarketType
*/
public final String marketAsString() {
return market;
}
/**
*
* The role of the instance group in the cluster.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #instanceRole} will
* return {@link InstanceRoleType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #instanceRoleAsString}.
*
*
* @return The role of the instance group in the cluster.
* @see InstanceRoleType
*/
public final InstanceRoleType instanceRole() {
return InstanceRoleType.fromValue(instanceRole);
}
/**
*
* The role of the instance group in the cluster.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #instanceRole} will
* return {@link InstanceRoleType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #instanceRoleAsString}.
*
*
* @return The role of the instance group in the cluster.
* @see InstanceRoleType
*/
public final String instanceRoleAsString() {
return instanceRole;
}
/**
*
* If specified, indicates that the instance group uses Spot Instances. This is the maximum price you are willing to
* pay for Spot Instances. Specify OnDemandPrice
to set the amount equal to the On-Demand price, or
* specify an amount in USD.
*
*
* @return If specified, indicates that the instance group uses Spot Instances. This is the maximum price you are
* willing to pay for Spot Instances. Specify OnDemandPrice
to set the amount equal to the
* On-Demand price, or specify an amount in USD.
*/
public final String bidPrice() {
return bidPrice;
}
/**
*
* The Amazon EC2 instance type for all instances in the instance group.
*
*
* @return The Amazon EC2 instance type for all instances in the instance group.
*/
public final String instanceType() {
return instanceType;
}
/**
*
* Target number of instances for the instance group.
*
*
* @return Target number of instances for the instance group.
*/
public final Integer instanceCount() {
return instanceCount;
}
/**
* For responses, this returns true if the service returned a value for the Configurations 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 hasConfigurations() {
return configurations != null && !(configurations instanceof SdkAutoConstructList);
}
/**
*
*
* Amazon EMR releases 4.x or later.
*
*
*
* The list of configurations supplied for an Amazon EMR cluster instance group. You can specify a separate
* configuration for each instance group (master, core, and task).
*
*
* 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 #hasConfigurations} method.
*
*
* @return
* Amazon EMR releases 4.x or later.
*
*
*
* The list of configurations supplied for an Amazon EMR cluster instance group. You can specify a separate
* configuration for each instance group (master, core, and task).
*/
public final List configurations() {
return configurations;
}
/**
*
* EBS configurations that will be attached to each Amazon EC2 instance in the instance group.
*
*
* @return EBS configurations that will be attached to each Amazon EC2 instance in the instance group.
*/
public final EbsConfiguration ebsConfiguration() {
return ebsConfiguration;
}
/**
*
* An automatic scaling policy for a core instance group or task instance group in an Amazon EMR cluster. The
* automatic scaling policy defines how an instance group dynamically adds and terminates Amazon EC2 instances in
* response to the value of a CloudWatch metric. See PutAutoScalingPolicy.
*
*
* @return An automatic scaling policy for a core instance group or task instance group in an Amazon EMR cluster.
* The automatic scaling policy defines how an instance group dynamically adds and terminates Amazon EC2
* instances in response to the value of a CloudWatch metric. See PutAutoScalingPolicy.
*/
public final AutoScalingPolicy autoScalingPolicy() {
return autoScalingPolicy;
}
/**
*
* The custom AMI ID to use for the provisioned instance group.
*
*
* @return The custom AMI ID to use for the provisioned instance group.
*/
public final String customAmiId() {
return customAmiId;
}
@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(name());
hashCode = 31 * hashCode + Objects.hashCode(marketAsString());
hashCode = 31 * hashCode + Objects.hashCode(instanceRoleAsString());
hashCode = 31 * hashCode + Objects.hashCode(bidPrice());
hashCode = 31 * hashCode + Objects.hashCode(instanceType());
hashCode = 31 * hashCode + Objects.hashCode(instanceCount());
hashCode = 31 * hashCode + Objects.hashCode(hasConfigurations() ? configurations() : null);
hashCode = 31 * hashCode + Objects.hashCode(ebsConfiguration());
hashCode = 31 * hashCode + Objects.hashCode(autoScalingPolicy());
hashCode = 31 * hashCode + Objects.hashCode(customAmiId());
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 InstanceGroupConfig)) {
return false;
}
InstanceGroupConfig other = (InstanceGroupConfig) obj;
return Objects.equals(name(), other.name()) && Objects.equals(marketAsString(), other.marketAsString())
&& Objects.equals(instanceRoleAsString(), other.instanceRoleAsString())
&& Objects.equals(bidPrice(), other.bidPrice()) && Objects.equals(instanceType(), other.instanceType())
&& Objects.equals(instanceCount(), other.instanceCount()) && hasConfigurations() == other.hasConfigurations()
&& Objects.equals(configurations(), other.configurations())
&& Objects.equals(ebsConfiguration(), other.ebsConfiguration())
&& Objects.equals(autoScalingPolicy(), other.autoScalingPolicy())
&& Objects.equals(customAmiId(), other.customAmiId());
}
/**
* 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("InstanceGroupConfig").add("Name", name()).add("Market", marketAsString())
.add("InstanceRole", instanceRoleAsString()).add("BidPrice", bidPrice()).add("InstanceType", instanceType())
.add("InstanceCount", instanceCount()).add("Configurations", hasConfigurations() ? configurations() : null)
.add("EbsConfiguration", ebsConfiguration()).add("AutoScalingPolicy", autoScalingPolicy())
.add("CustomAmiId", customAmiId()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Name":
return Optional.ofNullable(clazz.cast(name()));
case "Market":
return Optional.ofNullable(clazz.cast(marketAsString()));
case "InstanceRole":
return Optional.ofNullable(clazz.cast(instanceRoleAsString()));
case "BidPrice":
return Optional.ofNullable(clazz.cast(bidPrice()));
case "InstanceType":
return Optional.ofNullable(clazz.cast(instanceType()));
case "InstanceCount":
return Optional.ofNullable(clazz.cast(instanceCount()));
case "Configurations":
return Optional.ofNullable(clazz.cast(configurations()));
case "EbsConfiguration":
return Optional.ofNullable(clazz.cast(ebsConfiguration()));
case "AutoScalingPolicy":
return Optional.ofNullable(clazz.cast(autoScalingPolicy()));
case "CustomAmiId":
return Optional.ofNullable(clazz.cast(customAmiId()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function