talatuyarer commented on code in PR #16258:
URL: https://github.com/apache/iceberg/pull/16258#discussion_r3211937764
##########
gcp/src/main/java/org/apache/iceberg/gcp/gcs/PrefixedStorage.java:
##########
@@ -115,23 +114,33 @@ public void close() {
}
}
+ if (null != gcsFileSystem) {
+ AnalyticsCoreUtil.close(gcsFileSystem);
+ gcsFileSystem = null;
+ }
+
if (null != storage) {
// GCS Storage does not appear to be closable, so release the reference
storage = null;
}
}
- GcsFileSystem gcsFileSystem() {
+ Object gcsFileSystem() {
Review Comment:
Done
##########
gcp/src/main/java/org/apache/iceberg/gcp/gcs/BaseGCSFile.java:
##########
@@ -28,15 +27,15 @@
abstract class BaseGCSFile {
private final Storage storage;
- private final GcsFileSystem gcsFileSystem;
Review Comment:
Done
##########
gcp/src/main/java/org/apache/iceberg/gcp/gcs/AnalyticsCoreUtil.java:
##########
@@ -0,0 +1,92 @@
+/*
+ * 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.gcp.gcs;
+
+import com.google.auth.Credentials;
+import com.google.cloud.gcs.analyticscore.client.GcsFileInfo;
+import com.google.cloud.gcs.analyticscore.client.GcsFileSystem;
+import com.google.cloud.gcs.analyticscore.client.GcsFileSystemImpl;
+import com.google.cloud.gcs.analyticscore.client.GcsFileSystemOptions;
+import com.google.cloud.gcs.analyticscore.client.GcsItemId;
+import com.google.cloud.gcs.analyticscore.client.GcsItemInfo;
+import com.google.cloud.gcs.analyticscore.core.GcsAnalyticsCoreOptions;
+import com.google.cloud.gcs.analyticscore.core.GoogleCloudStorageInputStream;
+import com.google.cloud.storage.BlobId;
+import java.io.IOException;
+import java.net.URI;
+import java.util.Map;
+import org.apache.iceberg.io.SeekableInputStream;
+import org.apache.iceberg.metrics.MetricsContext;
+import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
+
+/**
+ * Gateway to the optional {@code com.google.cloud.gcs.analyticscore.*}
dependency. All references
+ * to analytics-core types are confined to this class so that it is loaded
only when {@link
+ * org.apache.iceberg.gcp.GCPProperties#GCS_ANALYTICS_CORE_ENABLED} is true.
+ */
+class AnalyticsCoreUtil {
+
+ private AnalyticsCoreUtil() {}
+
+ static Object createFileSystem(Map<String, String> properties, Credentials
credentials) {
+ GcsAnalyticsCoreOptions options = new GcsAnalyticsCoreOptions("gcs.",
properties);
Review Comment:
Done
##########
gcp/src/main/java/org/apache/iceberg/gcp/gcs/PrefixedStorage.java:
##########
@@ -59,6 +55,11 @@ class PrefixedStorage implements AutoCloseable {
this.storagePrefix = storagePrefix;
this.storage = storage;
this.gcpProperties = new GCPProperties(properties);
+ this.propertiesWithUserAgent =
+ ImmutableMap.<String, String>builder()
+ .putAll(properties)
+ .put("gcs.user-agent", GCS_FILE_IO_USER_AGENT)
+ .build();
Review Comment:
A collision can only happen if a caller pokes at undocumented analytics-core
keys directly via the GCSFileIO property map. That's possible (the property map
is open) but not on any documented or supported surface. Keep the current
build() for this PR since making it buildKeepingLast() is a behavior change for
an undocumented edge case, and I can add this change improvement PR.
##########
gcp/src/main/java/org/apache/iceberg/gcp/gcs/PrefixedStorage.java:
##########
@@ -45,11 +41,11 @@ class PrefixedStorage implements AutoCloseable {
private static final String GCS_FILE_IO_USER_AGENT = "gcsfileio/" +
EnvironmentContext.get();
private final String storagePrefix;
private final GCPProperties gcpProperties;
+ private final Map<String, String> propertiesWithUserAgent;
private SerializableSupplier<Storage> storage;
private CloseableGroup closeableGroup;
private transient volatile Storage storageClient;
Review Comment:
I dont want to increase scope of work in this PR. I agree this is good
improvement. I can create followup PR to address this
--
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]