Search in sources :

Example 1 with RequestRetryOptions

use of com.azure.storage.common.policy.RequestRetryOptions in project ambry by linkedin.

the class StorageClient method createBlobStorageClient.

/**
 * Create the {@link BlobServiceClient} object.
 * @param {@link CloudConfig} object.
 * @param {@link AzureCloudConfig} object.
 * @return {@link BlobServiceClient} object.
 */
protected BlobServiceClient createBlobStorageClient() {
    validateABSAuthConfigs(azureCloudConfig);
    Configuration storageConfiguration = new Configuration();
    // Check for network proxy
    ProxyOptions proxyOptions = (cloudConfig.vcrProxyHost == null) ? null : new ProxyOptions(ProxyOptions.Type.HTTP, new InetSocketAddress(cloudConfig.vcrProxyHost, cloudConfig.vcrProxyPort));
    if (proxyOptions != null) {
        logger.info("Using proxy: {}:{}", cloudConfig.vcrProxyHost, cloudConfig.vcrProxyPort);
    }
    HttpClient client = new NettyAsyncHttpClientBuilder().proxy(proxyOptions).build();
    // Note: retry decisions are made at CloudBlobStore level.  Configure storageClient with no retries.
    RequestRetryOptions noRetries = new RequestRetryOptions(RetryPolicyType.FIXED, 1, (Integer) null, null, null, null);
    try {
        return buildBlobServiceClient(client, storageConfiguration, noRetries, azureCloudConfig);
    } catch (MalformedURLException | InterruptedException | ExecutionException ex) {
        logger.error("Error building ABS blob service client: {}", ex.getMessage());
        throw new IllegalStateException(ex);
    }
}
Also used : RequestRetryOptions(com.azure.storage.common.policy.RequestRetryOptions) MalformedURLException(java.net.MalformedURLException) Configuration(com.azure.core.util.Configuration) ProxyOptions(com.azure.core.http.ProxyOptions) InetSocketAddress(java.net.InetSocketAddress) HttpClient(com.azure.core.http.HttpClient) NettyAsyncHttpClientBuilder(com.azure.core.http.netty.NettyAsyncHttpClientBuilder) ExecutionException(java.util.concurrent.ExecutionException)

Example 2 with RequestRetryOptions

use of com.azure.storage.common.policy.RequestRetryOptions in project ambry by linkedin.

the class StorageClient method createBlobStorageAsyncClient.

/**
 * Create the {@link BlobServiceAsyncClient} object.
 * @param {@link CloudConfig} object.
 * @param {@link AzureCloudConfig} object.
 * @return {@link BlobServiceAsyncClient} object.
 */
protected BlobServiceAsyncClient createBlobStorageAsyncClient() {
    validateABSAuthConfigs(azureCloudConfig);
    Configuration storageConfiguration = new Configuration();
    // Check for network proxy
    ProxyOptions proxyOptions = (cloudConfig.vcrProxyHost == null) ? null : new ProxyOptions(ProxyOptions.Type.HTTP, new InetSocketAddress(cloudConfig.vcrProxyHost, cloudConfig.vcrProxyPort));
    if (proxyOptions != null) {
        logger.info("Using proxy: {}:{}", cloudConfig.vcrProxyHost, cloudConfig.vcrProxyPort);
    }
    HttpClient client = new NettyAsyncHttpClientBuilder().proxy(proxyOptions).build();
    // Note: retry decisions are made at CloudBlobStore level.  Configure storageClient with no retries.
    RequestRetryOptions noRetries = new RequestRetryOptions(RetryPolicyType.FIXED, 1, (Integer) null, null, null, null);
    try {
        return buildBlobServiceAsyncClient(client, storageConfiguration, noRetries, azureCloudConfig);
    } catch (MalformedURLException | InterruptedException | ExecutionException ex) {
        logger.error("Error building ABS blob service client: {}", ex.getMessage());
        throw new IllegalStateException(ex);
    }
}
Also used : RequestRetryOptions(com.azure.storage.common.policy.RequestRetryOptions) MalformedURLException(java.net.MalformedURLException) Configuration(com.azure.core.util.Configuration) ProxyOptions(com.azure.core.http.ProxyOptions) InetSocketAddress(java.net.InetSocketAddress) HttpClient(com.azure.core.http.HttpClient) NettyAsyncHttpClientBuilder(com.azure.core.http.netty.NettyAsyncHttpClientBuilder) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

HttpClient (com.azure.core.http.HttpClient)2 ProxyOptions (com.azure.core.http.ProxyOptions)2 NettyAsyncHttpClientBuilder (com.azure.core.http.netty.NettyAsyncHttpClientBuilder)2 Configuration (com.azure.core.util.Configuration)2 RequestRetryOptions (com.azure.storage.common.policy.RequestRetryOptions)2 InetSocketAddress (java.net.InetSocketAddress)2 MalformedURLException (java.net.MalformedURLException)2 ExecutionException (java.util.concurrent.ExecutionException)2