adoroszlai commented on code in PR #9327:
URL: https://github.com/apache/ozone/pull/9327#discussion_r2547067264
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMKeyCommitRequest.java:
##########
@@ -301,19 +301,22 @@ public OMClientResponse
validateAndUpdateCache(OzoneManager ozoneManager, Execut
// not persisted in the key table.
omKeyInfo.setExpectedDataGeneration(null);
- omKeyInfo = omKeyInfo.withMetadataMutations(metadata ->
- metadata.putAll(KeyValueUtil.getFromProtobuf(
- commitKeyArgs.getMetadataList())));
+ // Combination
+ // Set the UpdateID to current transactionLogIndex
+ Map<String, String> metadataMap = omKeyInfo.toBuilder().getMetadata();
+ metadataMap.putAll(KeyValueUtil.getFromProtobuf(
+ commitKeyArgs.getMetadataList()));
+ omKeyInfo = omKeyInfo.toBuilder()
Review Comment:
Avoid duplicate `toBuilder()`:
```suggestion
OmKeyInfo.Builder builder = omKeyInfo.toBuilder();
Map<String, String> metadataMap = builder.getMetadata();
metadataMap.putAll(KeyValueUtil.getFromProtobuf(
commitKeyArgs.getMetadataList()));
omKeyInfo = builder
```
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/OMBucketSetOwnerRequest.java:
##########
@@ -156,7 +156,9 @@ public OMClientResponse validateAndUpdateCache(OzoneManager
ozoneManager, Execut
newOwner, bucketName, volumeName);
// Set the updateID to current transaction log index
- newOmBucketInfo.setUpdateID(transactionLogIndex);
+ newOmBucketInfo = newOmBucketInfo.toBuilder()
+ .withUpdateID(transactionLogIndex)
+ .build();
Review Comment:
Please move `.withUpdateID` into existing builder chain:
https://github.com/apache/ozone/blob/bcd3b7681fbc049f7d47d249fe1865d4ae1ddab5/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/OMBucketSetOwnerRequest.java#L150-L153
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMKeyCommitRequestWithFSO.java:
##########
@@ -224,16 +224,19 @@ public OMClientResponse
validateAndUpdateCache(OzoneManager ozoneManager, Execut
}
}
- omKeyInfo = omKeyInfo.withMetadataMutations(metadata ->
- metadata.putAll(KeyValueUtil.getFromProtobuf(
- commitKeyArgs.getMetadataList())));
+ 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()
Review Comment:
Please avoid duplicate `toBuilder()`.
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMKeyRequest.java:
##########
@@ -977,7 +977,9 @@ protected OmKeyInfo prepareFileInfo(
// The modification time is set in preExecute. Use the same
// modification time.
dbKeyInfo.setModificationTime(keyArgs.getModificationTime());
- dbKeyInfo.setUpdateID(transactionLogIndex);
+ dbKeyInfo = dbKeyInfo.toBuilder()
+ .withUpdateID(transactionLogIndex)
+ .build();
dbKeyInfo.setReplicationConfig(replicationConfig);
// Construct a new metadata map from KeyArgs by rebuilding via toBuilder.
Review Comment:
Please combine these two builders.
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OmKeysDeleteRequestWithFSO.java:
##########
@@ -139,7 +141,9 @@ protected Pair<Long, Integer> markKeysAsDeletedInCache(
omKeyInfo.getFileName())),
CacheValue.get(trxnLogIndex));
- omKeyInfo.setUpdateID(trxnLogIndex);
+ omKeyInfo = omKeyInfo.toBuilder()
+ .withUpdateID(trxnLogIndex)
+ .build();
Review Comment:
Same here, need to update `dirList`.
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OmKeysDeleteRequestWithFSO.java:
##########
@@ -106,7 +106,9 @@ protected Pair<Long, Integer> markKeysAsDeletedInCache(
.getOzonePathKey(volumeId, bucketId, parentId, fileName)),
CacheValue.get(trxnLogIndex));
emptyKeys += OmKeyInfo.isKeyEmpty(omKeyInfo) ? 1 : 0;
- omKeyInfo.setUpdateID(trxnLogIndex);
+ omKeyInfo = omKeyInfo.toBuilder()
+ .withUpdateID(trxnLogIndex)
+ .build();
Review Comment:
This updated `omKeyInfo` is not stored anywhere, so the updateID will be
lost. We need to replace the item in the list.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]