Search in sources :

Example 6 with ClientExecutionParams

use of software.amazon.awssdk.core.client.handler.ClientExecutionParams in project aws-sdk-java-v2 by aws.

the class DefaultEndpointDiscoveryTestClient method testDiscoveryRequired.

/**
 * Invokes the TestDiscoveryRequired operation.
 *
 * @param testDiscoveryRequiredRequest
 * @return Result of the TestDiscoveryRequired operation returned by 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 EndpointDiscoveryTestException
 *         Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
 * @sample EndpointDiscoveryTestClient.TestDiscoveryRequired
 */
@Override
public TestDiscoveryRequiredResponse testDiscoveryRequired(TestDiscoveryRequiredRequest testDiscoveryRequiredRequest) throws AwsServiceException, SdkClientException, EndpointDiscoveryTestException {
    JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false).isPayloadJson(true).build();
    HttpResponseHandler<TestDiscoveryRequiredResponse> responseHandler = protocolFactory.createResponseHandler(operationMetadata, TestDiscoveryRequiredResponse::builder);
    HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata);
    boolean endpointDiscoveryEnabled = clientConfiguration.option(SdkClientOption.ENDPOINT_DISCOVERY_ENABLED);
    boolean endpointOverridden = clientConfiguration.option(SdkClientOption.ENDPOINT_OVERRIDDEN) == Boolean.TRUE;
    if (endpointOverridden) {
        throw new IllegalStateException("This operation requires endpoint discovery, but an endpoint override was specified when the client was created. This is not supported.");
    }
    if (!endpointDiscoveryEnabled) {
        throw new IllegalStateException("This operation requires endpoint discovery, but endpoint discovery was disabled on the client.");
    }
    URI cachedEndpoint = null;
    if (endpointDiscoveryEnabled) {
        String key = testDiscoveryRequiredRequest.overrideConfiguration().flatMap(AwsRequestOverrideConfiguration::credentialsProvider).orElseGet(() -> clientConfiguration.option(AwsClientOption.CREDENTIALS_PROVIDER)).resolveCredentials().accessKeyId();
        EndpointDiscoveryRequest endpointDiscoveryRequest = EndpointDiscoveryRequest.builder().required(true).defaultEndpoint(clientConfiguration.option(SdkClientOption.ENDPOINT)).overrideConfiguration(testDiscoveryRequiredRequest.overrideConfiguration().orElse(null)).build();
        cachedEndpoint = endpointDiscoveryCache.get(key, endpointDiscoveryRequest);
    }
    List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, testDiscoveryRequiredRequest.overrideConfiguration().orElse(null));
    MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector.create("ApiCall");
    try {
        apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "AwsEndpointDiscoveryTest");
        apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "TestDiscoveryRequired");
        return clientHandler.execute(new ClientExecutionParams<TestDiscoveryRequiredRequest, TestDiscoveryRequiredResponse>().withOperationName("TestDiscoveryRequired").withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler).discoveredEndpoint(cachedEndpoint).withInput(testDiscoveryRequiredRequest).withMetricCollector(apiCallMetricCollector).withMarshaller(new TestDiscoveryRequiredRequestMarshaller(protocolFactory)));
    } finally {
        metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
    }
}
Also used : ClientExecutionParams(software.amazon.awssdk.core.client.handler.ClientExecutionParams) TestDiscoveryRequiredResponse(software.amazon.awssdk.services.endpointdiscoverytest.model.TestDiscoveryRequiredResponse) TestDiscoveryRequiredRequestMarshaller(software.amazon.awssdk.services.endpointdiscoverytest.transform.TestDiscoveryRequiredRequestMarshaller) EndpointDiscoveryRequest(software.amazon.awssdk.core.endpointdiscovery.EndpointDiscoveryRequest) MetricPublisher(software.amazon.awssdk.metrics.MetricPublisher) JsonOperationMetadata(software.amazon.awssdk.protocols.json.JsonOperationMetadata) URI(java.net.URI) AwsServiceException(software.amazon.awssdk.awscore.exception.AwsServiceException) NoOpMetricCollector(software.amazon.awssdk.metrics.NoOpMetricCollector) MetricCollector(software.amazon.awssdk.metrics.MetricCollector)

