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


##########
flink-filesystems/flink-s3-fs-native/src/main/java/org/apache/flink/fs/s3native/writer/NativeS3AccessHelper.java:
##########
@@ -0,0 +1,575 @@
+/*
+ * 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.writer;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.core.fs.Path;
+import org.apache.flink.fs.s3native.S3EncryptionConfig;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import software.amazon.awssdk.core.sync.RequestBody;
+import software.amazon.awssdk.core.sync.ResponseTransformer;
+import software.amazon.awssdk.services.s3.S3AsyncClient;
+import software.amazon.awssdk.services.s3.S3Client;
+import software.amazon.awssdk.services.s3.model.AbortMultipartUploadRequest;
+import software.amazon.awssdk.services.s3.model.CompleteMultipartUploadRequest;
+import 
software.amazon.awssdk.services.s3.model.CompleteMultipartUploadResponse;
+import software.amazon.awssdk.services.s3.model.CompletedMultipartUpload;
+import software.amazon.awssdk.services.s3.model.CompletedPart;
+import software.amazon.awssdk.services.s3.model.CreateMultipartUploadRequest;
+import software.amazon.awssdk.services.s3.model.CreateMultipartUploadResponse;
+import software.amazon.awssdk.services.s3.model.DeleteObjectRequest;
+import software.amazon.awssdk.services.s3.model.GetObjectRequest;
+import software.amazon.awssdk.services.s3.model.GetObjectResponse;
+import software.amazon.awssdk.services.s3.model.HeadObjectRequest;
+import software.amazon.awssdk.services.s3.model.HeadObjectResponse;
+import software.amazon.awssdk.services.s3.model.NoSuchUploadException;
+import software.amazon.awssdk.services.s3.model.PutObjectRequest;
+import software.amazon.awssdk.services.s3.model.PutObjectResponse;
+import software.amazon.awssdk.services.s3.model.S3Exception;
+import software.amazon.awssdk.services.s3.model.UploadPartRequest;
+import software.amazon.awssdk.services.s3.model.UploadPartResponse;
+import software.amazon.awssdk.transfer.s3.S3TransferManager;
+import software.amazon.awssdk.transfer.s3.model.CompletedFileUpload;
+import software.amazon.awssdk.transfer.s3.model.FileUpload;
+import software.amazon.awssdk.transfer.s3.model.UploadFileRequest;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.stream.Collectors;
+
+/**
+ * Helper class for S3 operations including multipart uploads, object storage, 
and retrieval.
+ *
+ * <p><b>Retry Handling:</b> This class relies on the AWS SDK's built-in retry 
mechanism which is
+ * configured in {@link org.apache.flink.fs.s3native.S3ClientProvider}. The 
SDK automatically
+ * handles retries for transient errors including:
+ *
+ * <ul>
+ *   <li>5xx server errors (including S3 throttling which manifests as 503 
Service Unavailable)
+ *   <li>Network timeouts and connection errors
+ *   <li>Request timeouts
+ * </ul>
+ *
+ * <p>Terminal (non-retriable) errors include:
+ *
+ * <ul>
+ *   <li>4xx client errors (400 Bad Request, 403 Forbidden, 404 Not Found)
+ *   <li>Authentication/authorization failures
+ *   <li>Invalid bucket or key names
+ * </ul>
+ *
+ * <p><b>Encryption Support:</b> Currently supports SSE-S3 and SSE-KMS 
encryption modes. The
+ * encryption logic is applied through the {@link S3EncryptionConfig} class. 
Future enhancements may
+ * include:
+ *
+ * <ul>
+ *   <li>SSE-C (customer-provided keys) via a KeyProvider interface
+ *   <li>Client-side encryption via an EncryptionHandler interface
+ *   <li>Encryption context for SSE-KMS (see HADOOP-19197)
+ * </ul>
+ *
+ * <p><b>S3 URI Handling:</b> The {@link #extractKey(Path)} and {@link 
#extractBucketName(Path)}
+ * methods expect URIs in the standard {@code s3://bucket/key} format. Other 
formats like path-style
+ * ({@code https://s3.amazonaws.com/bucket/key}) or virtual-hosted-style 
({@code
+ * https://bucket.s3.amazonaws.com/key}) are not currently supported.
+ */
+@Internal
+public class NativeS3AccessHelper {

Review Comment:
    You're right that the ...Helper name is carried over from the legacy 
S3AccessHelper interface in flink-s3-fs-base, which existed to abstract MPU 
operations across the Hadoop and Presto backends. That abstraction rationale 
doesn't apply in the native connector. we have a single concrete implementation 
targeting the AWS SDK v2 directly.
    
   Looking at what the class actually does, it has a fairly coherent 
responsibility: 
   1. it's an S3 object operations facade wrapping the raw SDK client with 
encryption, 
   2. error handling, 
   3. Flink URI parsing. 
   
   The name just doesn't reflect that.
    
   I'll rename it to `NativeS3ObjectOperations` (open to alternatives -- 
`NativeS3ObjectStore` is another option). The static URI utilities 
(extractKey/extractBucketName) could also be extracted into a separate 
NativeS3PathUtils since they're used independently by NativeS3FileSystem, but 
I'd prefer to do that as a follow-up to keep this change focused.



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