-
Notifications
You must be signed in to change notification settings - Fork 613
HDDS-15182. [STS] Remove latent extra read on CopyObject api - make CopyPart work similarly #10203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: HDDS-13323-sts
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,8 @@ | |
|
|
||
| package org.apache.hadoop.ozone.om.helpers; | ||
|
|
||
| import java.util.OptionalLong; | ||
|
|
||
| /** | ||
| * This class holds information about the response from commit multipart | ||
| * upload part request. | ||
|
|
@@ -27,9 +29,16 @@ public class OmMultipartCommitUploadPartInfo { | |
|
|
||
| private final String eTag; | ||
|
|
||
| private final Long modificationTime; | ||
|
|
||
| public OmMultipartCommitUploadPartInfo(String partName, String eTag) { | ||
| this(partName, eTag, null); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove this constructor if it's not used anymore. |
||
| } | ||
|
|
||
| public OmMultipartCommitUploadPartInfo(String partName, String eTag, Long modificationTime) { | ||
| this.partName = partName; | ||
| this.eTag = eTag; | ||
| this.modificationTime = modificationTime; | ||
| } | ||
|
|
||
| public String getETag() { | ||
|
|
@@ -39,4 +48,8 @@ public String getETag() { | |
| public String getPartName() { | ||
| return partName; | ||
| } | ||
|
|
||
| public OptionalLong getModificationTime() { | ||
| return modificationTime == null ? OptionalLong.empty() : OptionalLong.of(modificationTime); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ | |
| import java.io.IOException; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.OptionalLong; | ||
| import java.util.UUID; | ||
| import org.apache.hadoop.fs.SafeModeAction; | ||
| import org.apache.hadoop.hdds.scm.container.common.helpers.ExcludeList; | ||
|
|
@@ -252,6 +253,17 @@ default void commitKey(OmKeyArgs args, long clientID) | |
| "this to be implemented, as write requests use a new approach."); | ||
| } | ||
|
|
||
| /** | ||
| * Commit a key and optionally return the stored modification time (epoch millis). | ||
| * <p> | ||
| * This is backward compatible with older OM versions which do not return | ||
| * the value in {@code CommitKeyResponse}. | ||
| */ | ||
| default OptionalLong commitKeyWithModificationTime(OmKeyArgs args, long clientID) throws IOException { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like that LastModified element is a mandatory part of CopyObject and UploadPartCopy. https://docs.aws.amazon.com/AmazonS3/latest/API/API_CopyObject.html So without this patch, Ozone now returns incorrect LastModified? Since there is already lastModified field in CopyObjectResponse and CopyPartResult. Since it's mandatory for S3, we don't need to maintain both commitKeyWithModificationTime and commitKey, update commitKey to return long, instead of OptionalLong, making sure lastModified is returned after a successful commit, so we can get a clean logic and code.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There were two cases previously per my understanding:
For both these cases, the patch now returns the actual lastModified that was set at the time the key was committed in the response itself so that a) no extra fetch is needed and b) it is more accurate
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
@ChenSammi - would this be a breaking api change to commitKey for older clients or mixed client versions? |
||
| commitKey(args, clientID); | ||
| return OptionalLong.empty(); | ||
| } | ||
|
|
||
| /** | ||
| * Synchronize the key length. This will make the change from the client | ||
| * visible. The client is identified by the clientID. | ||
|
|
@@ -1146,7 +1158,6 @@ default CancelPrepareResponse cancelOzoneManagerPrepare() throws IOException { | |
| EchoRPCResponse echoRPCReq(byte[] payloadReq, int payloadSizeResp, | ||
| boolean writeToRatis) throws IOException; | ||
|
|
||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can be reverted. |
||
| /** | ||
| * Start the lease recovery of a file. | ||
| * | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,8 +46,12 @@ public CopyPartResult() { | |
| } | ||
|
|
||
| public CopyPartResult(String eTag) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove this constructor if it's not used anymore. |
||
| this(eTag, Instant.now()); | ||
| } | ||
|
|
||
| public CopyPartResult(String eTag, Instant lastModified) { | ||
| this.eTag = eTag; | ||
| this.lastModified = Instant.now(); | ||
| this.lastModified = lastModified; | ||
| } | ||
|
|
||
| public Instant getLastModified() { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| /* | ||
| * 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.hadoop.ozone.s3.endpoint; | ||
|
|
||
| /** | ||
| * Result of a copy operation. | ||
| */ | ||
| public class CopyResult { | ||
| private final String eTag; | ||
| private final long size; | ||
| private final long modificationTime; | ||
|
|
||
| public CopyResult(String eTag, long size, long modificationTime) { | ||
| this.eTag = eTag; | ||
| this.size = size; | ||
| this.modificationTime = modificationTime; | ||
| } | ||
|
|
||
| public String getETag() { | ||
| return eTag; | ||
| } | ||
|
|
||
| public long getSize() { | ||
| return size; | ||
| } | ||
|
|
||
| public long getModificationTime() { | ||
| return modificationTime; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
metadata is to persist in OM DB, a different goal. Please add a new field for LastModified value.