Example 7 with ClientExecutionParams

use of software.amazon.awssdk.core.client.handler.ClientExecutionParams in project aws-sdk-java-v2 by aws.

the class DefaultJsonClient method operationWithChecksumRequired.

/**
 * Invokes the OperationWithChecksumRequired operation.
 *
 * @param operationWithChecksumRequiredRequest
 * @return Result of the OperationWithChecksumRequired operation returned by 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 JsonException
 *         Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
 * @sample JsonClient.OperationWithChecksumRequired
 * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithChecksumRequired"
 *      target="_top">AWS API Documentation</a>
 */
@Override
public OperationWithChecksumRequiredResponse operationWithChecksumRequired(OperationWithChecksumRequiredRequest operationWithChecksumRequiredRequest) throws AwsServiceException, SdkClientException, JsonException {
    JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false).isPayloadJson(true).build();
    HttpResponseHandler<OperationWithChecksumRequiredResponse> responseHandler = protocolFactory.createResponseHandler(operationMetadata, OperationWithChecksumRequiredResponse::builder);
    HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata);
    List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithChecksumRequiredRequest.overrideConfiguration().orElse(null));
    MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector.create("ApiCall");
    try {
        apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
        apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithChecksumRequired");
        return clientHandler.execute(new ClientExecutionParams<OperationWithChecksumRequiredRequest, OperationWithChecksumRequiredResponse>().withOperationName("OperationWithChecksumRequired").withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler).withInput(operationWithChecksumRequiredRequest).withMetricCollector(apiCallMetricCollector).putExecutionAttribute(SdkInternalExecutionAttribute.HTTP_CHECKSUM_REQUIRED, HttpChecksumRequired.create()).withMarshaller(new OperationWithChecksumRequiredRequestMarshaller(protocolFactory)));
    } finally {
        metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
    }
}
Also used : ClientExecutionParams(software.amazon.awssdk.core.client.handler.ClientExecutionParams) AwsServiceException(software.amazon.awssdk.awscore.exception.AwsServiceException) OperationWithChecksumRequiredResponse(software.amazon.awssdk.services.json.model.OperationWithChecksumRequiredResponse) MetricPublisher(software.amazon.awssdk.metrics.MetricPublisher) NoOpMetricCollector(software.amazon.awssdk.metrics.NoOpMetricCollector) MetricCollector(software.amazon.awssdk.metrics.MetricCollector) JsonOperationMetadata(software.amazon.awssdk.protocols.json.JsonOperationMetadata) OperationWithChecksumRequiredRequestMarshaller(software.amazon.awssdk.services.json.transform.OperationWithChecksumRequiredRequestMarshaller)

Example 8 with ClientExecutionParams

use of software.amazon.awssdk.core.client.handler.ClientExecutionParams in project aws-sdk-java-v2 by aws.

the class DefaultJsonClient method aPostOperation.

/**
 * <p>
 * Performs a post operation to the query service and has no output
 * </p>
 *
 * @param aPostOperationRequest
 * @return Result of the APostOperation operation returned by the service.
 * @throws InvalidInputException
 *         The request was rejected because an invalid or out-of-range value was supplied for an input parameter.
 * @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 JsonException
 *         Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
 * @sample JsonClient.APostOperation
 * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/APostOperation" target="_top">AWS
 *      API Documentation</a>
 */
