com.ibm.cloud.objectstorage.client.ClientHandlerImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ibm-cos-java-sdk-bundle Show documentation
Show all versions of ibm-cos-java-sdk-bundle Show documentation
A single bundled dependency that includes all service and dependent JARs with third-party libraries relocated to different namespaces.
/*
* Copyright 2011-2022 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 com.ibm.cloud.objectstorage.client;
import com.ibm.cloud.objectstorage.AmazonWebServiceRequest;
import com.ibm.cloud.objectstorage.Request;
import com.ibm.cloud.objectstorage.RequestConfig;
import com.ibm.cloud.objectstorage.Response;
import com.ibm.cloud.objectstorage.SdkBaseException;
import com.ibm.cloud.objectstorage.annotation.Immutable;
import com.ibm.cloud.objectstorage.annotation.SdkProtectedApi;
import com.ibm.cloud.objectstorage.annotation.ThreadSafe;
import com.ibm.cloud.objectstorage.auth.AWSCredentialsProvider;
import com.ibm.cloud.objectstorage.handlers.RequestHandler2;
import com.ibm.cloud.objectstorage.http.AmazonHttpClient;
import com.ibm.cloud.objectstorage.http.ExecutionContext;
import com.ibm.cloud.objectstorage.http.HttpResponseHandler;
import com.ibm.cloud.objectstorage.internal.auth.SignerProvider;
import com.ibm.cloud.objectstorage.metrics.AwsSdkMetrics;
import com.ibm.cloud.objectstorage.metrics.RequestMetricCollector;
import com.ibm.cloud.objectstorage.util.AWSRequestMetrics;
import com.ibm.cloud.objectstorage.util.CredentialUtils;
import java.net.URI;
import java.util.List;
/**
* Default implementation of {@link ClientHandler}.
*/
@Immutable
@ThreadSafe
@SdkProtectedApi
public class ClientHandlerImpl extends ClientHandler {
private final AWSCredentialsProvider awsCredentialsProvider;
private final SignerProvider signerProvider;
private final URI endpoint;
private final List requestHandler2s;
private final RequestMetricCollector clientLevelMetricCollector;
private final AmazonHttpClient client;
public ClientHandlerImpl(ClientHandlerParams handlerParams) {
this.signerProvider = handlerParams.getClientParams().getSignerProvider();
this.endpoint = handlerParams.getClientParams().getEndpoint();
this.awsCredentialsProvider = handlerParams.getClientParams().getCredentialsProvider();
this.requestHandler2s = handlerParams.getClientParams().getRequestHandlers();
this.clientLevelMetricCollector = handlerParams.getClientParams().getRequestMetricCollector();
this.client = buildHttpClient(handlerParams);
}
private AmazonHttpClient buildHttpClient(ClientHandlerParams handlerParams) {
final AwsSyncClientParams clientParams = handlerParams.getClientParams();
return AmazonHttpClient.builder()
.clientConfiguration(clientParams.getClientConfiguration())
.retryPolicy(clientParams.getRetryPolicy())
.requestMetricCollector(clientParams.getRequestMetricCollector())
.useBrowserCompatibleHostNameVerifier(handlerParams.isDisableStrictHostnameVerification())
.build();
}
@Override
public Output execute(
ClientExecutionParams executionParams) {
final Input input = executionParams.getInput();
ExecutionContext executionContext = createExecutionContext(
executionParams.getRequestConfig());
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
awsRequestMetrics.startEvent(AWSRequestMetrics.Field.ClientExecuteTime);
Request request = null;
Response
© 2015 - 2025 Weber Informatics LLC | Privacy Policy