kuenishi commented on a change in pull request #2433:
URL: https://github.com/apache/ozone/pull/2433#discussion_r726667868
##########
File path:
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/request/key/TestOMKeyCommitRequest.java
##########
@@ -275,6 +276,76 @@ public void testValidateAndUpdateCacheWithKeyNotFound()
throws Exception {
Assert.assertNull(omKeyInfo);
}
+ @Test
+ public void testValidateAndUpdateCacheOnOverwrite() throws Exception {
+ testValidateAndUpdateCache();
+
+ // Become a new client and set next version number
+ clientID = Time.now();
+ version += 1;
+
+ OMRequest modifiedOmRequest = doPreExecute(createCommitKeyRequest());
+
+ OMKeyCommitRequest omKeyCommitRequest =
+ getOmKeyCommitRequest(modifiedOmRequest);
+
+ KeyArgs keyArgs = modifiedOmRequest.getCommitKeyRequest().getKeyArgs();
+
+ // Key should be there in key table, as validateAndUpdateCache is called.
+ OmKeyInfo omKeyInfo =
+ omMetadataManager.getKeyTable().get(getOzonePathKey());
+
+ Assert.assertNotNull(omKeyInfo);
+ // Previously committed version
+ Assert.assertEquals(0L,
+ omKeyInfo.getLatestVersionLocations().getVersion());
+
+ // Append new blocks
+ List<OmKeyLocationInfo> allocatedLocationList =
+ keyArgs.getKeyLocationsList().stream()
+ .map(OmKeyLocationInfo::getFromProtobuf)
+ .collect(Collectors.toList());
+ addKeyToOpenKeyTable(allocatedLocationList);
+
+ OMClientResponse omClientResponse =
+ omKeyCommitRequest.validateAndUpdateCache(ozoneManager,
+ 102L, ozoneManagerDoubleBufferHelper);
+
+ Assert.assertEquals(OzoneManagerProtocolProtos.Status.OK,
+ omClientResponse.getOMResponse().getStatus());
+
+ String ozoneKey = getOzonePathKey();
+ // Entry should be deleted from openKey Table.
Review comment:
I merged your fix in
https://github.com/bharatviswa504/hadoop-ozone/commit/b0d9df21ea9fec8365a2da45451db44d881213a2
. Thank you.
--
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]