software.amazon.awssdk.services.sagemaker.model.ClusterInstanceGroupSpecification Maven / Gradle / Ivy
Show all versions of sagemaker 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.sagemaker.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;
/**
*
* The specifications of an instance group that you need to define.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class ClusterInstanceGroupSpecification implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField INSTANCE_COUNT_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("InstanceCount").getter(getter(ClusterInstanceGroupSpecification::instanceCount))
.setter(setter(Builder::instanceCount))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("InstanceCount").build()).build();
private static final SdkField INSTANCE_GROUP_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("InstanceGroupName").getter(getter(ClusterInstanceGroupSpecification::instanceGroupName))
.setter(setter(Builder::instanceGroupName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("InstanceGroupName").build()).build();
private static final SdkField INSTANCE_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("InstanceType").getter(getter(ClusterInstanceGroupSpecification::instanceTypeAsString))
.setter(setter(Builder::instanceType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("InstanceType").build()).build();
private static final SdkField LIFE_CYCLE_CONFIG_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("LifeCycleConfig")
.getter(getter(ClusterInstanceGroupSpecification::lifeCycleConfig)).setter(setter(Builder::lifeCycleConfig))
.constructor(ClusterLifeCycleConfig::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LifeCycleConfig").build()).build();
private static final SdkField EXECUTION_ROLE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ExecutionRole").getter(getter(ClusterInstanceGroupSpecification::executionRole))
.setter(setter(Builder::executionRole))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ExecutionRole").build()).build();
private static final SdkField THREADS_PER_CORE_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("ThreadsPerCore").getter(getter(ClusterInstanceGroupSpecification::threadsPerCore))
.setter(setter(Builder::threadsPerCore))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ThreadsPerCore").build()).build();
private static final SdkField> INSTANCE_STORAGE_CONFIGS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("InstanceStorageConfigs")
.getter(getter(ClusterInstanceGroupSpecification::instanceStorageConfigs))
.setter(setter(Builder::instanceStorageConfigs))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("InstanceStorageConfigs").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(ClusterInstanceStorageConfig::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField> ON_START_DEEP_HEALTH_CHECKS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("OnStartDeepHealthChecks")
.getter(getter(ClusterInstanceGroupSpecification::onStartDeepHealthChecksAsStrings))
.setter(setter(Builder::onStartDeepHealthChecksWithStrings))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("OnStartDeepHealthChecks").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.STRING)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField TRAINING_PLAN_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("TrainingPlanArn").getter(getter(ClusterInstanceGroupSpecification::trainingPlanArn))
.setter(setter(Builder::trainingPlanArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TrainingPlanArn").build()).build();
private static final SdkField OVERRIDE_VPC_CONFIG_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("OverrideVpcConfig").getter(getter(ClusterInstanceGroupSpecification::overrideVpcConfig))
.setter(setter(Builder::overrideVpcConfig)).constructor(VpcConfig::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("OverrideVpcConfig").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(INSTANCE_COUNT_FIELD,
INSTANCE_GROUP_NAME_FIELD, INSTANCE_TYPE_FIELD, LIFE_CYCLE_CONFIG_FIELD, EXECUTION_ROLE_FIELD,
THREADS_PER_CORE_FIELD, INSTANCE_STORAGE_CONFIGS_FIELD, ON_START_DEEP_HEALTH_CHECKS_FIELD, TRAINING_PLAN_ARN_FIELD,
OVERRIDE_VPC_CONFIG_FIELD));
private static final Map> SDK_NAME_TO_FIELD = memberNameToFieldInitializer();
private static final long serialVersionUID = 1L;
private final Integer instanceCount;
private final String instanceGroupName;
private final String instanceType;
private final ClusterLifeCycleConfig lifeCycleConfig;
private final String executionRole;
private final Integer threadsPerCore;
private final List instanceStorageConfigs;
private final List onStartDeepHealthChecks;
private final String trainingPlanArn;
private final VpcConfig overrideVpcConfig;
private ClusterInstanceGroupSpecification(BuilderImpl builder) {
this.instanceCount = builder.instanceCount;
this.instanceGroupName = builder.instanceGroupName;
this.instanceType = builder.instanceType;
this.lifeCycleConfig = builder.lifeCycleConfig;
this.executionRole = builder.executionRole;
this.threadsPerCore = builder.threadsPerCore;
this.instanceStorageConfigs = builder.instanceStorageConfigs;
this.onStartDeepHealthChecks = builder.onStartDeepHealthChecks;
this.trainingPlanArn = builder.trainingPlanArn;
this.overrideVpcConfig = builder.overrideVpcConfig;
}
/**
*
* Specifies the number of instances to add to the instance group of a SageMaker HyperPod cluster.
*
*
* @return Specifies the number of instances to add to the instance group of a SageMaker HyperPod cluster.
*/
public final Integer instanceCount() {
return instanceCount;
}
/**
*
* Specifies the name of the instance group.
*
*
* @return Specifies the name of the instance group.
*/
public final String instanceGroupName() {
return instanceGroupName;
}
/**
*
* Specifies the instance type of the instance group.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #instanceType} will
* return {@link ClusterInstanceType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #instanceTypeAsString}.
*
*
* @return Specifies the instance type of the instance group.
* @see ClusterInstanceType
*/
public final ClusterInstanceType instanceType() {
return ClusterInstanceType.fromValue(instanceType);
}
/**
*
* Specifies the instance type of the instance group.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #instanceType} will
* return {@link ClusterInstanceType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #instanceTypeAsString}.
*
*
* @return Specifies the instance type of the instance group.
* @see ClusterInstanceType
*/
public final String instanceTypeAsString() {
return instanceType;
}
/**
*
* Specifies the LifeCycle configuration for the instance group.
*
*
* @return Specifies the LifeCycle configuration for the instance group.
*/
public final ClusterLifeCycleConfig lifeCycleConfig() {
return lifeCycleConfig;
}
/**
*
* Specifies an IAM execution role to be assumed by the instance group.
*
*
* @return Specifies an IAM execution role to be assumed by the instance group.
*/
public final String executionRole() {
return executionRole;
}
/**
*
* Specifies the value for Threads per core. For instance types that support multithreading, you can specify
* 1
for disabling multithreading and 2
for enabling multithreading. For instance types
* that doesn't support multithreading, specify 1
. For more information, see the reference table of CPU cores
* and threads per CPU core per instance type in the Amazon Elastic Compute Cloud User Guide.
*
*
* @return Specifies the value for Threads per core. For instance types that support multithreading, you can
* specify 1
for disabling multithreading and 2
for enabling multithreading. For
* instance types that doesn't support multithreading, specify 1
. For more information, see the
* reference table of CPU cores and threads per CPU core per instance type in the Amazon Elastic Compute Cloud User
* Guide.
*/
public final Integer threadsPerCore() {
return threadsPerCore;
}
/**
* For responses, this returns true if the service returned a value for the InstanceStorageConfigs 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 hasInstanceStorageConfigs() {
return instanceStorageConfigs != null && !(instanceStorageConfigs instanceof SdkAutoConstructList);
}
/**
*
* Specifies the additional storage configurations for the instances in the SageMaker HyperPod cluster instance
* group.
*
*
* 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 #hasInstanceStorageConfigs} method.
*
*
* @return Specifies the additional storage configurations for the instances in the SageMaker HyperPod cluster
* instance group.
*/
public final List instanceStorageConfigs() {
return instanceStorageConfigs;
}
/**
*
* A flag indicating whether deep health checks should be performed when the cluster instance group is created or
* updated.
*
*
* 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 #hasOnStartDeepHealthChecks} method.
*
*
* @return A flag indicating whether deep health checks should be performed when the cluster instance group is
* created or updated.
*/
public final List onStartDeepHealthChecks() {
return OnStartDeepHealthChecksCopier.copyStringToEnum(onStartDeepHealthChecks);
}
/**
* For responses, this returns true if the service returned a value for the OnStartDeepHealthChecks 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 hasOnStartDeepHealthChecks() {
return onStartDeepHealthChecks != null && !(onStartDeepHealthChecks instanceof SdkAutoConstructList);
}
/**
*
* A flag indicating whether deep health checks should be performed when the cluster instance group is created or
* updated.
*
*
* 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 #hasOnStartDeepHealthChecks} method.
*
*
* @return A flag indicating whether deep health checks should be performed when the cluster instance group is
* created or updated.
*/
public final List onStartDeepHealthChecksAsStrings() {
return onStartDeepHealthChecks;
}
/**
*
* The Amazon Resource Name (ARN); of the training plan to use for this cluster instance group.
*
*
* For more information about how to reserve GPU capacity for your SageMaker HyperPod clusters using Amazon
* SageMaker Training Plan, see
* CreateTrainingPlan
* .
*
*
* @return The Amazon Resource Name (ARN); of the training plan to use for this cluster instance group.
*
* For more information about how to reserve GPU capacity for your SageMaker HyperPod clusters using Amazon
* SageMaker Training Plan, see
* CreateTrainingPlan
.
*/
public final String trainingPlanArn() {
return trainingPlanArn;
}
/**
* Returns the value of the OverrideVpcConfig property for this object.
*
* @return The value of the OverrideVpcConfig property for this object.
*/
public final VpcConfig overrideVpcConfig() {
return overrideVpcConfig;
}
@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(instanceCount());
hashCode = 31 * hashCode + Objects.hashCode(instanceGroupName());
hashCode = 31 * hashCode + Objects.hashCode(instanceTypeAsString());
hashCode = 31 * hashCode + Objects.hashCode(lifeCycleConfig());
hashCode = 31 * hashCode + Objects.hashCode(executionRole());
hashCode = 31 * hashCode + Objects.hashCode(threadsPerCore());
hashCode = 31 * hashCode + Objects.hashCode(hasInstanceStorageConfigs() ? instanceStorageConfigs() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasOnStartDeepHealthChecks() ? onStartDeepHealthChecksAsStrings() : null);
hashCode = 31 * hashCode + Objects.hashCode(trainingPlanArn());
hashCode = 31 * hashCode + Objects.hashCode(overrideVpcConfig());
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 ClusterInstanceGroupSpecification)) {
return false;
}
ClusterInstanceGroupSpecification other = (ClusterInstanceGroupSpecification) obj;
return Objects.equals(instanceCount(), other.instanceCount())
&& Objects.equals(instanceGroupName(), other.instanceGroupName())
&& Objects.equals(instanceTypeAsString(), other.instanceTypeAsString())
&& Objects.equals(lifeCycleConfig(), other.lifeCycleConfig())
&& Objects.equals(executionRole(), other.executionRole())
&& Objects.equals(threadsPerCore(), other.threadsPerCore())
&& hasInstanceStorageConfigs() == other.hasInstanceStorageConfigs()
&& Objects.equals(instanceStorageConfigs(), other.instanceStorageConfigs())
&& hasOnStartDeepHealthChecks() == other.hasOnStartDeepHealthChecks()
&& Objects.equals(onStartDeepHealthChecksAsStrings(), other.onStartDeepHealthChecksAsStrings())
&& Objects.equals(trainingPlanArn(), other.trainingPlanArn())
&& Objects.equals(overrideVpcConfig(), other.overrideVpcConfig());
}
/**
* 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("ClusterInstanceGroupSpecification").add("InstanceCount", instanceCount())
.add("InstanceGroupName", instanceGroupName()).add("InstanceType", instanceTypeAsString())
.add("LifeCycleConfig", lifeCycleConfig()).add("ExecutionRole", executionRole())
.add("ThreadsPerCore", threadsPerCore())
.add("InstanceStorageConfigs", hasInstanceStorageConfigs() ? instanceStorageConfigs() : null)
.add("OnStartDeepHealthChecks", hasOnStartDeepHealthChecks() ? onStartDeepHealthChecksAsStrings() : null)
.add("TrainingPlanArn", trainingPlanArn()).add("OverrideVpcConfig", overrideVpcConfig()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "InstanceCount":
return Optional.ofNullable(clazz.cast(instanceCount()));
case "InstanceGroupName":
return Optional.ofNullable(clazz.cast(instanceGroupName()));
case "InstanceType":
return Optional.ofNullable(clazz.cast(instanceTypeAsString()));
case "LifeCycleConfig":
return Optional.ofNullable(clazz.cast(lifeCycleConfig()));
case "ExecutionRole":
return Optional.ofNullable(clazz.cast(executionRole()));
case "ThreadsPerCore":
return Optional.ofNullable(clazz.cast(threadsPerCore()));
case "InstanceStorageConfigs":
return Optional.ofNullable(clazz.cast(instanceStorageConfigs()));
case "OnStartDeepHealthChecks":
return Optional.ofNullable(clazz.cast(onStartDeepHealthChecksAsStrings()));
case "TrainingPlanArn":
return Optional.ofNullable(clazz.cast(trainingPlanArn()));
case "OverrideVpcConfig":
return Optional.ofNullable(clazz.cast(overrideVpcConfig()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
@Override
public final Map> sdkFieldNameToField() {
return SDK_NAME_TO_FIELD;
}
private static Map> memberNameToFieldInitializer() {
Map> map = new HashMap<>();
map.put("InstanceCount", INSTANCE_COUNT_FIELD);
map.put("InstanceGroupName", INSTANCE_GROUP_NAME_FIELD);
map.put("InstanceType", INSTANCE_TYPE_FIELD);
map.put("LifeCycleConfig", LIFE_CYCLE_CONFIG_FIELD);
map.put("ExecutionRole", EXECUTION_ROLE_FIELD);
map.put("ThreadsPerCore", THREADS_PER_CORE_FIELD);
map.put("InstanceStorageConfigs", INSTANCE_STORAGE_CONFIGS_FIELD);
map.put("OnStartDeepHealthChecks", ON_START_DEEP_HEALTH_CHECKS_FIELD);
map.put("TrainingPlanArn", TRAINING_PLAN_ARN_FIELD);
map.put("OverrideVpcConfig", OVERRIDE_VPC_CONFIG_FIELD);
return Collections.unmodifiableMap(map);
}
private static Function