@Override
public APostOperationResponse aPostOperation(APostOperationRequest aPostOperationRequest) throws InvalidInputException, AwsServiceException, SdkClientException, JsonException {
    JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false).isPayloadJson(true).build();
    HttpResponseHandler<APostOperationResponse> responseHandler = protocolFactory.createResponseHandler(operationMetadata, APostOperationResponse::builder);
    HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata);
    List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationRequest.overrideConfiguration().orElse(null));
    MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector.create("ApiCall");
    try {
        apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
        apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperation");
        String hostPrefix = "{StringMember}-foo.";
        HostnameValidator.validateHostnameCompliant(aPostOperationRequest.stringMember(), "StringMember", "aPostOperationRequest");
        String resolvedHostExpression = String.format("%s-foo.", aPostOperationRequest.stringMember());
        return clientHandler.execute(new ClientExecutionParams<APostOperationRequest, APostOperationResponse>().withOperationName("APostOperation").withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler).hostPrefixExpression(resolvedHostExpression).withInput(aPostOperationRequest).withMetricCollector(apiCallMetricCollector).withMarshaller(new APostOperationRequestMarshaller(protocolFactory)));
    } finally {
        metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
    }
}
Also used : APostOperationResponse(software.amazon.awssdk.services.json.model.APostOperationResponse) ClientExecutionParams(software.amazon.awssdk.core.client.handler.ClientExecutionParams) AwsServiceException(software.amazon.awssdk.awscore.exception.AwsServiceException) MetricPublisher(software.amazon.awssdk.metrics.MetricPublisher) NoOpMetricCollector(software.amazon.awssdk.metrics.NoOpMetricCollector) MetricCollector(software.amazon.awssdk.metrics.MetricCollector) APostOperationRequestMarshaller(software.amazon.awssdk.services.json.transform.APostOperationRequestMarshaller) JsonOperationMetadata(software.amazon.awssdk.protocols.json.JsonOperationMetadata)

Example 9 with ClientExecutionParams

use of software.amazon.awssdk.core.client.handler.ClientExecutionParams in project aws-sdk-java-v2 by aws.

the class DefaultQueryAsyncClient method aPostOperation.

/**
 * <p>
 * Performs a post operation to the query service and has no output
 * </p>
 *
 * @param aPostOperationRequest
 * @return A Java Future containing the result of the APostOperation operation returned by the service.<br/>
 *         The CompletableFuture returned by this method can be completed exceptionally with the following
 *         exceptions.
 *         <ul>
 *         <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied
 *         for an input parameter.</li>
 *         <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
 *         Can be used for catch all scenarios.</li>
 *         <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
 *         credentials, etc.</li>
 *         <li>QueryException Base class for all service exceptions. Unknown exceptions will be thrown as an
 *         instance of this type.</li>
 *         </ul>
 * @sample QueryAsyncClient.APostOperation
 * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/APostOperation" target="_top">AWS
 *      API Documentation</a>
 */
