danielcweeks commented on code in PR #17457: URL: https://github.com/apache/iceberg/pull/17457#discussion_r4023064038
########## core/src/main/java/org/apache/iceberg/io/http/HttpInputFile.java: ########## @@ -0,0 +1,409 @@ +/* + * 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.IOException; +import java.net.URI; +import java.util.Locale; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import org.apache.hc.client5.http.classic.methods.HttpGet; +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.http.ClassicHttpResponse; +import org.apache.hc.core5.http.Header; +import org.apache.hc.core5.http.HttpHeaders; +import org.apache.iceberg.exceptions.ForbiddenException; +import org.apache.iceberg.exceptions.NotFoundException; +import org.apache.iceberg.exceptions.RuntimeIOException; +import org.apache.iceberg.io.InputFile; +import org.apache.iceberg.io.SeekableInputStream; +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.util.PropertyUtil; +import org.apache.iceberg.util.SerializableMap; + +/** + * An {@link InputFile} backed by an HTTP URL, typically a pre-signed object-store URL that encodes + * auth in its query parameters. + * + * <p>A known content length is returned directly; otherwise it is fetched lazily via a {@code GET + * Range: bytes=0-0} request, which (unlike HEAD) works with pre-signed GET URLs. + */ +public class HttpInputFile implements InputFile { + static final String CONNECTION_TIMEOUT_MS = "io.http.connection-timeout-ms"; + static final String SOCKET_TIMEOUT_MS = "io.http.socket-timeout-ms"; + static final String CONNECTION_ACQUISITION_TIMEOUT_MS = + "io.http.connection-acquisition-timeout-ms"; + static final String MAX_CONNECTIONS = "io.http.max-connections"; + static final String MAX_CONNECTIONS_PER_ROUTE = "io.http.connections-per-route"; + static final String READ_CHUNK_SIZE_BYTES = "io.http.read.chunk-size-bytes"; + static final int READ_CHUNK_SIZE_BYTES_DEFAULT = 8 * 1024 * 1024; + static final long UNKNOWN_LENGTH = -1L; + + private final SerializableMap<String, String> properties; + private final CloseableHttpClient client; Review Comment: I think I would actually suggest pulling the client and config up into a `BaseHttpFile` class. We're going to need the client for both `HttpInputFile` and `HttpOutputFile` when adding JIT pre-signing as an alternative to remote signing. I think that logic will likely live in the HttpInput/OutputFile implementations. -- 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]
