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


##########
flink-filesystems/flink-s3-fs-native/src/main/java/org/apache/flink/fs/s3native/NativeS3BulkCopyHelper.java:
##########
@@ -70,10 +74,37 @@ class NativeS3BulkCopyHelper {
 
     private final S3TransferManager transferManager;
     private final int maxConcurrentCopies;
+    private final int maxConnections;
 
-    public NativeS3BulkCopyHelper(S3TransferManager transferManager, int 
maxConcurrentCopies) {
+    /**
+     * Creates a new bulk copy helper.
+     *
+     * @param transferManager the S3 transfer manager for async downloads
+     * @param maxConcurrentCopies the requested maximum number of concurrent 
copy operations
+     * @param maxConnections the HTTP connection pool size; if {@code 
maxConcurrentCopies} exceeds
+     *     this value, it is clamped down to prevent connection pool exhaustion
+     */
+    NativeS3BulkCopyHelper(
+            S3TransferManager transferManager, int maxConcurrentCopies, int 
maxConnections) {
+        checkArgument(maxConcurrentCopies > 0, "maxConcurrentCopies must be 
positive");
+        checkArgument(maxConnections > 0, "maxConnections must be positive");
         this.transferManager = transferManager;
-        this.maxConcurrentCopies = maxConcurrentCopies;
+        this.maxConnections = maxConnections;
+        if (maxConcurrentCopies > maxConnections) {
+            LOG.warn(
+                    "s3.bulk-copy.max-concurrent ({}) exceeds 
s3.connection.max ({}). "
+                            + "Clamping concurrent copies to {} to prevent 
connection pool exhaustion.",

Review Comment:
   Thanks for the review. @davidradl 
   
   > I suggest saying limiting rather thanclamping as it is clearer.
   
   "clamping" is the standard CS term for bounding a value to a range ( 
`Math.clamp()` in Java 21), and this codebase already uses it in the same file 
at                                                                              
                                                                                
   
   
https://github.com/apache/flink/blob/b0ea378c64d/flink-filesystems/flink-s3-fs-native/src/main/java/org/apache/flink/fs/s3native/NativeS3FileSystemFactory.java#L338:
 
   
   
   ```
   // Validate 
     and clamp read buffer size to sensible range".
   ```
   
    I'd prefer to keep the term consistent with the existing codebase usage. 
   
   
   > I suggest calling the maxConcurrentCopies requestedMaxConcurrentCopies and 
maybe you could change the getter to getMaxConcurrentCopies. I do not think the 
caller needs to be aware that this is effective.
   
   the @param Javadoc already documents it as "the requested maximum", so 
keeping the concise maxConcurrentCopies avoids verbosity in the internal API. 
However, agreed on the getter rename is much better. I have updated to 
`getMaxConcurrentCopies()`.  



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