@Override
public CompletableFuture<APostOperationResponse> aPostOperation(APostOperationRequest aPostOperationRequest) {
    List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationRequest.overrideConfiguration().orElse(null));
    MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector.create("ApiCall");
    try {
        apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service");
        apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperation");
        HttpResponseHandler<APostOperationResponse> responseHandler = protocolFactory.createResponseHandler(APostOperationResponse::builder);
        HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
        String hostPrefix = "foo-";
        String resolvedHostExpression = "foo-";
        CompletableFuture<APostOperationResponse> executeFuture = clientHandler.execute(new ClientExecutionParams<APostOperationRequest, APostOperationResponse>().withOperationName("APostOperation").withMarshaller(new APostOperationRequestMarshaller(protocolFactory)).withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler).withMetricCollector(apiCallMetricCollector).hostPrefixExpression(resolvedHostExpression).withInput(aPostOperationRequest));
        CompletableFuture<APostOperationResponse> whenCompleteFuture = null;
        whenCompleteFuture = executeFuture.whenComplete((r, e) -> {
            metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
        });
        return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture);
    } catch (Throwable t) {
        metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
        return CompletableFutureUtils.failedFuture(t);
    }
}
Also used : ExceptionMetadata(software.amazon.awssdk.protocols.core.ExceptionMetadata) StreamingInputOperationRequestMarshaller(software.amazon.awssdk.services.query.transform.StreamingInputOperationRequestMarshaller) AwsAsyncClientHandler(software.amazon.awssdk.awscore.client.handler.AwsAsyncClientHandler) LoggerFactory(org.slf4j.LoggerFactory) MetricPublisher(software.amazon.awssdk.metrics.MetricPublisher) QueryException(software.amazon.awssdk.services.query.model.QueryException) AsyncStreamingRequestMarshaller(software.amazon.awssdk.core.runtime.transform.AsyncStreamingRequestMarshaller) AsyncResponseTransformer(software.amazon.awssdk.core.async.AsyncResponseTransformer) SdkClientOption(software.amazon.awssdk.core.client.config.SdkClientOption) OperationWithChecksumRequiredResponse(software.amazon.awssdk.services.query.model.OperationWithChecksumRequiredResponse) AsyncClientHandler(software.amazon.awssdk.core.client.handler.AsyncClientHandler) APostOperationRequestMarshaller(software.amazon.awssdk.services.query.transform.APostOperationRequestMarshaller) AwsServiceException(software.amazon.awssdk.awscore.exception.AwsServiceException) StreamingOutputOperationResponse(software.amazon.awssdk.services.query.model.StreamingOutputOperationResponse) StreamingOutputOperationRequest(software.amazon.awssdk.services.query.model.StreamingOutputOperationRequest) List(java.util.List) AsyncRequestBody(software.amazon.awssdk.core.async.AsyncRequestBody) OperationWithChecksumRequiredRequest(software.amazon.awssdk.services.query.model.OperationWithChecksumRequiredRequest) AsyncAws4Signer(software.amazon.awssdk.auth.signer.AsyncAws4Signer) HttpResponseHandler(software.amazon.awssdk.core.http.HttpResponseHandler) PutOperationWithChecksumResponse(software.amazon.awssdk.services.query.model.PutOperationWithChecksumResponse) Generated(software.amazon.awssdk.annotations.Generated) AsyncResponseTransformerUtils(software.amazon.awssdk.core.async.AsyncResponseTransformerUtils) GetOperationWithChecksumRequest(software.amazon.awssdk.services.query.model.GetOperationWithChecksumRequest) AwsRequestOverrideConfiguration(software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration) Signer(software.amazon.awssdk.core.signer.Signer) PutOperationWithChecksumRequestMarshaller(software.amazon.awssdk.services.query.transform.PutOperationWithChecksumRequestMarshaller) OperationWithChecksumRequiredRequestMarshaller(software.amazon.awssdk.services.query.transform.OperationWithChecksumRequiredRequestMarshaller) CompletableFutureUtils(software.amazon.awssdk.utils.CompletableFutureUtils) CompletableFuture(java.util.concurrent.CompletableFuture) SdkClientConfiguration(software.amazon.awssdk.core.client.config.SdkClientConfiguration) StreamingOutputOperationRequestMarshaller(software.amazon.awssdk.services.query.transform.StreamingOutputOperationRequestMarshaller) StreamingInputOperationRequest(software.amazon.awssdk.services.query.model.StreamingInputOperationRequest) HttpChecksumRequired(software.amazon.awssdk.core.interceptor.trait.HttpChecksumRequired) CoreMetric(software.amazon.awssdk.core.metrics.CoreMetric) AwsQueryProtocolFactory(software.amazon.awssdk.protocols.query.AwsQueryProtocolFactory) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) RequestOverrideConfiguration(software.amazon.awssdk.core.RequestOverrideConfiguration) InvalidInputException(software.amazon.awssdk.services.query.model.InvalidInputException) APostOperationResponse(software.amazon.awssdk.services.query.model.APostOperationResponse) NoOpMetricCollector(software.amazon.awssdk.metrics.NoOpMetricCollector) GetOperationWithChecksumResponse(software.amazon.awssdk.services.query.model.GetOperationWithChecksumResponse) APostOperationWithOutputResponse(software.amazon.awssdk.services.query.model.APostOperationWithOutputResponse) APostOperationWithOutputRequestMarshaller(software.amazon.awssdk.services.query.transform.APostOperationWithOutputRequestMarshaller) Logger(org.slf4j.Logger) SdkInternalExecutionAttribute(software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute) MetricCollector(software.amazon.awssdk.metrics.MetricCollector) QueryAsyncWaiter(software.amazon.awssdk.services.query.waiters.QueryAsyncWaiter) StreamingInputOperationResponse(software.amazon.awssdk.services.query.model.StreamingInputOperationResponse) Pair(software.amazon.awssdk.utils.Pair) PutOperationWithChecksumRequest(software.amazon.awssdk.services.query.model.PutOperationWithChecksumRequest) QueryRequest(software.amazon.awssdk.services.query.model.QueryRequest) Consumer(java.util.function.Consumer) HttpChecksum(software.amazon.awssdk.core.interceptor.trait.HttpChecksum) ClientExecutionParams(software.amazon.awssdk.core.client.handler.ClientExecutionParams) APostOperationWithOutputRequest(software.amazon.awssdk.services.query.model.APostOperationWithOutputRequest) APostOperationRequest(software.amazon.awssdk.services.query.model.APostOperationRequest) GetOperationWithChecksumRequestMarshaller(software.amazon.awssdk.services.query.transform.GetOperationWithChecksumRequestMarshaller) SdkInternalApi(software.amazon.awssdk.annotations.SdkInternalApi) FunctionalUtils.runAndLogError(software.amazon.awssdk.utils.FunctionalUtils.runAndLogError) Collections(java.util.Collections) APostOperationResponse(software.amazon.awssdk.services.query.model.APostOperationResponse) ClientExecutionParams(software.amazon.awssdk.core.client.handler.ClientExecutionParams) MetricPublisher(software.amazon.awssdk.metrics.MetricPublisher) APostOperationRequestMarshaller(software.amazon.awssdk.services.query.transform.APostOperationRequestMarshaller) AwsServiceException(software.amazon.awssdk.awscore.exception.AwsServiceException) NoOpMetricCollector(software.amazon.awssdk.metrics.NoOpMetricCollector) MetricCollector(software.amazon.awssdk.metrics.MetricCollector)

