sadanand48 commented on code in PR #6180:
URL: https://github.com/apache/ozone/pull/6180#discussion_r1481286543
##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/request/key/TestOMKeyCommitRequest.java:
##########
@@ -576,49 +582,54 @@ public void testValidateAndUpdateCacheOnOverwrite()
throws Exception {
assertNotNull(omKeyInfo);
// Previously committed version
- assertEquals(0L,
- omKeyInfo.getLatestVersionLocations().getVersion());
+ assertEquals(0L, omKeyInfo.getLatestVersionLocations().getVersion());
// Append new blocks
List<OmKeyLocationInfo> allocatedLocationList =
- keyArgs.getKeyLocationsList().stream()
- .map(OmKeyLocationInfo::getFromProtobuf)
- .collect(Collectors.toList());
+ keyArgs.getKeyLocationsList().stream()
+ .map(OmKeyLocationInfo::getFromProtobuf)
+ .collect(Collectors.toList());
addKeyToOpenKeyTable(allocatedLocationList);
OMClientResponse omClientResponse =
omKeyCommitRequest.validateAndUpdateCache(ozoneManager, 102L);
- assertEquals(OzoneManagerProtocolProtos.Status.OK,
- omClientResponse.getOMResponse().getStatus());
+ assertEquals(OzoneManagerProtocolProtos.Status.OK,
omClientResponse.getOMResponse().getStatus());
// New entry should be created in key Table.
- omKeyInfo =
- omMetadataManager.getKeyTable(omKeyCommitRequest.getBucketLayout())
- .get(ozoneKey);
+ omKeyInfo =
omMetadataManager.getKeyTable(omKeyCommitRequest.getBucketLayout()).get(ozoneKey);
assertNotNull(omKeyInfo);
- assertEquals(version,
- omKeyInfo.getLatestVersionLocations().getVersion());
+ assertEquals(version, omKeyInfo.getLatestVersionLocations().getVersion());
// DB keyInfo format
verifyKeyName(omKeyInfo);
// Check modification time
CommitKeyRequest commitKeyRequest =
modifiedOmRequest.getCommitKeyRequest();
- assertEquals(commitKeyRequest.getKeyArgs().getModificationTime(),
- omKeyInfo.getModificationTime());
+ assertEquals(commitKeyRequest.getKeyArgs().getModificationTime(),
omKeyInfo.getModificationTime());
// Check block location.
List<OmKeyLocationInfo> locationInfoListFromCommitKeyRequest =
- commitKeyRequest.getKeyArgs()
- .getKeyLocationsList().stream().map(OmKeyLocationInfo::getFromProtobuf)
- .collect(Collectors.toList());
+
commitKeyRequest.getKeyArgs().getKeyLocationsList().stream().map(OmKeyLocationInfo::getFromProtobuf)
+ .collect(Collectors.toList());
- assertEquals(locationInfoListFromCommitKeyRequest,
- omKeyInfo.getLatestVersionLocations().getLocationList());
- assertEquals(allocatedLocationList,
- omKeyInfo.getLatestVersionLocations().getLocationList());
+ assertEquals(locationInfoListFromCommitKeyRequest,
omKeyInfo.getLatestVersionLocations().getLocationList());
+ assertEquals(allocatedLocationList,
omKeyInfo.getLatestVersionLocations().getLocationList());
assertEquals(1, omKeyInfo.getKeyLocationVersions().size());
+
+ // flush response content to db
+ BatchOperation batchOperation =
omMetadataManager.getStore().initBatchOperation();
+ ((OMKeyCommitResponse) omClientResponse).addToDBBatch(omMetadataManager,
batchOperation);
+ omMetadataManager.getStore().commitBatchOperation(batchOperation);
+
+ // verify deleted key is unique generated
+ String deletedKey = omMetadataManager.getOzoneKey(volumeName,
omKeyInfo.getBucketName(), keyName);
+ List<? extends Table.KeyValue<String, RepeatedOmKeyInfo>> rangeKVs
+ = omMetadataManager.getDeletedTable().getRangeKVs(null, 100,
deletedKey);
+ assertThat(rangeKVs.size()).isGreaterThan(0);
+ assertEquals(1, rangeKVs.get(0).getValue().getOmKeyInfoList().size());
+
assertTrue(!rangeKVs.get(0).getKey().endsWith(rangeKVs.get(0).getValue().getOmKeyInfoList().get(0).getObjectID()
Review Comment:
can use assertFalse instead. Also for better readability we can assign
variables to these both keys we are comparing
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMKeyCommitRequest.java:
##########
@@ -270,8 +270,10 @@ public OMClientResponse
validateAndUpdateCache(OzoneManager ozoneManager, TermIn
keyToDelete, trxnLogIndex, ozoneManager.isRatisEnabled());
checkBucketQuotaInBytes(omMetadataManager, omBucketInfo,
correctedSpace);
+ // using pseutoObjId as objectId can be same in case of overwrite key
Review Comment:
typo : pseudo
--
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]