danielcweeks commented on code in PR #17457: URL: https://github.com/apache/iceberg/pull/17457#discussion_r3919025736
########## core/src/main/java/org/apache/iceberg/io/http/HttpUrlClient.java: ########## @@ -0,0 +1,265 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License 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 org.apache.iceberg.io.http; + +import java.io.Serializable; +import java.net.URI; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import org.apache.hc.client5.http.config.ConnectionConfig; +import org.apache.hc.client5.http.config.RequestConfig; +import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; +import org.apache.hc.client5.http.impl.classic.HttpClientBuilder; +import org.apache.hc.client5.http.impl.classic.HttpClients; +import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder; +import org.apache.hc.client5.http.io.HttpClientConnectionManager; +import org.apache.hc.core5.io.CloseMode; +import org.apache.iceberg.io.InputFile; +import org.apache.iceberg.metrics.MetricsContext; +import org.apache.iceberg.relocated.com.google.common.annotations.VisibleForTesting; +import org.apache.iceberg.relocated.com.google.common.base.Preconditions; +import org.apache.iceberg.relocated.com.google.common.collect.Maps; +import org.apache.iceberg.util.PropertyUtil; +import org.apache.iceberg.util.SerializableMap; + +/** + * A client that a {@link org.apache.iceberg.io.FileIO} can delegate to for reading a file directly + * over HTTP(S) instead of its normal, credentialed read path. + * + * <p>Intended for catalogs that vend a pre-signed object-store URL directly as a file's location + * (e.g. a scan task's {@code file-path}). The location is used unchanged as the fetch URL, so + * {@link InputFile#location()} equals the location passed to {@link #newInputFile(String, + * MetricsContext)}. + * + * <p>The underlying HTTP client's timeouts and connection pool are configurable through the + * properties passed to {@link #HttpUrlClient(Map)}. When a setting is not provided, the client + * falls back to JVM system properties and then to the Apache HttpClient defaults. + * + * <p>The chunk size used for sequential reads is configurable via {@value #READ_CHUNK_SIZE_BYTES}. + * When the property is not set, the default passed to {@link #HttpUrlClient(Map, int)} is used, + * letting a {@link org.apache.iceberg.io.FileIO} supply a value tuned for its backing object store. + */ +public class HttpUrlClient implements Serializable { Review Comment: This class doesn't make sense to me. We already have a HttpClient interface in the project and this seems to create a separate wrapper interface over a specific implementation. I don't think we should have this. The client can be initialized and held by the HttpInputFile class directly. This gives the impression that we need a separate standard way of building a client, but it doesn't abstract the underlying implementation and seems like an unnecessary and exposes things in a strange way. It's not actually an HTTP client and only eposes access to InputFile. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