Example 10 with ClientExecutionParams

use of software.amazon.awssdk.core.client.handler.ClientExecutionParams in project aws-sdk-java-v2 by aws.

the class DefaultQueryAsyncClient method aPostOperationWithOutput.

/**
 * <p>
 * Performs a post operation to the query service and has modelled output
 * </p>
 *
 * @param aPostOperationWithOutputRequest
 * @return A Java Future containing the result of the APostOperationWithOutput operation returned by the service.<br/>
 *         The CompletableFuture returned by this method can be completed exceptionally with the following
 *         exceptions.
 *         <ul>
 *         <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied
 *         for an input parameter.</li>
 *         <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
 *         Can be used for catch all scenarios.</li>
 *         <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
 *         credentials, etc.</li>
 *         <li>QueryException Base class for all service exceptions. Unknown exceptions will be thrown as an
 *         instance of this type.</li>
 *         </ul>
 * @sample QueryAsyncClient.APostOperationWithOutput
 * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/APostOperationWithOutput"
 *      target="_top">AWS API Documentation</a>
 */
@Override
public CompletableFuture<APostOperationWithOutputResponse> aPostOperationWithOutput(APostOperationWithOutputRequest aPostOperationWithOutputRequest) {
    List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationWithOutputRequest.overrideConfiguration().orElse(null));
    MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector.create("ApiCall");
    try {
        apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service");
        apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperationWithOutput");
        HttpResponseHandler<APostOperationWithOutputResponse> responseHandler = protocolFactory.createResponseHandler(APostOperationWithOutputResponse::builder);
        HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
        CompletableFuture<APostOperationWithOutputResponse> executeFuture = clientHandler.execute(new ClientExecutionParams<APostOperationWithOutputRequest, APostOperationWithOutputResponse>().withOperationName("APostOperationWithOutput").withMarshaller(new APostOperationWithOutputRequestMarshaller(protocolFactory)).withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler).withMetricCollector(apiCallMetricCollector).withInput(aPostOperationWithOutputRequest));
        CompletableFuture<APostOperationWithOutputResponse> whenCompleteFuture = null;
        whenCompleteFuture = executeFuture.whenComplete((r, e) -> {
            metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
        });
        return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture);
    } catch (Throwable t) {
        metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
        return CompletableFutureUtils.failedFuture(t);
    }
}
Also used : ExceptionMetadata(software.amazon.awssdk.protocols.core.ExceptionMetadata) StreamingInputOperationRequestMarshaller(software.amazon.awssdk.services.query.transform.StreamingInputOperationRequestMarshaller) AwsAsyncClientHandler(software.amazon.awssdk.awscore.client.handler.AwsAsyncClientHandler) LoggerFactory(org.slf4j.LoggerFactory) MetricPublisher(software.amazon.awssdk.metrics.MetricPublisher) QueryException(software.amazon.awssdk.services.query.model.QueryException) AsyncStreamingRequestMarshaller(software.amazon.awssdk.core.runtime.transform.AsyncStreamingRequestMarshaller) AsyncResponseTransformer(software.amazon.awssdk.core.async.AsyncResponseTransformer) SdkClientOption(software.amazon.awssdk.core.client.config.SdkClientOption) OperationWithChecksumRequiredResponse(software.amazon.awssdk.services.query.model.OperationWithChecksumRequiredResponse) AsyncClientHandler(software.amazon.awssdk.core.client.handler.AsyncClientHandler) APostOperationRequestMarshaller(software.amazon.awssdk.services.query.transform.APostOperationRequestMarshaller) AwsServiceException(software.amazon.awssdk.awscore.exception.AwsServiceException) StreamingOutputOperationResponse(software.amazon.awssdk.services.query.model.StreamingOutputOperationResponse) StreamingOutputOperationRequest(software.amazon.awssdk.services.query.model.StreamingOutputOperationRequest) List(java.util.List) AsyncRequestBody(software.amazon.awssdk.core.async.AsyncRequestBody) OperationWithChecksumRequiredRequest(software.amazon.awssdk.services.query.model.OperationWithChecksumRequiredRequest) AsyncAws4Signer(software.amazon.awssdk.auth.signer.AsyncAws4Signer) HttpResponseHandler(software.amazon.awssdk.core.http.HttpResponseHandler) PutOperationWithChecksumResponse(software.amazon.awssdk.services.query.model.PutOperationWithChecksumResponse) Generated(software.amazon.awssdk.annotations.Generated) AsyncResponseTransformerUtils(software.amazon.awssdk.core.async.AsyncResponseTransformerUtils) GetOperationWithChecksumRequest(software.amazon.awssdk.services.query.model.GetOperationWithChecksumRequest) AwsRequestOverrideConfiguration(software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration) Signer(software.amazon.awssdk.core.signer.Signer) PutOperationWithChecksumRequestMarshaller(software.amazon.awssdk.services.query.transform.PutOperationWithChecksumRequestMarshaller) OperationWithChecksumRequiredRequestMarshaller(software.amazon.awssdk.services.query.transform.OperationWithChecksumRequiredRequestMarshaller) CompletableFutureUtils(software.amazon.awssdk.utils.CompletableFutureUtils) CompletableFuture(java.util.concurrent.CompletableFuture) SdkClientConfiguration(software.amazon.awssdk.core.client.config.SdkClientConfiguration) StreamingOutputOperationRequestMarshaller(software.amazon.awssdk.services.query.transform.StreamingOutputOperationRequestMarshaller) StreamingInputOperationRequest(software.amazon.awssdk.services.query.model.StreamingInputOperationRequest) HttpChecksumRequired(software.amazon.awssdk.core.interceptor.trait.HttpChecksumRequired) CoreMetric(software.amazon.awssdk.core.metrics.CoreMetric) AwsQueryProtocolFactory(software.amazon.awssdk.protocols.query.AwsQueryProtocolFactory) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) RequestOverrideConfiguration(software.amazon.awssdk.core.RequestOverrideConfiguration) InvalidInputException(software.amazon.awssdk.services.query.model.InvalidInputException) APostOperationResponse(software.amazon.awssdk.services.query.model.APostOperationResponse) NoOpMetricCollector(software.amazon.awssdk.metrics.NoOpMetricCollector) GetOperationWithChecksumResponse(software.amazon.awssdk.services.query.model.GetOperationWithChecksumResponse) APostOperationWithOutputResponse(software.amazon.awssdk.services.query.model.APostOperationWithOutputResponse) APostOperationWithOutputRequestMarshaller(software.amazon.awssdk.services.query.transform.APostOperationWithOutputRequestMarshaller) Logger(org.slf4j.Logger) SdkInternalExecutionAttribute(software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute) MetricCollector(software.amazon.awssdk.metrics.MetricCollector) QueryAsyncWaiter(software.amazon.awssdk.services.query.waiters.QueryAsyncWaiter) StreamingInputOperationResponse(software.amazon.awssdk.services.query.model.StreamingInputOperationResponse) Pair(software.amazon.awssdk.utils.Pair) PutOperationWithChecksumRequest(software.amazon.awssdk.services.query.model.PutOperationWithChecksumRequest) QueryRequest(software.amazon.awssdk.services.query.model.QueryRequest) Consumer(java.util.function.Consumer) HttpChecksum(software.amazon.awssdk.core.interceptor.trait.HttpChecksum) ClientExecutionParams(software.amazon.awssdk.core.client.handler.ClientExecutionParams) APostOperationWithOutputRequest(software.amazon.awssdk.services.query.model.APostOperationWithOutputRequest) APostOperationRequest(software.amazon.awssdk.services.query.model.APostOperationRequest) GetOperationWithChecksumRequestMarshaller(software.amazon.awssdk.services.query.transform.GetOperationWithChecksumRequestMarshaller) SdkInternalApi(software.amazon.awssdk.annotations.SdkInternalApi) FunctionalUtils.runAndLogError(software.amazon.awssdk.utils.FunctionalUtils.runAndLogError) Collections(java.util.Collections) MetricPublisher(software.amazon.awssdk.metrics.MetricPublisher) APostOperationWithOutputRequestMarshaller(software.amazon.awssdk.services.query.transform.APostOperationWithOutputRequestMarshaller) APostOperationWithOutputRequest(software.amazon.awssdk.services.query.model.APostOperationWithOutputRequest) AwsServiceException(software.amazon.awssdk.awscore.exception.AwsServiceException) NoOpMetricCollector(software.amazon.awssdk.metrics.NoOpMetricCollector) MetricCollector(software.amazon.awssdk.metrics.MetricCollector) APostOperationWithOutputResponse(software.amazon.awssdk.services.query.model.APostOperationWithOutputResponse)

