software.amazon.awssdk.services.emr.model.StepConfig Maven / Gradle / Ivy
Show all versions of emr 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.emr.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;
/**
*
* Specification for a cluster (job flow) step.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class StepConfig implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField NAME_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Name")
.getter(getter(StepConfig::name)).setter(setter(Builder::name))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Name").build()).build();
private static final SdkField ACTION_ON_FAILURE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ActionOnFailure").getter(getter(StepConfig::actionOnFailureAsString))
.setter(setter(Builder::actionOnFailure))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ActionOnFailure").build()).build();
private static final SdkField HADOOP_JAR_STEP_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("HadoopJarStep")
.getter(getter(StepConfig::hadoopJarStep)).setter(setter(Builder::hadoopJarStep))
.constructor(HadoopJarStepConfig::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("HadoopJarStep").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(NAME_FIELD,
ACTION_ON_FAILURE_FIELD, HADOOP_JAR_STEP_FIELD));
private static final long serialVersionUID = 1L;
private final String name;
private final String actionOnFailure;
private final HadoopJarStepConfig hadoopJarStep;
private StepConfig(BuilderImpl builder) {
this.name = builder.name;
this.actionOnFailure = builder.actionOnFailure;
this.hadoopJarStep = builder.hadoopJarStep;
}
/**
*
* The name of the step.
*
*
* @return The name of the step.
*/
public final String name() {
return name;
}
/**
*
* The action to take when the step fails. Use one of the following values:
*
*
* -
*
* TERMINATE_CLUSTER
- Shuts down the cluster.
*
*
* -
*
* CANCEL_AND_WAIT
- Cancels any pending steps and returns the cluster to the WAITING
* state.
*
*
* -
*
* CONTINUE
- Continues to the next step in the queue.
*
*
* -
*
* TERMINATE_JOB_FLOW
- Shuts down the cluster. TERMINATE_JOB_FLOW
is provided for
* backward compatibility. We recommend using TERMINATE_CLUSTER
instead.
*
*
*
*
* If a cluster's StepConcurrencyLevel
is greater than 1
, do not use
* AddJobFlowSteps
to submit a step with this parameter set to CANCEL_AND_WAIT
or
* TERMINATE_CLUSTER
. The step is not submitted and the action fails with a message that the
* ActionOnFailure
setting is not valid.
*
*
* If you change a cluster's StepConcurrencyLevel
to be greater than 1 while a step is running, the
* ActionOnFailure
parameter may not behave as you expect. In this case, for a step that fails with
* this parameter set to CANCEL_AND_WAIT
, pending steps and the running step are not canceled; for a
* step that fails with this parameter set to TERMINATE_CLUSTER
, the cluster does not terminate.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #actionOnFailure}
* will return {@link ActionOnFailure#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #actionOnFailureAsString}.
*
*
* @return The action to take when the step fails. Use one of the following values:
*
* -
*
* TERMINATE_CLUSTER
- Shuts down the cluster.
*
*
* -
*
* CANCEL_AND_WAIT
- Cancels any pending steps and returns the cluster to the
* WAITING
state.
*
*
* -
*
* CONTINUE
- Continues to the next step in the queue.
*
*
* -
*
* TERMINATE_JOB_FLOW
- Shuts down the cluster. TERMINATE_JOB_FLOW
is provided for
* backward compatibility. We recommend using TERMINATE_CLUSTER
instead.
*
*
*
*
* If a cluster's StepConcurrencyLevel
is greater than 1
, do not use
* AddJobFlowSteps
to submit a step with this parameter set to CANCEL_AND_WAIT
or
* TERMINATE_CLUSTER
. The step is not submitted and the action fails with a message that the
* ActionOnFailure
setting is not valid.
*
*
* If you change a cluster's StepConcurrencyLevel
to be greater than 1 while a step is running,
* the ActionOnFailure
parameter may not behave as you expect. In this case, for a step that
* fails with this parameter set to CANCEL_AND_WAIT
, pending steps and the running step are not
* canceled; for a step that fails with this parameter set to TERMINATE_CLUSTER
, the cluster
* does not terminate.
* @see ActionOnFailure
*/
public final ActionOnFailure actionOnFailure() {
return ActionOnFailure.fromValue(actionOnFailure);
}
/**
*
* The action to take when the step fails. Use one of the following values:
*
*
* -
*
* TERMINATE_CLUSTER
- Shuts down the cluster.
*
*
* -
*
* CANCEL_AND_WAIT
- Cancels any pending steps and returns the cluster to the WAITING
* state.
*
*
* -
*
* CONTINUE
- Continues to the next step in the queue.
*
*
* -
*
* TERMINATE_JOB_FLOW
- Shuts down the cluster. TERMINATE_JOB_FLOW
is provided for
* backward compatibility. We recommend using TERMINATE_CLUSTER
instead.
*
*
*
*
* If a cluster's StepConcurrencyLevel
is greater than 1
, do not use
* AddJobFlowSteps
to submit a step with this parameter set to CANCEL_AND_WAIT
or
* TERMINATE_CLUSTER
. The step is not submitted and the action fails with a message that the
* ActionOnFailure
setting is not valid.
*
*
* If you change a cluster's StepConcurrencyLevel
to be greater than 1 while a step is running, the
* ActionOnFailure
parameter may not behave as you expect. In this case, for a step that fails with
* this parameter set to CANCEL_AND_WAIT
, pending steps and the running step are not canceled; for a
* step that fails with this parameter set to TERMINATE_CLUSTER
, the cluster does not terminate.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #actionOnFailure}
* will return {@link ActionOnFailure#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #actionOnFailureAsString}.
*
*
* @return The action to take when the step fails. Use one of the following values:
*
* -
*
* TERMINATE_CLUSTER
- Shuts down the cluster.
*
*
* -
*
* CANCEL_AND_WAIT
- Cancels any pending steps and returns the cluster to the
* WAITING
state.
*
*
* -
*
* CONTINUE
- Continues to the next step in the queue.
*
*
* -
*
* TERMINATE_JOB_FLOW
- Shuts down the cluster. TERMINATE_JOB_FLOW
is provided for
* backward compatibility. We recommend using TERMINATE_CLUSTER
instead.
*
*
*
*
* If a cluster's StepConcurrencyLevel
is greater than 1
, do not use
* AddJobFlowSteps
to submit a step with this parameter set to CANCEL_AND_WAIT
or
* TERMINATE_CLUSTER
. The step is not submitted and the action fails with a message that the
* ActionOnFailure
setting is not valid.
*
*
* If you change a cluster's StepConcurrencyLevel
to be greater than 1 while a step is running,
* the ActionOnFailure
parameter may not behave as you expect. In this case, for a step that
* fails with this parameter set to CANCEL_AND_WAIT
, pending steps and the running step are not
* canceled; for a step that fails with this parameter set to TERMINATE_CLUSTER
, the cluster
* does not terminate.
* @see ActionOnFailure
*/
public final String actionOnFailureAsString() {
return actionOnFailure;
}
/**
*
* The JAR file used for the step.
*
*
* @return The JAR file used for the step.
*/
public final HadoopJarStepConfig hadoopJarStep() {
return hadoopJarStep;
}
@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(actionOnFailureAsString());
hashCode = 31 * hashCode + Objects.hashCode(hadoopJarStep());
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 StepConfig)) {
return false;
}
StepConfig other = (StepConfig) obj;
return Objects.equals(name(), other.name()) && Objects.equals(actionOnFailureAsString(), other.actionOnFailureAsString())
&& Objects.equals(hadoopJarStep(), other.hadoopJarStep());
}
/**
* 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("StepConfig").add("Name", name()).add("ActionOnFailure", actionOnFailureAsString())
.add("HadoopJarStep", hadoopJarStep()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Name":
return Optional.ofNullable(clazz.cast(name()));
case "ActionOnFailure":
return Optional.ofNullable(clazz.cast(actionOnFailureAsString()));
case "HadoopJarStep":
return Optional.ofNullable(clazz.cast(hadoopJarStep()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function