fmorg-git commented on code in PR #10197:
URL: https://github.com/apache/ozone/pull/10197#discussion_r3399812015


##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/ObjectEndpoint.java:
##########
@@ -889,52 +890,55 @@ private Response createMultipartKey(OzoneVolume volume, 
OzoneBucket ozoneBucket,
                       + rangeHeader.getStartOffset() + " actual: " + skipped);
             }
           }
-          try (OzoneOutputStream ozoneOutputStream = getClientProtocol()
-              .createMultipartKey(volume.getName(), bucketName, key, length,
-                  partNumber, uploadID)) {
-            metadataLatencyNs =
-                getMetrics().updateCopyKeyMetadataStats(startNanos);
-            copyLength = IOUtils.copyLarge(sourceObject, ozoneOutputStream, 0, 
length,
-                new byte[getIOBufferSize(length)]);
-            ozoneOutputStream.getMetadata()
-                .putAll(sourceKeyDetails.getMetadata());
-            String raw = ozoneOutputStream.getMetadata().get(OzoneConsts.ETAG);
-            if (raw != null) {
-              ozoneOutputStream.getMetadata().put(OzoneConsts.ETAG, 
stripQuotes(raw));
+          final long finalLength = length;
+          final long bytesToCopy = length;
+          omMultipartCommitUploadPartInfo = runWithS3ActionString("PutObject", 
() -> {
+            final OzoneOutputStream ozoneOutputStream = 
getClientProtocol().createMultipartKey(
+                volume.getName(), bucketName, key, finalLength, partNumber, 
uploadID);
+            try (OzoneOutputStream ignored = ozoneOutputStream) {
+              metadataLatencyHolder[0] = 
getMetrics().updateCopyKeyMetadataStats(startNanos);
+              copyLengthHolder[0] = IOUtils.copyLarge(
+                  sourceObject, ozoneOutputStream, 0, bytesToCopy, new 
byte[getIOBufferSize(bytesToCopy)]);
+              ozoneOutputStream.getMetadata()
+                  .putAll(sourceKeyDetails.getMetadata());
+              final String raw = 
ozoneOutputStream.getMetadata().get(OzoneConsts.ETAG);
+              if (raw != null) {
+                ozoneOutputStream.getMetadata().put(OzoneConsts.ETAG, 
stripQuotes(raw));
+              }
             }
-            outputStream = ozoneOutputStream;
-          }
-          getMetrics().incCopyObjectSuccessLength(copyLength);
-          perf.appendSizeBytes(copyLength);
+            return ozoneOutputStream.getCommitUploadPartInfo();
+          });
+          metadataLatencyNs = metadataLatencyHolder[0];
+          getMetrics().incCopyObjectSuccessLength(copyLengthHolder[0]);
+          perf.appendSizeBytes(copyLengthHolder[0]);
         }
       } else {
-        long putLength;
-        try (OzoneOutputStream ozoneOutputStream = getClientProtocol()
+        final long putLength;
+        final OzoneOutputStream ozoneOutputStream = getClientProtocol()

Review Comment:
   Actually, here is the reason "PutObject" is not missed here.  In this `else` 
branch of the code, the request action is set to 
`S3GAction.CREATE_MULTIPART_KEY` and this has a mapping in `S3GActionIamMapper` 
to "PutObject", so it's covered.  In the `if` branch of the code, the request 
action is set to `S3GAction.CREATE_MULTIPART_KEY_BY_COPY` which is mapped to 
null in `S3GActionIamMapper` (by design, since it needs "GetObject" on the 
source and "PutObject" on the destination.)
   
   Also, the ozoneOutputStream is closed on line 920 in the 
`try-with-resources` block.



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

Reply via email to