software.amazon.awssdk.services.emr.model.InstanceFleet 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.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 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;
/**
*
* Describes an instance fleet, which is a group of Amazon EC2 instances that host a particular node type (master, core,
* or task) in an Amazon EMR cluster. Instance fleets can consist of a mix of instance types and On-Demand and Spot
* Instances, which are provisioned to meet a defined target capacity.
*
*
*
* The instance fleet configuration is available only in Amazon EMR releases 4.8.0 and later, excluding 5.0.x versions.
*
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class InstanceFleet implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField ID_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Id")
.getter(getter(InstanceFleet::id)).setter(setter(Builder::id))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Id").build()).build();
private static final SdkField NAME_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Name")
.getter(getter(InstanceFleet::name)).setter(setter(Builder::name))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Name").build()).build();
private static final SdkField STATUS_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("Status").getter(getter(InstanceFleet::status))
.setter(setter(Builder::status)).constructor(InstanceFleetStatus::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Status").build()).build();
private static final SdkField INSTANCE_FLEET_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("InstanceFleetType").getter(getter(InstanceFleet::instanceFleetTypeAsString))
.setter(setter(Builder::instanceFleetType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("InstanceFleetType").build()).build();
private static final SdkField TARGET_ON_DEMAND_CAPACITY_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("TargetOnDemandCapacity").getter(getter(InstanceFleet::targetOnDemandCapacity))
.setter(setter(Builder::targetOnDemandCapacity))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TargetOnDemandCapacity").build())
.build();
private static final SdkField TARGET_SPOT_CAPACITY_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("TargetSpotCapacity").getter(getter(InstanceFleet::targetSpotCapacity))
.setter(setter(Builder::targetSpotCapacity))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TargetSpotCapacity").build())
.build();
private static final SdkField PROVISIONED_ON_DEMAND_CAPACITY_FIELD = SdkField
. builder(MarshallingType.INTEGER)
.memberName("ProvisionedOnDemandCapacity")
.getter(getter(InstanceFleet::provisionedOnDemandCapacity))
.setter(setter(Builder::provisionedOnDemandCapacity))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ProvisionedOnDemandCapacity")
.build()).build();
private static final SdkField PROVISIONED_SPOT_CAPACITY_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("ProvisionedSpotCapacity").getter(getter(InstanceFleet::provisionedSpotCapacity))
.setter(setter(Builder::provisionedSpotCapacity))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ProvisionedSpotCapacity").build())
.build();
private static final SdkField> INSTANCE_TYPE_SPECIFICATIONS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("InstanceTypeSpecifications")
.getter(getter(InstanceFleet::instanceTypeSpecifications))
.setter(setter(Builder::instanceTypeSpecifications))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("InstanceTypeSpecifications").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(InstanceTypeSpecification::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField LAUNCH_SPECIFICATIONS_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("LaunchSpecifications")
.getter(getter(InstanceFleet::launchSpecifications)).setter(setter(Builder::launchSpecifications))
.constructor(InstanceFleetProvisioningSpecifications::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LaunchSpecifications").build())
.build();
private static final SdkField RESIZE_SPECIFICATIONS_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("ResizeSpecifications")
.getter(getter(InstanceFleet::resizeSpecifications)).setter(setter(Builder::resizeSpecifications))
.constructor(InstanceFleetResizingSpecifications::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ResizeSpecifications").build())
.build();
private static final SdkField CONTEXT_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Context")
.getter(getter(InstanceFleet::context)).setter(setter(Builder::context))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Context").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ID_FIELD, NAME_FIELD,
STATUS_FIELD, INSTANCE_FLEET_TYPE_FIELD, TARGET_ON_DEMAND_CAPACITY_FIELD, TARGET_SPOT_CAPACITY_FIELD,
PROVISIONED_ON_DEMAND_CAPACITY_FIELD, PROVISIONED_SPOT_CAPACITY_FIELD, INSTANCE_TYPE_SPECIFICATIONS_FIELD,
LAUNCH_SPECIFICATIONS_FIELD, RESIZE_SPECIFICATIONS_FIELD, CONTEXT_FIELD));
private static final Map> SDK_NAME_TO_FIELD = Collections
.unmodifiableMap(new HashMap>() {
{
put("Id", ID_FIELD);
put("Name", NAME_FIELD);
put("Status", STATUS_FIELD);
put("InstanceFleetType", INSTANCE_FLEET_TYPE_FIELD);
put("TargetOnDemandCapacity", TARGET_ON_DEMAND_CAPACITY_FIELD);
put("TargetSpotCapacity", TARGET_SPOT_CAPACITY_FIELD);
put("ProvisionedOnDemandCapacity", PROVISIONED_ON_DEMAND_CAPACITY_FIELD);
put("ProvisionedSpotCapacity", PROVISIONED_SPOT_CAPACITY_FIELD);
put("InstanceTypeSpecifications", INSTANCE_TYPE_SPECIFICATIONS_FIELD);
put("LaunchSpecifications", LAUNCH_SPECIFICATIONS_FIELD);
put("ResizeSpecifications", RESIZE_SPECIFICATIONS_FIELD);
put("Context", CONTEXT_FIELD);
}
});
private static final long serialVersionUID = 1L;
private final String id;
private final String name;
private final InstanceFleetStatus status;
private final String instanceFleetType;
private final Integer targetOnDemandCapacity;
private final Integer targetSpotCapacity;
private final Integer provisionedOnDemandCapacity;
private final Integer provisionedSpotCapacity;
private final List instanceTypeSpecifications;
private final InstanceFleetProvisioningSpecifications launchSpecifications;
private final InstanceFleetResizingSpecifications resizeSpecifications;
private final String context;
private InstanceFleet(BuilderImpl builder) {
this.id = builder.id;
this.name = builder.name;
this.status = builder.status;
this.instanceFleetType = builder.instanceFleetType;
this.targetOnDemandCapacity = builder.targetOnDemandCapacity;
this.targetSpotCapacity = builder.targetSpotCapacity;
this.provisionedOnDemandCapacity = builder.provisionedOnDemandCapacity;
this.provisionedSpotCapacity = builder.provisionedSpotCapacity;
this.instanceTypeSpecifications = builder.instanceTypeSpecifications;
this.launchSpecifications = builder.launchSpecifications;
this.resizeSpecifications = builder.resizeSpecifications;
this.context = builder.context;
}
/**
*
* The unique identifier of the instance fleet.
*
*
* @return The unique identifier of the instance fleet.
*/
public final String id() {
return id;
}
/**
*
* A friendly name for the instance fleet.
*
*
* @return A friendly name for the instance fleet.
*/
public final String name() {
return name;
}
/**
*
* The current status of the instance fleet.
*
*
* @return The current status of the instance fleet.
*/
public final InstanceFleetStatus status() {
return status;
}
/**
*
* The node type that the instance fleet hosts. Valid values are MASTER, CORE, or TASK.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #instanceFleetType}
* will return {@link InstanceFleetType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #instanceFleetTypeAsString}.
*
*
* @return The node type that the instance fleet hosts. Valid values are MASTER, CORE, or TASK.
* @see InstanceFleetType
*/
public final InstanceFleetType instanceFleetType() {
return InstanceFleetType.fromValue(instanceFleetType);
}
/**
*
* The node type that the instance fleet hosts. Valid values are MASTER, CORE, or TASK.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #instanceFleetType}
* will return {@link InstanceFleetType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #instanceFleetTypeAsString}.
*
*
* @return The node type that the instance fleet hosts. Valid values are MASTER, CORE, or TASK.
* @see InstanceFleetType
*/
public final String instanceFleetTypeAsString() {
return instanceFleetType;
}
/**
*
* The target capacity of On-Demand units for the instance fleet, which determines how many On-Demand Instances to
* provision. When the instance fleet launches, Amazon EMR tries to provision On-Demand Instances as specified by
* InstanceTypeConfig. Each instance configuration has a specified WeightedCapacity
. When an
* On-Demand Instance is provisioned, the WeightedCapacity
units count toward the target capacity.
* Amazon EMR provisions instances until the target capacity is totally fulfilled, even if this results in an
* overage. For example, if there are 2 units remaining to fulfill capacity, and Amazon EMR can only provision an
* instance with a WeightedCapacity
of 5 units, the instance is provisioned, and the target capacity is
* exceeded by 3 units. You can use InstanceFleet$ProvisionedOnDemandCapacity to determine the Spot capacity
* units that have been provisioned for the instance fleet.
*
*
*
* If not specified or set to 0, only Spot Instances are provisioned for the instance fleet using
* TargetSpotCapacity
. At least one of TargetSpotCapacity
and
* TargetOnDemandCapacity
should be greater than 0. For a master instance fleet, only one of
* TargetSpotCapacity
and TargetOnDemandCapacity
can be specified, and its value must be
* 1.
*
*
*
* @return The target capacity of On-Demand units for the instance fleet, which determines how many On-Demand
* Instances to provision. When the instance fleet launches, Amazon EMR tries to provision On-Demand
* Instances as specified by InstanceTypeConfig. Each instance configuration has a specified
* WeightedCapacity
. When an On-Demand Instance is provisioned, the
* WeightedCapacity
units count toward the target capacity. Amazon EMR provisions instances
* until the target capacity is totally fulfilled, even if this results in an overage. For example, if there
* are 2 units remaining to fulfill capacity, and Amazon EMR can only provision an instance with a
* WeightedCapacity
of 5 units, the instance is provisioned, and the target capacity is
* exceeded by 3 units. You can use InstanceFleet$ProvisionedOnDemandCapacity to determine the Spot
* capacity units that have been provisioned for the instance fleet.
*
* If not specified or set to 0, only Spot Instances are provisioned for the instance fleet using
* TargetSpotCapacity
. At least one of TargetSpotCapacity
and
* TargetOnDemandCapacity
should be greater than 0. For a master instance fleet, only one of
* TargetSpotCapacity
and TargetOnDemandCapacity
can be specified, and its value
* must be 1.
*
*/
public final Integer targetOnDemandCapacity() {
return targetOnDemandCapacity;
}
/**
*
* The target capacity of Spot units for the instance fleet, which determines how many Spot Instances to provision.
* When the instance fleet launches, Amazon EMR tries to provision Spot Instances as specified by
* InstanceTypeConfig. Each instance configuration has a specified WeightedCapacity
. When a Spot
* instance is provisioned, the WeightedCapacity
units count toward the target capacity. Amazon EMR
* provisions instances until the target capacity is totally fulfilled, even if this results in an overage. For
* example, if there are 2 units remaining to fulfill capacity, and Amazon EMR can only provision an instance with a
* WeightedCapacity
of 5 units, the instance is provisioned, and the target capacity is exceeded by 3
* units. You can use InstanceFleet$ProvisionedSpotCapacity to determine the Spot capacity units that have
* been provisioned for the instance fleet.
*
*
*
* If not specified or set to 0, only On-Demand Instances are provisioned for the instance fleet. At least one of
* TargetSpotCapacity
and TargetOnDemandCapacity
should be greater than 0. For a master
* instance fleet, only one of TargetSpotCapacity
and TargetOnDemandCapacity
can be
* specified, and its value must be 1.
*
*
*
* @return The target capacity of Spot units for the instance fleet, which determines how many Spot Instances to
* provision. When the instance fleet launches, Amazon EMR tries to provision Spot Instances as specified by
* InstanceTypeConfig. Each instance configuration has a specified WeightedCapacity
.
* When a Spot instance is provisioned, the WeightedCapacity
units count toward the target
* capacity. Amazon EMR provisions instances until the target capacity is totally fulfilled, even if this
* results in an overage. For example, if there are 2 units remaining to fulfill capacity, and Amazon EMR
* can only provision an instance with a WeightedCapacity
of 5 units, the instance is
* provisioned, and the target capacity is exceeded by 3 units. You can use
* InstanceFleet$ProvisionedSpotCapacity to determine the Spot capacity units that have been
* provisioned for the instance fleet.
*
* If not specified or set to 0, only On-Demand Instances are provisioned for the instance fleet. At least
* one of TargetSpotCapacity
and TargetOnDemandCapacity
should be greater than 0.
* For a master instance fleet, only one of TargetSpotCapacity
and
* TargetOnDemandCapacity
can be specified, and its value must be 1.
*
*/
public final Integer targetSpotCapacity() {
return targetSpotCapacity;
}
/**
*
* The number of On-Demand units that have been provisioned for the instance fleet to fulfill
* TargetOnDemandCapacity
. This provisioned capacity might be less than or greater than
* TargetOnDemandCapacity
.
*
*
* @return The number of On-Demand units that have been provisioned for the instance fleet to fulfill
* TargetOnDemandCapacity
. This provisioned capacity might be less than or greater than
* TargetOnDemandCapacity
.
*/
public final Integer provisionedOnDemandCapacity() {
return provisionedOnDemandCapacity;
}
/**
*
* The number of Spot units that have been provisioned for this instance fleet to fulfill
* TargetSpotCapacity
. This provisioned capacity might be less than or greater than
* TargetSpotCapacity
.
*
*
* @return The number of Spot units that have been provisioned for this instance fleet to fulfill
* TargetSpotCapacity
. This provisioned capacity might be less than or greater than
* TargetSpotCapacity
.
*/
public final Integer provisionedSpotCapacity() {
return provisionedSpotCapacity;
}
/**
* For responses, this returns true if the service returned a value for the InstanceTypeSpecifications 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 hasInstanceTypeSpecifications() {
return instanceTypeSpecifications != null && !(instanceTypeSpecifications instanceof SdkAutoConstructList);
}
/**
*
* An array of specifications for the instance types that comprise an instance fleet.
*
*
* 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 #hasInstanceTypeSpecifications} method.
*
*
* @return An array of specifications for the instance types that comprise an instance fleet.
*/
public final List instanceTypeSpecifications() {
return instanceTypeSpecifications;
}
/**
*
* Describes the launch specification for an instance fleet.
*
*
* @return Describes the launch specification for an instance fleet.
*/
public final InstanceFleetProvisioningSpecifications launchSpecifications() {
return launchSpecifications;
}
/**
*
* The resize specification for the instance fleet.
*
*
* @return The resize specification for the instance fleet.
*/
public final InstanceFleetResizingSpecifications resizeSpecifications() {
return resizeSpecifications;
}
/**
*
* Reserved.
*
*
* @return Reserved.
*/
public final String context() {
return context;
}
@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(id());
hashCode = 31 * hashCode + Objects.hashCode(name());
hashCode = 31 * hashCode + Objects.hashCode(status());
hashCode = 31 * hashCode + Objects.hashCode(instanceFleetTypeAsString());
hashCode = 31 * hashCode + Objects.hashCode(targetOnDemandCapacity());
hashCode = 31 * hashCode + Objects.hashCode(targetSpotCapacity());
hashCode = 31 * hashCode + Objects.hashCode(provisionedOnDemandCapacity());
hashCode = 31 * hashCode + Objects.hashCode(provisionedSpotCapacity());
hashCode = 31 * hashCode + Objects.hashCode(hasInstanceTypeSpecifications() ? instanceTypeSpecifications() : null);
hashCode = 31 * hashCode + Objects.hashCode(launchSpecifications());
hashCode = 31 * hashCode + Objects.hashCode(resizeSpecifications());
hashCode = 31 * hashCode + Objects.hashCode(context());
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 InstanceFleet)) {
return false;
}
InstanceFleet other = (InstanceFleet) obj;
return Objects.equals(id(), other.id()) && Objects.equals(name(), other.name())
&& Objects.equals(status(), other.status())
&& Objects.equals(instanceFleetTypeAsString(), other.instanceFleetTypeAsString())
&& Objects.equals(targetOnDemandCapacity(), other.targetOnDemandCapacity())
&& Objects.equals(targetSpotCapacity(), other.targetSpotCapacity())
&& Objects.equals(provisionedOnDemandCapacity(), other.provisionedOnDemandCapacity())
&& Objects.equals(provisionedSpotCapacity(), other.provisionedSpotCapacity())
&& hasInstanceTypeSpecifications() == other.hasInstanceTypeSpecifications()
&& Objects.equals(instanceTypeSpecifications(), other.instanceTypeSpecifications())
&& Objects.equals(launchSpecifications(), other.launchSpecifications())
&& Objects.equals(resizeSpecifications(), other.resizeSpecifications())
&& Objects.equals(context(), other.context());
}
/**
* 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("InstanceFleet").add("Id", id()).add("Name", name()).add("Status", status())
.add("InstanceFleetType", instanceFleetTypeAsString()).add("TargetOnDemandCapacity", targetOnDemandCapacity())
.add("TargetSpotCapacity", targetSpotCapacity())
.add("ProvisionedOnDemandCapacity", provisionedOnDemandCapacity())
.add("ProvisionedSpotCapacity", provisionedSpotCapacity())
.add("InstanceTypeSpecifications", hasInstanceTypeSpecifications() ? instanceTypeSpecifications() : null)
.add("LaunchSpecifications", launchSpecifications()).add("ResizeSpecifications", resizeSpecifications())
.add("Context", context()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Id":
return Optional.ofNullable(clazz.cast(id()));
case "Name":
return Optional.ofNullable(clazz.cast(name()));
case "Status":
return Optional.ofNullable(clazz.cast(status()));
case "InstanceFleetType":
return Optional.ofNullable(clazz.cast(instanceFleetTypeAsString()));
case "TargetOnDemandCapacity":
return Optional.ofNullable(clazz.cast(targetOnDemandCapacity()));
case "TargetSpotCapacity":
return Optional.ofNullable(clazz.cast(targetSpotCapacity()));
case "ProvisionedOnDemandCapacity":
return Optional.ofNullable(clazz.cast(provisionedOnDemandCapacity()));
case "ProvisionedSpotCapacity":
return Optional.ofNullable(clazz.cast(provisionedSpotCapacity()));
case "InstanceTypeSpecifications":
return Optional.ofNullable(clazz.cast(instanceTypeSpecifications()));
case "LaunchSpecifications":
return Optional.ofNullable(clazz.cast(launchSpecifications()));
case "ResizeSpecifications":
return Optional.ofNullable(clazz.cast(resizeSpecifications()));
case "Context":
return Optional.ofNullable(clazz.cast(context()));
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