software.amazon.awssdk.services.emrserverless.DefaultEmrServerlessClient Maven / Gradle / Ivy
Show all versions of emrserverless 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.emrserverless;
import java.util.Collections;
import java.util.List;
import java.util.function.Consumer;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.awscore.client.handler.AwsSyncClientHandler;
import software.amazon.awssdk.awscore.exception.AwsServiceException;
import software.amazon.awssdk.awscore.internal.AwsProtocolMetadata;
import software.amazon.awssdk.awscore.internal.AwsServiceProtocol;
import software.amazon.awssdk.awscore.retry.AwsRetryStrategy;
import software.amazon.awssdk.core.RequestOverrideConfiguration;
import software.amazon.awssdk.core.SdkPlugin;
import software.amazon.awssdk.core.SdkRequest;
import software.amazon.awssdk.core.client.config.ClientOverrideConfiguration;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
import software.amazon.awssdk.core.client.config.SdkClientOption;
import software.amazon.awssdk.core.client.handler.ClientExecutionParams;
import software.amazon.awssdk.core.client.handler.SyncClientHandler;
import software.amazon.awssdk.core.exception.SdkClientException;
import software.amazon.awssdk.core.http.HttpResponseHandler;
import software.amazon.awssdk.core.metrics.CoreMetric;
import software.amazon.awssdk.core.retry.RetryMode;
import software.amazon.awssdk.metrics.MetricCollector;
import software.amazon.awssdk.metrics.MetricPublisher;
import software.amazon.awssdk.metrics.NoOpMetricCollector;
import software.amazon.awssdk.protocols.core.ExceptionMetadata;
import software.amazon.awssdk.protocols.json.AwsJsonProtocol;
import software.amazon.awssdk.protocols.json.AwsJsonProtocolFactory;
import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory;
import software.amazon.awssdk.protocols.json.JsonOperationMetadata;
import software.amazon.awssdk.retries.api.RetryStrategy;
import software.amazon.awssdk.services.emrserverless.internal.EmrServerlessServiceClientConfigurationBuilder;
import software.amazon.awssdk.services.emrserverless.model.CancelJobRunRequest;
import software.amazon.awssdk.services.emrserverless.model.CancelJobRunResponse;
import software.amazon.awssdk.services.emrserverless.model.ConflictException;
import software.amazon.awssdk.services.emrserverless.model.CreateApplicationRequest;
import software.amazon.awssdk.services.emrserverless.model.CreateApplicationResponse;
import software.amazon.awssdk.services.emrserverless.model.DeleteApplicationRequest;
import software.amazon.awssdk.services.emrserverless.model.DeleteApplicationResponse;
import software.amazon.awssdk.services.emrserverless.model.EmrServerlessException;
import software.amazon.awssdk.services.emrserverless.model.GetApplicationRequest;
import software.amazon.awssdk.services.emrserverless.model.GetApplicationResponse;
import software.amazon.awssdk.services.emrserverless.model.GetDashboardForJobRunRequest;
import software.amazon.awssdk.services.emrserverless.model.GetDashboardForJobRunResponse;
import software.amazon.awssdk.services.emrserverless.model.GetJobRunRequest;
import software.amazon.awssdk.services.emrserverless.model.GetJobRunResponse;
import software.amazon.awssdk.services.emrserverless.model.InternalServerException;
import software.amazon.awssdk.services.emrserverless.model.ListApplicationsRequest;
import software.amazon.awssdk.services.emrserverless.model.ListApplicationsResponse;
import software.amazon.awssdk.services.emrserverless.model.ListJobRunAttemptsRequest;
import software.amazon.awssdk.services.emrserverless.model.ListJobRunAttemptsResponse;
import software.amazon.awssdk.services.emrserverless.model.ListJobRunsRequest;
import software.amazon.awssdk.services.emrserverless.model.ListJobRunsResponse;
import software.amazon.awssdk.services.emrserverless.model.ListTagsForResourceRequest;
import software.amazon.awssdk.services.emrserverless.model.ListTagsForResourceResponse;
import software.amazon.awssdk.services.emrserverless.model.ResourceNotFoundException;
import software.amazon.awssdk.services.emrserverless.model.ServiceQuotaExceededException;
import software.amazon.awssdk.services.emrserverless.model.StartApplicationRequest;
import software.amazon.awssdk.services.emrserverless.model.StartApplicationResponse;
import software.amazon.awssdk.services.emrserverless.model.StartJobRunRequest;
import software.amazon.awssdk.services.emrserverless.model.StartJobRunResponse;
import software.amazon.awssdk.services.emrserverless.model.StopApplicationRequest;
import software.amazon.awssdk.services.emrserverless.model.StopApplicationResponse;
import software.amazon.awssdk.services.emrserverless.model.TagResourceRequest;
import software.amazon.awssdk.services.emrserverless.model.TagResourceResponse;
import software.amazon.awssdk.services.emrserverless.model.UntagResourceRequest;
import software.amazon.awssdk.services.emrserverless.model.UntagResourceResponse;
import software.amazon.awssdk.services.emrserverless.model.UpdateApplicationRequest;
import software.amazon.awssdk.services.emrserverless.model.UpdateApplicationResponse;
import software.amazon.awssdk.services.emrserverless.model.ValidationException;
import software.amazon.awssdk.services.emrserverless.transform.CancelJobRunRequestMarshaller;
import software.amazon.awssdk.services.emrserverless.transform.CreateApplicationRequestMarshaller;
import software.amazon.awssdk.services.emrserverless.transform.DeleteApplicationRequestMarshaller;
import software.amazon.awssdk.services.emrserverless.transform.GetApplicationRequestMarshaller;
import software.amazon.awssdk.services.emrserverless.transform.GetDashboardForJobRunRequestMarshaller;
import software.amazon.awssdk.services.emrserverless.transform.GetJobRunRequestMarshaller;
import software.amazon.awssdk.services.emrserverless.transform.ListApplicationsRequestMarshaller;
import software.amazon.awssdk.services.emrserverless.transform.ListJobRunAttemptsRequestMarshaller;
import software.amazon.awssdk.services.emrserverless.transform.ListJobRunsRequestMarshaller;
import software.amazon.awssdk.services.emrserverless.transform.ListTagsForResourceRequestMarshaller;
import software.amazon.awssdk.services.emrserverless.transform.StartApplicationRequestMarshaller;
import software.amazon.awssdk.services.emrserverless.transform.StartJobRunRequestMarshaller;
import software.amazon.awssdk.services.emrserverless.transform.StopApplicationRequestMarshaller;
import software.amazon.awssdk.services.emrserverless.transform.TagResourceRequestMarshaller;
import software.amazon.awssdk.services.emrserverless.transform.UntagResourceRequestMarshaller;
import software.amazon.awssdk.services.emrserverless.transform.UpdateApplicationRequestMarshaller;
import software.amazon.awssdk.utils.Logger;
/**
* Internal implementation of {@link EmrServerlessClient}.
*
* @see EmrServerlessClient#builder()
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
final class DefaultEmrServerlessClient implements EmrServerlessClient {
private static final Logger log = Logger.loggerFor(DefaultEmrServerlessClient.class);
private static final AwsProtocolMetadata protocolMetadata = AwsProtocolMetadata.builder()
.serviceProtocol(AwsServiceProtocol.REST_JSON).build();
private final SyncClientHandler clientHandler;
private final AwsJsonProtocolFactory protocolFactory;
private final SdkClientConfiguration clientConfiguration;
protected DefaultEmrServerlessClient(SdkClientConfiguration clientConfiguration) {
this.clientHandler = new AwsSyncClientHandler(clientConfiguration);
this.clientConfiguration = clientConfiguration.toBuilder().option(SdkClientOption.SDK_CLIENT, this).build();
this.protocolFactory = init(AwsJsonProtocolFactory.builder()).build();
}
/**
*
* Cancels a job run.
*
*
* @param cancelJobRunRequest
* @return Result of the CancelJobRun operation returned by the service.
* @throws ValidationException
* The input fails to satisfy the constraints specified by an Amazon Web Services service.
* @throws ResourceNotFoundException
* The specified resource was not found.
* @throws InternalServerException
* Request processing failed because of an error or failure with the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws EmrServerlessException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample EmrServerlessClient.CancelJobRun
* @see AWS
* API Documentation
*/
@Override
public CancelJobRunResponse cancelJobRun(CancelJobRunRequest cancelJobRunRequest) throws ValidationException,
ResourceNotFoundException, InternalServerException, AwsServiceException, SdkClientException, EmrServerlessException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
CancelJobRunResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(cancelJobRunRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, cancelJobRunRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "EMR Serverless");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "CancelJobRun");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("CancelJobRun").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(cancelJobRunRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new CancelJobRunRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Creates an application.
*
*
* @param createApplicationRequest
* @return Result of the CreateApplication operation returned by the service.
* @throws ValidationException
* The input fails to satisfy the constraints specified by an Amazon Web Services service.
* @throws ResourceNotFoundException
* The specified resource was not found.
* @throws InternalServerException
* Request processing failed because of an error or failure with the service.
* @throws ConflictException
* The request could not be processed because of conflict in the current state of the resource.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws EmrServerlessException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample EmrServerlessClient.CreateApplication
* @see AWS API Documentation
*/
@Override
public CreateApplicationResponse createApplication(CreateApplicationRequest createApplicationRequest)
throws ValidationException, ResourceNotFoundException, InternalServerException, ConflictException,
AwsServiceException, SdkClientException, EmrServerlessException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
CreateApplicationResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(createApplicationRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, createApplicationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "EMR Serverless");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "CreateApplication");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("CreateApplication").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(createApplicationRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new CreateApplicationRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Deletes an application. An application has to be in a stopped or created state in order to be deleted.
*
*
* @param deleteApplicationRequest
* @return Result of the DeleteApplication operation returned by the service.
* @throws ValidationException
* The input fails to satisfy the constraints specified by an Amazon Web Services service.
* @throws ResourceNotFoundException
* The specified resource was not found.
* @throws InternalServerException
* Request processing failed because of an error or failure with the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws EmrServerlessException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample EmrServerlessClient.DeleteApplication
* @see AWS API Documentation
*/
@Override
public DeleteApplicationResponse deleteApplication(DeleteApplicationRequest deleteApplicationRequest)
throws ValidationException, ResourceNotFoundException, InternalServerException, AwsServiceException,
SdkClientException, EmrServerlessException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
DeleteApplicationResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(deleteApplicationRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, deleteApplicationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "EMR Serverless");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DeleteApplication");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("DeleteApplication").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(deleteApplicationRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new DeleteApplicationRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Displays detailed information about a specified application.
*
*
* @param getApplicationRequest
* @return Result of the GetApplication operation returned by the service.
* @throws ValidationException
* The input fails to satisfy the constraints specified by an Amazon Web Services service.
* @throws ResourceNotFoundException
* The specified resource was not found.
* @throws InternalServerException
* Request processing failed because of an error or failure with the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws EmrServerlessException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample EmrServerlessClient.GetApplication
* @see AWS
* API Documentation
*/
@Override
public GetApplicationResponse getApplication(GetApplicationRequest getApplicationRequest) throws ValidationException,
ResourceNotFoundException, InternalServerException, AwsServiceException, SdkClientException, EmrServerlessException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
GetApplicationResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getApplicationRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, getApplicationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "EMR Serverless");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetApplication");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("GetApplication").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(getApplicationRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new GetApplicationRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Creates and returns a URL that you can use to access the application UIs for a job run.
*
*
* For jobs in a running state, the application UI is a live user interface such as the Spark or Tez web UI. For
* completed jobs, the application UI is a persistent application user interface such as the Spark History Server or
* persistent Tez UI.
*
*
*
* The URL is valid for one hour after you generate it. To access the application UI after that hour elapses, you
* must invoke the API again to generate a new URL.
*
*
*
* @param getDashboardForJobRunRequest
* @return Result of the GetDashboardForJobRun operation returned by the service.
* @throws ValidationException
* The input fails to satisfy the constraints specified by an Amazon Web Services service.
* @throws ResourceNotFoundException
* The specified resource was not found.
* @throws InternalServerException
* Request processing failed because of an error or failure with the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws EmrServerlessException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample EmrServerlessClient.GetDashboardForJobRun
* @see AWS API Documentation
*/
@Override
public GetDashboardForJobRunResponse getDashboardForJobRun(GetDashboardForJobRunRequest getDashboardForJobRunRequest)
throws ValidationException, ResourceNotFoundException, InternalServerException, AwsServiceException,
SdkClientException, EmrServerlessException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GetDashboardForJobRunResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getDashboardForJobRunRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, getDashboardForJobRunRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "EMR Serverless");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetDashboardForJobRun");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("GetDashboardForJobRun").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(getDashboardForJobRunRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new GetDashboardForJobRunRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Displays detailed information about a job run.
*
*
* @param getJobRunRequest
* @return Result of the GetJobRun operation returned by the service.
* @throws ValidationException
* The input fails to satisfy the constraints specified by an Amazon Web Services service.
* @throws ResourceNotFoundException
* The specified resource was not found.
* @throws InternalServerException
* Request processing failed because of an error or failure with the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws EmrServerlessException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample EmrServerlessClient.GetJobRun
* @see AWS API
* Documentation
*/
@Override
public GetJobRunResponse getJobRun(GetJobRunRequest getJobRunRequest) throws ValidationException, ResourceNotFoundException,
InternalServerException, AwsServiceException, SdkClientException, EmrServerlessException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
GetJobRunResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getJobRunRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, getJobRunRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "EMR Serverless");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetJobRun");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("GetJobRun").withProtocolMetadata(protocolMetadata).withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration)
.withInput(getJobRunRequest).withMetricCollector(apiCallMetricCollector)
.withMarshaller(new GetJobRunRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Lists applications based on a set of parameters.
*
*
* @param listApplicationsRequest
* @return Result of the ListApplications operation returned by the service.
* @throws ValidationException
* The input fails to satisfy the constraints specified by an Amazon Web Services service.
* @throws InternalServerException
* Request processing failed because of an error or failure with the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws EmrServerlessException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample EmrServerlessClient.ListApplications
* @see AWS API Documentation
*/
@Override
public ListApplicationsResponse listApplications(ListApplicationsRequest listApplicationsRequest) throws ValidationException,
InternalServerException, AwsServiceException, SdkClientException, EmrServerlessException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
ListApplicationsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listApplicationsRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, listApplicationsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "EMR Serverless");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListApplications");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("ListApplications").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(listApplicationsRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new ListApplicationsRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Lists all attempt of a job run.
*
*
* @param listJobRunAttemptsRequest
* @return Result of the ListJobRunAttempts operation returned by the service.
* @throws ValidationException
* The input fails to satisfy the constraints specified by an Amazon Web Services service.
* @throws ResourceNotFoundException
* The specified resource was not found.
* @throws InternalServerException
* Request processing failed because of an error or failure with the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws EmrServerlessException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample EmrServerlessClient.ListJobRunAttempts
* @see AWS API Documentation
*/
@Override
public ListJobRunAttemptsResponse listJobRunAttempts(ListJobRunAttemptsRequest listJobRunAttemptsRequest)
throws ValidationException, ResourceNotFoundException, InternalServerException, AwsServiceException,
SdkClientException, EmrServerlessException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListJobRunAttemptsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listJobRunAttemptsRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, listJobRunAttemptsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "EMR Serverless");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListJobRunAttempts");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("ListJobRunAttempts").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(listJobRunAttemptsRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new ListJobRunAttemptsRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Lists job runs based on a set of parameters.
*
*
* @param listJobRunsRequest
* @return Result of the ListJobRuns operation returned by the service.
* @throws ValidationException
* The input fails to satisfy the constraints specified by an Amazon Web Services service.
* @throws InternalServerException
* Request processing failed because of an error or failure with the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws EmrServerlessException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample EmrServerlessClient.ListJobRuns
* @see AWS
* API Documentation
*/
@Override
public ListJobRunsResponse listJobRuns(ListJobRunsRequest listJobRunsRequest) throws ValidationException,
InternalServerException, AwsServiceException, SdkClientException, EmrServerlessException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
ListJobRunsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listJobRunsRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, listJobRunsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "EMR Serverless");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListJobRuns");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("ListJobRuns").withProtocolMetadata(protocolMetadata).withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration)
.withInput(listJobRunsRequest).withMetricCollector(apiCallMetricCollector)
.withMarshaller(new ListJobRunsRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Lists the tags assigned to the resources.
*
*
* @param listTagsForResourceRequest
* @return Result of the ListTagsForResource operation returned by the service.
* @throws ValidationException
* The input fails to satisfy the constraints specified by an Amazon Web Services service.
* @throws ResourceNotFoundException
* The specified resource was not found.
* @throws InternalServerException
* Request processing failed because of an error or failure with the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws EmrServerlessException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample EmrServerlessClient.ListTagsForResource
* @see AWS API Documentation
*/
@Override
public ListTagsForResourceResponse listTagsForResource(ListTagsForResourceRequest listTagsForResourceRequest)
throws ValidationException, ResourceNotFoundException, InternalServerException, AwsServiceException,
SdkClientException, EmrServerlessException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListTagsForResourceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listTagsForResourceRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, listTagsForResourceRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "EMR Serverless");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListTagsForResource");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("ListTagsForResource").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(listTagsForResourceRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new ListTagsForResourceRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Starts a specified application and initializes initial capacity if configured.
*
*
* @param startApplicationRequest
* @return Result of the StartApplication operation returned by the service.
* @throws ValidationException
* The input fails to satisfy the constraints specified by an Amazon Web Services service.
* @throws ResourceNotFoundException
* The specified resource was not found.
* @throws InternalServerException
* Request processing failed because of an error or failure with the service.
* @throws ServiceQuotaExceededException
* The maximum number of resources per account has been reached.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws EmrServerlessException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample EmrServerlessClient.StartApplication
* @see AWS API Documentation
*/
@Override
public StartApplicationResponse startApplication(StartApplicationRequest startApplicationRequest) throws ValidationException,
ResourceNotFoundException, InternalServerException, ServiceQuotaExceededException, AwsServiceException,
SdkClientException, EmrServerlessException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
StartApplicationResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(startApplicationRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, startApplicationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "EMR Serverless");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StartApplication");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("StartApplication").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(startApplicationRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new StartApplicationRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Starts a job run.
*
*
* @param startJobRunRequest
* @return Result of the StartJobRun operation returned by the service.
* @throws ValidationException
* The input fails to satisfy the constraints specified by an Amazon Web Services service.
* @throws ResourceNotFoundException
* The specified resource was not found.
* @throws InternalServerException
* Request processing failed because of an error or failure with the service.
* @throws ConflictException
* The request could not be processed because of conflict in the current state of the resource.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws EmrServerlessException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample EmrServerlessClient.StartJobRun
* @see AWS
* API Documentation
*/
@Override
public StartJobRunResponse startJobRun(StartJobRunRequest startJobRunRequest) throws ValidationException,
ResourceNotFoundException, InternalServerException, ConflictException, AwsServiceException, SdkClientException,
EmrServerlessException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
StartJobRunResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(startJobRunRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, startJobRunRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "EMR Serverless");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StartJobRun");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("StartJobRun").withProtocolMetadata(protocolMetadata).withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration)
.withInput(startJobRunRequest).withMetricCollector(apiCallMetricCollector)
.withMarshaller(new StartJobRunRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Stops a specified application and releases initial capacity if configured. All scheduled and running jobs must be
* completed or cancelled before stopping an application.
*
*
* @param stopApplicationRequest
* @return Result of the StopApplication operation returned by the service.
* @throws ValidationException
* The input fails to satisfy the constraints specified by an Amazon Web Services service.
* @throws ResourceNotFoundException
* The specified resource was not found.
* @throws InternalServerException
* Request processing failed because of an error or failure with the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws EmrServerlessException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample EmrServerlessClient.StopApplication
* @see AWS API Documentation
*/
@Override
public StopApplicationResponse stopApplication(StopApplicationRequest stopApplicationRequest) throws ValidationException,
ResourceNotFoundException, InternalServerException, AwsServiceException, SdkClientException, EmrServerlessException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
StopApplicationResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(stopApplicationRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, stopApplicationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "EMR Serverless");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StopApplication");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("StopApplication").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(stopApplicationRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new StopApplicationRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Assigns tags to resources. A tag is a label that you assign to an Amazon Web Services resource. Each tag consists
* of a key and an optional value, both of which you define. Tags enable you to categorize your Amazon Web Services
* resources by attributes such as purpose, owner, or environment. When you have many resources of the same type,
* you can quickly identify a specific resource based on the tags you've assigned to it.
*
*
* @param tagResourceRequest
* @return Result of the TagResource operation returned by the service.
* @throws ValidationException
* The input fails to satisfy the constraints specified by an Amazon Web Services service.
* @throws ResourceNotFoundException
* The specified resource was not found.
* @throws InternalServerException
* Request processing failed because of an error or failure with the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws EmrServerlessException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample EmrServerlessClient.TagResource
* @see AWS
* API Documentation
*/
@Override
public TagResourceResponse tagResource(TagResourceRequest tagResourceRequest) throws ValidationException,
ResourceNotFoundException, InternalServerException, AwsServiceException, SdkClientException, EmrServerlessException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
TagResourceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(tagResourceRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, tagResourceRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "EMR Serverless");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "TagResource");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("TagResource").withProtocolMetadata(protocolMetadata).withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration)
.withInput(tagResourceRequest).withMetricCollector(apiCallMetricCollector)
.withMarshaller(new TagResourceRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Removes tags from resources.
*
*
* @param untagResourceRequest
* @return Result of the UntagResource operation returned by the service.
* @throws ValidationException
* The input fails to satisfy the constraints specified by an Amazon Web Services service.
* @throws ResourceNotFoundException
* The specified resource was not found.
* @throws InternalServerException
* Request processing failed because of an error or failure with the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws EmrServerlessException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample EmrServerlessClient.UntagResource
* @see AWS
* API Documentation
*/
@Override
public UntagResourceResponse untagResource(UntagResourceRequest untagResourceRequest) throws ValidationException,
ResourceNotFoundException, InternalServerException, AwsServiceException, SdkClientException, EmrServerlessException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
UntagResourceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(untagResourceRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, untagResourceRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "EMR Serverless");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "UntagResource");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("UntagResource").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(untagResourceRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new UntagResourceRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Updates a specified application. An application has to be in a stopped or created state in order to be updated.
*
*
* @param updateApplicationRequest
* @return Result of the UpdateApplication operation returned by the service.
* @throws ValidationException
* The input fails to satisfy the constraints specified by an Amazon Web Services service.
* @throws ResourceNotFoundException
* The specified resource was not found.
* @throws InternalServerException
* Request processing failed because of an error or failure with the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws EmrServerlessException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample EmrServerlessClient.UpdateApplication
* @see AWS API Documentation
*/
@Override
public UpdateApplicationResponse updateApplication(UpdateApplicationRequest updateApplicationRequest)
throws ValidationException, ResourceNotFoundException, InternalServerException, AwsServiceException,
SdkClientException, EmrServerlessException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
UpdateApplicationResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(updateApplicationRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, updateApplicationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "EMR Serverless");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "UpdateApplication");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("UpdateApplication").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(updateApplicationRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new UpdateApplicationRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
@Override
public final String serviceName() {
return SERVICE_NAME;
}
private static List resolveMetricPublishers(SdkClientConfiguration clientConfiguration,
RequestOverrideConfiguration requestOverrideConfiguration) {
List publishers = null;
if (requestOverrideConfiguration != null) {
publishers = requestOverrideConfiguration.metricPublishers();
}
if (publishers == null || publishers.isEmpty()) {
publishers = clientConfiguration.option(SdkClientOption.METRIC_PUBLISHERS);
}
if (publishers == null) {
publishers = Collections.emptyList();
}
return publishers;
}
private HttpResponseHandler createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory,
JsonOperationMetadata operationMetadata) {
return protocolFactory.createErrorResponseHandler(operationMetadata);
}
private void updateRetryStrategyClientConfiguration(SdkClientConfiguration.Builder configuration) {
ClientOverrideConfiguration.Builder builder = configuration.asOverrideConfigurationBuilder();
RetryMode retryMode = builder.retryMode();
if (retryMode != null) {
configuration.option(SdkClientOption.RETRY_STRATEGY, AwsRetryStrategy.forRetryMode(retryMode));
} else {
Consumer> configurator = builder.retryStrategyConfigurator();
if (configurator != null) {
RetryStrategy.Builder defaultBuilder = AwsRetryStrategy.defaultRetryStrategy().toBuilder();
configurator.accept(defaultBuilder);
configuration.option(SdkClientOption.RETRY_STRATEGY, defaultBuilder.build());
} else {
RetryStrategy retryStrategy = builder.retryStrategy();
if (retryStrategy != null) {
configuration.option(SdkClientOption.RETRY_STRATEGY, retryStrategy);
}
}
}
configuration.option(SdkClientOption.CONFIGURED_RETRY_MODE, null);
configuration.option(SdkClientOption.CONFIGURED_RETRY_STRATEGY, null);
configuration.option(SdkClientOption.CONFIGURED_RETRY_CONFIGURATOR, null);
}
private SdkClientConfiguration updateSdkClientConfiguration(SdkRequest request, SdkClientConfiguration clientConfiguration) {
List plugins = request.overrideConfiguration().map(c -> c.plugins()).orElse(Collections.emptyList());
SdkClientConfiguration.Builder configuration = clientConfiguration.toBuilder();
if (plugins.isEmpty()) {
return configuration.build();
}
EmrServerlessServiceClientConfigurationBuilder serviceConfigBuilder = new EmrServerlessServiceClientConfigurationBuilder(
configuration);
for (SdkPlugin plugin : plugins) {
plugin.configureClient(serviceConfigBuilder);
}
updateRetryStrategyClientConfiguration(configuration);
return configuration.build();
}
private > T init(T builder) {
return builder
.clientConfiguration(clientConfiguration)
.defaultServiceExceptionSupplier(EmrServerlessException::builder)
.protocol(AwsJsonProtocol.REST_JSON)
.protocolVersion("1.1")
.registerModeledException(
ExceptionMetadata.builder().errorCode("ConflictException")
.exceptionBuilderSupplier(ConflictException::builder).httpStatusCode(409).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ResourceNotFoundException")
.exceptionBuilderSupplier(ResourceNotFoundException::builder).httpStatusCode(404).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ValidationException")
.exceptionBuilderSupplier(ValidationException::builder).httpStatusCode(400).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ServiceQuotaExceededException")
.exceptionBuilderSupplier(ServiceQuotaExceededException::builder).httpStatusCode(402).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("InternalServerException")
.exceptionBuilderSupplier(InternalServerException::builder).httpStatusCode(500).build());
}
@Override
public final EmrServerlessServiceClientConfiguration serviceClientConfiguration() {
return new EmrServerlessServiceClientConfigurationBuilder(this.clientConfiguration.toBuilder()).build();
}
@Override
public void close() {
clientHandler.close();
}
}