You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by GitBox <gi...@apache.org> on 2019/08/21 09:09:16 UTC

[GitHub] [hadoop] elek commented on a change in pull request #1279: HDDS-1942. Support copy during S3 multipart upload part creation

elek commented on a change in pull request #1279: HDDS-1942. Support copy during S3 multipart upload part creation
URL: https://github.com/apache/hadoop/pull/1279#discussion_r316076135
 
 

 ##########
 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:
   It is set in the constructor:
   
   ```java
     public CopyPartResult(String eTag) {
       this.eTag = eTag;
       this.lastModified = Instant.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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org