HDDS-13937. Make WithObjectID immutable#9327
Conversation
adoroszlai
left a comment
There was a problem hiding this comment.
Thanks @echonesis for the patch.
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/OmUtils.java
Outdated
Show resolved
Hide resolved
| /** Hook method, customized in subclasses. */ | ||
| public String getObjectInfo() { |
There was a problem hiding this comment.
getObjectInfo is overridden in value subclasses, but not in builders. What's more, value classes override toString(), but builders do not.
Probably worth a separate sub-task to keep patches from growing huge.
There was a problem hiding this comment.
Thanks @adoroszlai
I agree with you.
Could I create a subtask under HDDS-10519 since HDDS-13937 has already been a sub-task?
There was a problem hiding this comment.
I've created one sub-task, HDDS-13964, to handle this.
...-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/acl/OMBucketAclRequest.java
Outdated
Show resolved
Hide resolved
...one-manager/src/main/java/org/apache/hadoop/ozone/om/request/file/OMRecoverLeaseRequest.java
Show resolved
Hide resolved
...e/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMKeyCommitRequest.java
Show resolved
Hide resolved
...-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMKeyCommitRequestWithFSO.java
Show resolved
Hide resolved
...p-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMKeyRequest.java
Show resolved
Hide resolved
...java/org/apache/hadoop/ozone/om/request/s3/multipart/S3MultipartUploadCommitPartRequest.java
Outdated
Show resolved
Hide resolved
...n/java/org/apache/hadoop/ozone/om/request/s3/multipart/S3MultipartUploadCompleteRequest.java
Outdated
Show resolved
Hide resolved
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/om/PrefixParser.java
Show resolved
Hide resolved
adoroszlai
left a comment
There was a problem hiding this comment.
Thanks @echonesis for updating the patch.
| Map<String, String> metadataMap = omKeyInfo.toBuilder().getMetadata(); | ||
| metadataMap.putAll(KeyValueUtil.getFromProtobuf( | ||
| commitKeyArgs.getMetadataList())); | ||
| omKeyInfo = omKeyInfo.toBuilder() |
There was a problem hiding this comment.
Avoid duplicate toBuilder():
| Map<String, String> metadataMap = omKeyInfo.toBuilder().getMetadata(); | |
| metadataMap.putAll(KeyValueUtil.getFromProtobuf( | |
| commitKeyArgs.getMetadataList())); | |
| omKeyInfo = omKeyInfo.toBuilder() | |
| OmKeyInfo.Builder builder = omKeyInfo.toBuilder(); | |
| Map<String, String> metadataMap = builder.getMetadata(); | |
| metadataMap.putAll(KeyValueUtil.getFromProtobuf( | |
| commitKeyArgs.getMetadataList())); | |
| omKeyInfo = builder |
| newOmBucketInfo.setUpdateID(transactionLogIndex); | ||
| newOmBucketInfo = newOmBucketInfo.toBuilder() | ||
| .withUpdateID(transactionLogIndex) | ||
| .build(); |
There was a problem hiding this comment.
Please move .withUpdateID into existing builder chain:
| omKeyInfo = omKeyInfo.toBuilder() | ||
| .withUpdateID(trxnLogIndex) | ||
| .build(); |
There was a problem hiding this comment.
This updated omKeyInfo is not stored anywhere, so the updateID will be lost. We need to replace the item in the list.
| omKeyInfo = omKeyInfo.toBuilder() | ||
| .withUpdateID(trxnLogIndex) | ||
| .build(); |
There was a problem hiding this comment.
Same here, need to update dirList.
| dbKeyInfo = dbKeyInfo.toBuilder() | ||
| .withUpdateID(transactionLogIndex) | ||
| .build(); | ||
| dbKeyInfo.setReplicationConfig(replicationConfig); | ||
|
|
||
| // Construct a new metadata map from KeyArgs by rebuilding via toBuilder. |
There was a problem hiding this comment.
Please combine these two builders.
| Map<String, String> metaDataMap = omKeyInfo.toBuilder().getMetadata(); | ||
| metaDataMap.putAll(KeyValueUtil.getFromProtobuf( | ||
| commitKeyArgs.getMetadataList())); | ||
| omKeyInfo.setDataSize(commitKeyArgs.getDataSize()); | ||
|
|
||
| List<OmKeyLocationInfo> uncommitted = | ||
| omKeyInfo.updateLocationInfoList(locationInfoList, false); | ||
|
|
||
| // Set the UpdateID to current transactionLogIndex | ||
| omKeyInfo.setUpdateID(trxnLogIndex); | ||
| omKeyInfo = omKeyInfo.toBuilder() |
There was a problem hiding this comment.
Please avoid duplicate toBuilder().
|
Thanks @echonesis for updating the patch, 6506a7d looks good. a10e72a was unnecessary. This PR is already large, it does not need to move all mutations into the builder chains. |
OK, got it. I will revert to 6506a7d |
a10e72a to
6506a7d
Compare
|
Thanks @echonesis for the patch. |
|
Thanks @adoroszlai for the review and merge. |
What changes were proposed in this pull request?
This PR makes
WithObjectIDimmutable.Essential modifications:
@ImmutabletoWithObjectIDsetObjectIDandsetUpdateID. Instead, addBuilder.withObjectIDandBuilder.withUpdateIDto support the same logicWhat is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-13937
How was this patch tested?