swamirishi commented on code in PR #7045:
URL: https://github.com/apache/ozone/pull/7045#discussion_r1717649173
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/snapshot/OMSnapshotPurgeRequest.java:
##########
@@ -287,18 +219,25 @@ private void updateSnapshotChainAndCache(
metadataManager.getSnapshotInfoTable().addCacheEntry(
new CacheKey<>(nextPathSnapInfo.getTableKey()),
CacheValue.get(trxnLogIndex, nextPathSnapInfo));
- updatedPathPreviousAndGlobalSnapshots
- .put(nextPathSnapInfo.getTableKey(), nextPathSnapInfo);
} else if (nextGlobalSnapInfo != null) {
nextGlobalSnapInfo.setGlobalPreviousSnapshotId(
snapInfo.getGlobalPreviousSnapshotId());
metadataManager.getSnapshotInfoTable().addCacheEntry(
new CacheKey<>(nextGlobalSnapInfo.getTableKey()),
CacheValue.get(trxnLogIndex, nextGlobalSnapInfo));
- updatedPathPreviousAndGlobalSnapshots
- .put(nextGlobalSnapInfo.getTableKey(), nextGlobalSnapInfo);
}
snapshotChainManager.deleteSnapshot(snapInfo);
}
+
+ private SnapshotInfo getUpdatedSnapshotInfo(String snapshotTableKey,
OMMetadataManager omMetadataManager)
+ throws IOException {
+ if (updatedSnapshotInfos.containsKey(snapshotTableKey)) {
+ return updatedSnapshotInfos.get(snapshotTableKey);
+ } else {
+ SnapshotInfo snapshotInfo =
omMetadataManager.getSnapshotInfoTable().get(snapshotTableKey);
+ updatedSnapshotInfos.put(snapshotTableKey, snapshotInfo);
+ return snapshotInfo;
+ }
Review Comment:
It would be better to throw an uncheckedIOException and catch in case of
exceptions. containsKey & put would do 2 lookups vs 1.
--
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]