software.amazon.awssdk.services.athena.model.QueryExecutionStatus Maven / Gradle / Ivy
Show all versions of athena 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.athena.model;
import java.beans.Transient;
import java.io.Serializable;
import java.time.Instant;
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;
/**
*
* The completion date, current state, submission time, and state change reason (if applicable) for the query execution.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class QueryExecutionStatus implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField STATE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("State")
.getter(getter(QueryExecutionStatus::stateAsString)).setter(setter(Builder::state))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("State").build()).build();
private static final SdkField STATE_CHANGE_REASON_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("StateChangeReason").getter(getter(QueryExecutionStatus::stateChangeReason))
.setter(setter(Builder::stateChangeReason))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StateChangeReason").build()).build();
private static final SdkField SUBMISSION_DATE_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("SubmissionDateTime").getter(getter(QueryExecutionStatus::submissionDateTime))
.setter(setter(Builder::submissionDateTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SubmissionDateTime").build())
.build();
private static final SdkField COMPLETION_DATE_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("CompletionDateTime").getter(getter(QueryExecutionStatus::completionDateTime))
.setter(setter(Builder::completionDateTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CompletionDateTime").build())
.build();
private static final SdkField ATHENA_ERROR_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("AthenaError").getter(getter(QueryExecutionStatus::athenaError)).setter(setter(Builder::athenaError))
.constructor(AthenaError::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AthenaError").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(STATE_FIELD,
STATE_CHANGE_REASON_FIELD, SUBMISSION_DATE_TIME_FIELD, COMPLETION_DATE_TIME_FIELD, ATHENA_ERROR_FIELD));
private static final long serialVersionUID = 1L;
private final String state;
private final String stateChangeReason;
private final Instant submissionDateTime;
private final Instant completionDateTime;
private final AthenaError athenaError;
private QueryExecutionStatus(BuilderImpl builder) {
this.state = builder.state;
this.stateChangeReason = builder.stateChangeReason;
this.submissionDateTime = builder.submissionDateTime;
this.completionDateTime = builder.completionDateTime;
this.athenaError = builder.athenaError;
}
/**
*
* The state of query execution. QUEUED
indicates that the query has been submitted to the service, and
* Athena will execute the query as soon as resources are available. RUNNING
indicates that the query
* is in execution phase. SUCCEEDED
indicates that the query completed without errors.
* FAILED
indicates that the query experienced an error and did not complete processing.
* CANCELLED
indicates that a user input interrupted query execution.
*
*
*
* Athena automatically retries your queries in cases of certain transient errors. As a result, you may see the
* query state transition from RUNNING
or FAILED
to QUEUED
.
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #state} will return
* {@link QueryExecutionState#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #stateAsString}.
*
*
* @return The state of query execution. QUEUED
indicates that the query has been submitted to the
* service, and Athena will execute the query as soon as resources are available. RUNNING
* indicates that the query is in execution phase. SUCCEEDED
indicates that the query completed
* without errors. FAILED
indicates that the query experienced an error and did not complete
* processing. CANCELLED
indicates that a user input interrupted query execution.
*
* Athena automatically retries your queries in cases of certain transient errors. As a result, you may see
* the query state transition from RUNNING
or FAILED
to QUEUED
.
*
* @see QueryExecutionState
*/
public final QueryExecutionState state() {
return QueryExecutionState.fromValue(state);
}
/**
*
* The state of query execution. QUEUED
indicates that the query has been submitted to the service, and
* Athena will execute the query as soon as resources are available. RUNNING
indicates that the query
* is in execution phase. SUCCEEDED
indicates that the query completed without errors.
* FAILED
indicates that the query experienced an error and did not complete processing.
* CANCELLED
indicates that a user input interrupted query execution.
*
*
*
* Athena automatically retries your queries in cases of certain transient errors. As a result, you may see the
* query state transition from RUNNING
or FAILED
to QUEUED
.
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #state} will return
* {@link QueryExecutionState#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #stateAsString}.
*
*
* @return The state of query execution. QUEUED
indicates that the query has been submitted to the
* service, and Athena will execute the query as soon as resources are available. RUNNING
* indicates that the query is in execution phase. SUCCEEDED
indicates that the query completed
* without errors. FAILED
indicates that the query experienced an error and did not complete
* processing. CANCELLED
indicates that a user input interrupted query execution.
*
* Athena automatically retries your queries in cases of certain transient errors. As a result, you may see
* the query state transition from RUNNING
or FAILED
to QUEUED
.
*
* @see QueryExecutionState
*/
public final String stateAsString() {
return state;
}
/**
*
* Further detail about the status of the query.
*
*
* @return Further detail about the status of the query.
*/
public final String stateChangeReason() {
return stateChangeReason;
}
/**
*
* The date and time that the query was submitted.
*
*
* @return The date and time that the query was submitted.
*/
public final Instant submissionDateTime() {
return submissionDateTime;
}
/**
*
* The date and time that the query completed.
*
*
* @return The date and time that the query completed.
*/
public final Instant completionDateTime() {
return completionDateTime;
}
/**
*
* Provides information about an Athena query error.
*
*
* @return Provides information about an Athena query error.
*/
public final AthenaError athenaError() {
return athenaError;
}
@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(stateAsString());
hashCode = 31 * hashCode + Objects.hashCode(stateChangeReason());
hashCode = 31 * hashCode + Objects.hashCode(submissionDateTime());
hashCode = 31 * hashCode + Objects.hashCode(completionDateTime());
hashCode = 31 * hashCode + Objects.hashCode(athenaError());
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 QueryExecutionStatus)) {
return false;
}
QueryExecutionStatus other = (QueryExecutionStatus) obj;
return Objects.equals(stateAsString(), other.stateAsString())
&& Objects.equals(stateChangeReason(), other.stateChangeReason())
&& Objects.equals(submissionDateTime(), other.submissionDateTime())
&& Objects.equals(completionDateTime(), other.completionDateTime())
&& Objects.equals(athenaError(), other.athenaError());
}
/**
* 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("QueryExecutionStatus").add("State", stateAsString())
.add("StateChangeReason", stateChangeReason()).add("SubmissionDateTime", submissionDateTime())
.add("CompletionDateTime", completionDateTime()).add("AthenaError", athenaError()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "State":
return Optional.ofNullable(clazz.cast(stateAsString()));
case "StateChangeReason":
return Optional.ofNullable(clazz.cast(stateChangeReason()));
case "SubmissionDateTime":
return Optional.ofNullable(clazz.cast(submissionDateTime()));
case "CompletionDateTime":
return Optional.ofNullable(clazz.cast(completionDateTime()));
case "AthenaError":
return Optional.ofNullable(clazz.cast(athenaError()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function