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


##########
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:
   I think this construct is coming from the old legacy connector:
   ```
   /**
    * An interface that abstracts away the Multi-Part Upload (MPU) 
functionality offered by S3, from
    * the specific implementation of the file system. This is needed so that we 
can accommodate both
    * Hadoop S3 and Presto.
    *
    * <p>Multipart uploads are convenient for large object. These will be 
uploaded in multiple parts
    * and the mutli-part upload is the equivalent of a transaction, where the 
upload with all its parts
    * will be either committed or discarded.
    */
   ```
   I'm not convinced that we should keep this pattern or at least with this 
name. If it's still responsible for MPU upload handling then we can name 
accordingly. Class named `...helper...` is always triggers "this class has no 
clear responsibility" which we can avoid since we have no constraints for now.



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