use of com.azure.core.http.netty.NettyAsyncHttpClientBuilder 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);
}
}
use of com.azure.core.http.netty.NettyAsyncHttpClientBuilder in project ambry by linkedin.
the class AzureUtils method getClientSecretCredential.
/**
* @param azureCloudConfig the {@link AzureCloudConfig} to source credential configs from.
* @return the {@link ClientSecretCredential}.
*/
static ClientSecretCredential getClientSecretCredential(AzureCloudConfig azureCloudConfig) {
ClientSecretCredentialBuilder builder = new ClientSecretCredentialBuilder().tenantId(azureCloudConfig.azureIdentityTenantId).clientId(azureCloudConfig.azureIdentityClientId).clientSecret(azureCloudConfig.azureIdentitySecret);
if (!azureCloudConfig.azureIdentityProxyHost.isEmpty()) {
logger.info("Using proxy for ClientSecretCredential: {}:{}", azureCloudConfig.azureIdentityProxyHost, azureCloudConfig.azureIdentityProxyPort);
ProxyOptions proxyOptions = new ProxyOptions(ProxyOptions.Type.HTTP, new InetSocketAddress(azureCloudConfig.azureIdentityProxyHost, azureCloudConfig.azureIdentityProxyPort));
HttpClient httpClient = new NettyAsyncHttpClientBuilder().proxy(proxyOptions).build();
builder.httpClient(httpClient);
}
return builder.build();
}
use of com.azure.core.http.netty.NettyAsyncHttpClientBuilder 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);
}
}
Aggregations