From c94237231f9d3613731fced9fae25309e568ce1c Mon Sep 17 00:00:00 2001 From: Charles Morgan Date: Wed, 30 Aug 2023 13:12:58 -0700 Subject: [PATCH] Use OkHttp client in AzureFileSystem Switch to using the OkHttp client for the AzureFileSystem as it is lighter weight and serves the same purpose as the netty http client that is currently being used --- lib/trino-filesystem-azure/pom.xml | 25 +++++++++++++++++++ .../azure/AzureFileSystemFactory.java | 7 +++--- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/lib/trino-filesystem-azure/pom.xml b/lib/trino-filesystem-azure/pom.xml index d892123f8c72..39f09131d4ad 100644 --- a/lib/trino-filesystem-azure/pom.xml +++ b/lib/trino-filesystem-azure/pom.xml @@ -29,10 +29,19 @@ + + com.azure + azure-core-http-okhttp + + com.azure azure-identity + + com.azure + azure-core-http-netty + com.nimbusds oauth2-oidc-sdk @@ -48,6 +57,10 @@ com.azure azure-storage-blob + + com.azure + azure-core-http-netty + com.fasterxml.jackson.dataformat jackson-dataformat-xml @@ -58,11 +71,23 @@ com.azure azure-storage-common + + + com.azure + azure-core-http-netty + + com.azure azure-storage-file-datalake + + + com.azure + azure-core-http-netty + + diff --git a/lib/trino-filesystem-azure/src/main/java/io/trino/filesystem/azure/AzureFileSystemFactory.java b/lib/trino-filesystem-azure/src/main/java/io/trino/filesystem/azure/AzureFileSystemFactory.java index f625fb1d320f..ea6345760993 100644 --- a/lib/trino-filesystem-azure/src/main/java/io/trino/filesystem/azure/AzureFileSystemFactory.java +++ b/lib/trino-filesystem-azure/src/main/java/io/trino/filesystem/azure/AzureFileSystemFactory.java @@ -14,6 +14,8 @@ package io.trino.filesystem.azure; import com.azure.core.http.HttpClient; +import com.azure.core.http.okhttp.OkHttpAsyncClientProvider; +import com.azure.core.util.HttpClientOptions; import com.google.inject.Inject; import io.airlift.units.DataSize; import io.trino.filesystem.TrinoFileSystem; @@ -26,14 +28,12 @@ public class AzureFileSystemFactory implements TrinoFileSystemFactory { - // All file systems share a single HTTP client - private final HttpClient httpClient = HttpClient.createDefault(); - private final AzureAuth auth; private final DataSize readBlockSize; private final DataSize writeBlockSize; private final int maxWriteConcurrency; private final DataSize maxSingleUploadSize; + private final HttpClient httpClient; @Inject public AzureFileSystemFactory(AzureAuth azureAuth, AzureFileSystemConfig config) @@ -54,6 +54,7 @@ public AzureFileSystemFactory(AzureAuth azureAuth, DataSize readBlockSize, DataS checkArgument(maxWriteConcurrency >= 0, "maxWriteConcurrency is negative"); this.maxWriteConcurrency = maxWriteConcurrency; this.maxSingleUploadSize = requireNonNull(maxSingleUploadSize, "maxSingleUploadSize is null"); + this.httpClient = HttpClient.createDefault(new HttpClientOptions().setHttpClientProvider(OkHttpAsyncClientProvider.class)); } @Override