-
Notifications
You must be signed in to change notification settings - Fork 588
HDDS-11603. Reclaimable Key Filter for Snapshots garbage reclaimation #8392
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 28 commits
a9f3630
80713fd
dcfec3d
e2a8cfe
7096a1c
7514ac3
889cb9d
7c141fd
acdaffe
b94a54f
df8c562
8b7c738
fdafee8
8bc3cc6
4c9bdfb
b7e20ca
0ee6b06
890eeb4
0d209b7
7e1e9d4
842a25f
6da2b1e
3055f8a
ce2afc8
ae1777a
db5b749
bafa998
2df2107
a358cb3
f5eb422
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,6 +40,8 @@ | |
| import org.apache.hadoop.ozone.om.SnapshotChainManager; | ||
| import org.apache.hadoop.ozone.om.exceptions.OMException; | ||
| import org.apache.hadoop.ozone.om.helpers.OmKeyInfo; | ||
| import org.apache.hadoop.ozone.om.helpers.OmKeyLocationInfo; | ||
| import org.apache.hadoop.ozone.om.helpers.OmKeyLocationInfoGroup; | ||
| import org.apache.hadoop.ozone.om.helpers.RepeatedOmKeyInfo; | ||
| import org.apache.hadoop.ozone.om.helpers.SnapshotInfo; | ||
| import org.apache.hadoop.ozone.om.helpers.SnapshotInfo.SnapshotStatus; | ||
|
|
@@ -53,8 +55,7 @@ | |
| * Util class for snapshot diff APIs. | ||
| */ | ||
| public final class SnapshotUtils { | ||
| private static final Logger LOG = | ||
| LoggerFactory.getLogger(SnapshotUtils.class); | ||
| private static final Logger LOG = LoggerFactory.getLogger(SnapshotUtils.class); | ||
|
|
||
| private SnapshotUtils() { | ||
| throw new IllegalStateException("SnapshotUtils should not be initialized."); | ||
|
|
@@ -189,7 +190,7 @@ public static SnapshotInfo getPreviousSnapshot(OzoneManager ozoneManager, | |
| /** | ||
| * Get the previous snapshot in the snapshot chain. | ||
| */ | ||
| private static UUID getPreviousSnapshotId(SnapshotInfo snapInfo, SnapshotChainManager chainManager) | ||
| public static UUID getPreviousSnapshotId(SnapshotInfo snapInfo, SnapshotChainManager chainManager) | ||
| throws IOException { | ||
| // If the snapshot is deleted in the previous run, then the in-memory | ||
| // SnapshotChainManager might throw NoSuchElementException as the snapshot | ||
|
|
@@ -299,4 +300,59 @@ public static void validatePreviousSnapshotId(SnapshotInfo snapshotInfo, | |
| OMException.ResultCodes.INVALID_REQUEST); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Compares the block location info of 2 key info. | ||
| * @return true if block locations are same else false. | ||
| */ | ||
| public static boolean isBlockLocationInfoSame(OmKeyInfo prevKeyInfo, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please add a javadoc explaining what it does.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is a relatively complex helper method. A test for this helper for various corner cases would be ideal.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this change doesn't pertain to this PR as I have simply moved this function to SnapshotUtils I can create a follow up task for adding a test case for this. |
||
| OmKeyInfo deletedKeyInfo) { | ||
| if (prevKeyInfo == null && deletedKeyInfo == null) { | ||
| LOG.debug("Both prevKeyInfo and deletedKeyInfo are null."); | ||
| return true; | ||
| } | ||
| if (prevKeyInfo == null || deletedKeyInfo == null) { | ||
| LOG.debug("prevKeyInfo: '{}' or deletedKeyInfo: '{}' is null.", | ||
| prevKeyInfo, deletedKeyInfo); | ||
| return false; | ||
| } | ||
| // For hsync, Though the blockLocationInfo of a key may not be same | ||
| // at the time of snapshot and key deletion as blocks can be appended. | ||
| // If the objectId is same then the key is same. | ||
| if (prevKeyInfo.isHsync() && deletedKeyInfo.isHsync()) { | ||
| return true; | ||
| } | ||
|
|
||
| if (prevKeyInfo.getKeyLocationVersions().size() != | ||
| deletedKeyInfo.getKeyLocationVersions().size()) { | ||
| return false; | ||
| } | ||
|
|
||
| OmKeyLocationInfoGroup deletedOmKeyLocation = | ||
| deletedKeyInfo.getLatestVersionLocations(); | ||
| OmKeyLocationInfoGroup prevOmKeyLocation = | ||
| prevKeyInfo.getLatestVersionLocations(); | ||
|
|
||
| if (deletedOmKeyLocation == null || prevOmKeyLocation == null) { | ||
| return false; | ||
| } | ||
|
|
||
| List<OmKeyLocationInfo> deletedLocationList = | ||
| deletedOmKeyLocation.getLocationList(); | ||
| List<OmKeyLocationInfo> prevLocationList = | ||
| prevOmKeyLocation.getLocationList(); | ||
|
|
||
| if (deletedLocationList.size() != prevLocationList.size()) { | ||
| return false; | ||
| } | ||
|
|
||
| for (int idx = 0; idx < deletedLocationList.size(); idx++) { | ||
| OmKeyLocationInfo deletedLocationInfo = deletedLocationList.get(idx); | ||
| OmKeyLocationInfo prevLocationInfo = prevLocationList.get(idx); | ||
| if (!deletedLocationInfo.hasSameBlockAs(prevLocationInfo)) { | ||
| return false; | ||
| } | ||
| } | ||
| return true; | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved to SnapshotUtils