HDDS-14660. Implement new table to store part information for multipart uploads#9886
HDDS-14660. Implement new table to store part information for multipart uploads#9886spacemonkd wants to merge 7 commits intoapache:masterfrom
Conversation
| OmMultipartKeyInfo.getCodec()); | ||
|
|
||
| public static final String MULTIPART_PARTS_TABLE = "multipartPartsTable"; | ||
| /** multipartPartsTable: /uploadId/partNumber :- PartKeyInfo. */ |
There was a problem hiding this comment.
The key is "/volume/bucket/key/uploadId/partNumber" in Column Family comments, while it's "/uploadId/partNumber" here. What's the real key format?
There was a problem hiding this comment.
Sorry, need to update the comment.
It is actually uploadId/part number.
The multipartInfo table is one with vol/buck/key/uploadID
There was a problem hiding this comment.
Can remove the /, /uploadId/partNumber -> uploadId/partNumber
ivandika3
left a comment
There was a problem hiding this comment.
Thanks @spacemonkd for the patch, overall LGTM. Left some comments,
| OmMultipartKeyInfo.getCodec()); | ||
|
|
||
| public static final String MULTIPART_PARTS_TABLE = "multipartPartsTable"; | ||
| /** multipartPartsTable: /uploadId/partNumber :- PartKeyInfo. */ |
There was a problem hiding this comment.
Can remove the /, /uploadId/partNumber -> uploadId/partNumber
|
|
||
| private Table<String, OmKeyInfo> openKeyTable; | ||
| private Table<String, OmMultipartKeyInfo> multipartInfoTable; | ||
| private Table<OmMultipartPartKey, OmMultipartPartInfo> multipartPartTable; |
There was a problem hiding this comment.
Nit: Standardize to multipartPartsTable. Similarly for getMultipartPartTable.
There was a problem hiding this comment.
Addressed in the latest commit.
| if (omMultipartKeyInfo.getSchemaVersion() == 0) { | ||
| numParts += omMultipartKeyInfo.getPartKeyInfoMap().size(); | ||
| } else { | ||
| OmMultipartPartKey prefix = | ||
| OmMultipartPartKey.prefix(expiredMultipartUpload.getUploadId()); | ||
| try (TableIterator<OmMultipartPartKey, ? extends KeyValue<OmMultipartPartKey, OmMultipartPartInfo>> | ||
| partIterator = getMultipartPartTable().iterator(prefix)) { | ||
| while (partIterator.hasNext()) { | ||
| KeyValue<OmMultipartPartKey, OmMultipartPartInfo> partEntry = | ||
| partIterator.next(); | ||
| if (!expiredMultipartUpload.getUploadId().equals( | ||
| partEntry.getKey().getUploadId())) { | ||
| break; | ||
| } | ||
| numParts++; | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Since this is not tested yet (we are still creating schemaVersion 0 MPU), let's exclude this first and add this once the MPU flow patches are done and listParts behaving normally.
There was a problem hiding this comment.
Addressed this in the latest commit.
I have commented out this part and added a TODO in case I forget about the changes 😅
Will just uncomment the section after the actual request and response modifications are done
| public static OmMultipartPartKey of(String uploadId, int partNumber) { | ||
| return new OmMultipartPartKey(uploadId, partNumber); | ||
| } |
There was a problem hiding this comment.
Should we also use the boxed Integer instead? If we pass null Integer here, it might throw NPE. We should also always use this static constructor and not normal constructor (in fromPersistedFormat)
There was a problem hiding this comment.
Changed it to use Integer and validate that Integer is nonnull in the latest commit.
Also using prefix() and of() methods to return the values instead of direct constructor calls in fromPersistedFormat()
| private static final class OmMultipartPartKeyCodec | ||
| implements Codec<OmMultipartPartKey> { |
There was a problem hiding this comment.
We can support CodecBuffer to prevent buffer copying, should be able to be addressed here, but can raise in another ticket (under HDDS-2274) if you prefer.
There was a problem hiding this comment.
Implemented this in the current change itself, added new tests to validate that the change is working fine.
What changes were proposed in this pull request?
HDDS-14660. Implement new table to store part information for multipart uploads
Please describe your PR in detail:
multipartPartsTableto handle storing of parts for Multipart Uploads.How is the PartKey encoded?
Say for the below sample input (we are taking 47 as it has 2F in the lower byte):
Encoding format:
keyBytes =
UTF8(uploadId)+/+int32_be(partNumber)For 47:
int32 big-endian bytes =
00 00 00 2fSo final tail is:
2f00 00 00 2f2f 00 00 00 2fNow we run the following checks:
A logical key will look something like the following in the RocksDB entry:
and will be represented as:
What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-14660
How was this patch tested?
Patch has been tested by running unit tests.