[ 
https://issues.apache.org/jira/browse/HDDS-1942?focusedWorklogId=295865&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-295865
 ]

ASF GitHub Bot logged work on HDDS-1942:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 15/Aug/19 23:16
            Start Date: 15/Aug/19 23:16
    Worklog Time Spent: 10m 
      Work Description: bharatviswa504 commented on pull request #1279: 
HDDS-1942. Support copy during S3 multipart upload part creation
URL: https://github.com/apache/hadoop/pull/1279#discussion_r314534295
 
 

 ##########
 File path: 
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/ObjectEndpoint.java
 ##########
 @@ -553,12 +555,45 @@ private Response createMultipartKey(String bucket, 
String key, long length,
       OzoneBucket ozoneBucket = getBucket(bucket);
       OzoneOutputStream ozoneOutputStream = ozoneBucket.createMultipartKey(
           key, length, partNumber, uploadID);
-      IOUtils.copy(body, ozoneOutputStream);
+
+      String copyHeader = headers.getHeaderString(COPY_SOURCE_HEADER);
+      if (copyHeader != null) {
+        Pair<String, String> result = parseSourceHeader(copyHeader);
+
+        String sourceBucket = result.getLeft();
+        String sourceKey = result.getRight();
+
+        try (OzoneInputStream sourceObject =
+            getBucket(sourceBucket).readKey(sourceKey)) {
+
+          String range =
+              headers.getHeaderString(COPY_SOURCE_HEADER_RANGE);
+          if (range != null) {
+            RangeHeader rangeHeader =
+                RangeHeaderParserUtil.parseRangeHeader(range, 0);
+            IOUtils.copyLarge(sourceObject, ozoneOutputStream,
+                rangeHeader.getStartOffset(),
+                rangeHeader.getEndOffset() - rangeHeader.getStartOffset());
+
+          } else {
+            IOUtils.copy(sourceObject, ozoneOutputStream);
+          }
+        }
+
+      } else {
+        IOUtils.copy(body, ozoneOutputStream);
+      }
       ozoneOutputStream.close();
       OmMultipartCommitUploadPartInfo omMultipartCommitUploadPartInfo =
           ozoneOutputStream.getCommitUploadPartInfo();
-      return Response.status(Status.OK).header("ETag",
-          omMultipartCommitUploadPartInfo.getPartName()).build();
+      String eTag = omMultipartCommitUploadPartInfo.getPartName();
+
+      if (copyHeader != null) {
+        return Response.ok(new CopyPartResult(eTag)).build();
 
 Review comment:
   CopyPartResult from the documentation has 2 fields etag and LastModified. 
Here we are not setting lastModified.
 
----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 295865)
    Time Spent: 40m  (was: 0.5h)

> Support copy during S3 multipart upload part creation
> -----------------------------------------------------
>
>                 Key: HDDS-1942
>                 URL: https://issues.apache.org/jira/browse/HDDS-1942
>             Project: Hadoop Distributed Data Store
>          Issue Type: Sub-task
>          Components: S3
>            Reporter: Elek, Marton
>            Assignee: Elek, Marton
>            Priority: Blocker
>              Labels: pull-request-available
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> Uploads a part by copying data from an existing object as data source
> Documented here:
> https://docs.aws.amazon.com/AmazonS3/latest/API/mpUploadUploadPartCopy.html



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)

---------------------------------------------------------------------
To unsubscribe, e-mail: hdfs-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: hdfs-issues-h...@hadoop.apache.org

Reply via email to