Aggregations

ClientExecutionParams (software.amazon.awssdk.core.client.handler.ClientExecutionParams)48 MetricCollector (software.amazon.awssdk.metrics.MetricCollector)47 MetricPublisher (software.amazon.awssdk.metrics.MetricPublisher)47 NoOpMetricCollector (software.amazon.awssdk.metrics.NoOpMetricCollector)47 AwsServiceException (software.amazon.awssdk.awscore.exception.AwsServiceException)46 CompletableFuture (java.util.concurrent.CompletableFuture)35 SdkClientConfiguration (software.amazon.awssdk.core.client.config.SdkClientConfiguration)35 SdkClientOption (software.amazon.awssdk.core.client.config.SdkClientOption)35 HttpResponseHandler (software.amazon.awssdk.core.http.HttpResponseHandler)35 Collections (java.util.Collections)34 List (java.util.List)34 Logger (org.slf4j.Logger)34 LoggerFactory (org.slf4j.LoggerFactory)34 Generated (software.amazon.awssdk.annotations.Generated)34 SdkInternalApi (software.amazon.awssdk.annotations.SdkInternalApi)34 AwsAsyncClientHandler (software.amazon.awssdk.awscore.client.handler.AwsAsyncClientHandler)34 RequestOverrideConfiguration (software.amazon.awssdk.core.RequestOverrideConfiguration)34 AsyncClientHandler (software.amazon.awssdk.core.client.handler.AsyncClientHandler)34 CoreMetric (software.amazon.awssdk.core.metrics.CoreMetric)34 CompletableFutureUtils (software.amazon.awssdk.utils.CompletableFutureUtils)34