Samrat002 commented on code in PR #27187:
URL: https://github.com/apache/flink/pull/27187#discussion_r2934624062


##########
flink-filesystems/flink-s3-fs-native/src/main/java/org/apache/flink/fs/s3native/NativeS3FileSystem.java:
##########
@@ -0,0 +1,582 @@
+/*
+ * 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.flink.fs.s3native;
+
+import org.apache.flink.core.fs.BlockLocation;
+import org.apache.flink.core.fs.EntropyInjectingFileSystem;
+import org.apache.flink.core.fs.FSDataInputStream;
+import org.apache.flink.core.fs.FSDataOutputStream;
+import org.apache.flink.core.fs.FileStatus;
+import org.apache.flink.core.fs.FileSystem;
+import org.apache.flink.core.fs.Path;
+import org.apache.flink.core.fs.PathsCopyingFileSystem;
+import org.apache.flink.core.fs.RecoverableWriter;
+import org.apache.flink.fs.s3native.writer.NativeS3AccessHelper;
+import org.apache.flink.fs.s3native.writer.NativeS3RecoverableWriter;
+import org.apache.flink.util.AutoCloseableAsync;
+import org.apache.flink.util.StringUtils;
+import org.apache.flink.util.concurrent.FutureUtils;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import software.amazon.awssdk.services.s3.S3Client;
+import software.amazon.awssdk.services.s3.model.CopyObjectRequest;
+import software.amazon.awssdk.services.s3.model.DeleteObjectRequest;
+import software.amazon.awssdk.services.s3.model.HeadObjectRequest;
+import software.amazon.awssdk.services.s3.model.HeadObjectResponse;
+import software.amazon.awssdk.services.s3.model.ListObjectsV2Request;
+import software.amazon.awssdk.services.s3.model.ListObjectsV2Response;
+import software.amazon.awssdk.services.s3.model.NoSuchKeyException;
+import software.amazon.awssdk.services.s3.model.S3Exception;
+import software.amazon.awssdk.services.s3.model.S3Object;
+
+import javax.annotation.Nullable;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ThreadLocalRandom;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+/**
+ * Native S3 FileSystem implementation using AWS SDK v2.
+ *
+ * <p>This file system uses an {@link AtomicBoolean} guard ({@code closed}) 
checked at the start of
+ * every public operation via {@link #checkNotClosed()}. The close lifecycle 
works as follows:
+ *
+ * <ul>
+ *   <li>New operations started after {@link #closeAsync()} will throw {@link
+ *       IllegalStateException}.
+ *   <li>Operations already past the {@code checkNotClosed()} barrier are 
allowed to complete
+ *       naturally. There is a small race window where an operation may pass 
the check just before
+ *       {@code closeAsync()} sets the flag. In this case, the operation 
either completes normally
+ *       (the underlying clients have not been torn down yet) or fails with an 
{@link IOException}
+ *       from the AWS SDK, which callers are already expected to handle.
+ *   <li>The {@link #closeAsync()} teardown sequence (bulkCopyHelper, 
transferManager, asyncClient,
+ *       syncClient) provides a natural grace period bounded by {@link 
#CLOSE_TIMEOUT_SECONDS}.
+ * </ul>
+ *
+ * <p>A thread-pool-routed approach would provide stricter guarantees but 
introduces latency
+ * overhead on every call and risks deadlocks from nested filesystem calls 
(e.g., {@code create()}
+ * calling {@code exists()} calling {@code getFileStatus()}).
+ *
+ * <p><b>Permission Considerations:</b> Some operations require specific IAM 
permissions:
+ *
+ * <ul>
+ *   <li>{@link #getFileStatus}: Returns 403 for non-existent objects if 
ListBucket permission is
+ *       not granted (to prevent object enumeration)
+ *   <li>{@link #listStatus}: Requires ListBucket permission
+ *   <li>{@link #delete}: With only DeleteObject permission, deleting 
non-existent objects may
+ *       return errors
+ * </ul>
+ */
+public class NativeS3FileSystem extends FileSystem

Review Comment:
   Removing the public is good. I confirmed via LLM that this class isn't 
instantiated via reflection, so we don't need the wider access.



-- 
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]

Reply via email to