smengcl commented on code in PR #8450:
URL: https://github.com/apache/ozone/pull/8450#discussion_r2103354999
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/service/KeyDeletingService.java:
##########
@@ -186,9 +173,116 @@ public void setKeyLimitPerTask(int keyLimitPerTask) {
*/
private final class KeyDeletingTask implements BackgroundTask {
private final KeyDeletingService deletingService;
+ private final UUID snapshotId;
- private KeyDeletingTask(KeyDeletingService service) {
+ private KeyDeletingTask(KeyDeletingService service, UUID snapshotId) {
this.deletingService = service;
+ this.snapshotId = snapshotId;
+ }
+
+ private OzoneManagerProtocolProtos.SetSnapshotPropertyRequest
getSetSnapshotRequestUpdatingExclusiveSize(
+ Map<UUID, Long> exclusiveSizeMap, Map<UUID, Long>
exclusiveReplicatedSizeMap, UUID snapshotID) {
+ OzoneManagerProtocolProtos.SnapshotSize snapshotSize =
OzoneManagerProtocolProtos.SnapshotSize.newBuilder()
+ .setExclusiveSize(
+ exclusiveSizeMap.getOrDefault(snapshotID, 0L))
+ .setExclusiveReplicatedSize(
+ exclusiveReplicatedSizeMap.getOrDefault(
+ snapshotID, 0L))
+ .build();
+ exclusiveSizeMap.remove(snapshotID);
+ exclusiveReplicatedSizeMap.remove(snapshotID);
+
+ return OzoneManagerProtocolProtos.SetSnapshotPropertyRequest.newBuilder()
+ .setSnapshotKey(snapshotChainManager.getTableKey(snapshotID))
+ .setSnapshotSize(snapshotSize)
+ .build();
+ }
+
+ /**
+ *
+ * @param currentSnapshotInfo if null, deleted directories in AOS should
be processed.
+ * @param keyManager KeyManager of the underlying store.
+ */
+ private void processDeletedKeysForStore(SnapshotInfo currentSnapshotInfo,
KeyManager keyManager,
+ int remainNum) throws IOException, InterruptedException {
+ String volume = null, bucket = null, snapshotTableKey = null;
+ if (currentSnapshotInfo != null) {
+ volume = currentSnapshotInfo.getVolumeName();
+ bucket = currentSnapshotInfo.getBucketName();
+ snapshotTableKey = currentSnapshotInfo.getTableKey();
+ }
+
+ String startKey = null;
+ boolean successStatus = true;
+ try {
+ // TODO: [SNAPSHOT] HDDS-7968. Reclaim eligible key blocks in
+ // snapshot's deletedTable when active DB's deletedTable
+ // doesn't have enough entries left.
+ // OM would have to keep track of which snapshot the key is coming
+ // from if the above would be done inside getPendingDeletionKeys().
+ OmSnapshotManager omSnapshotManager =
getOzoneManager().getOmSnapshotManager();
+ // This is to avoid race condition b/w purge request and snapshot
chain update. For AOS taking the global
+ // snapshotId since AOS could process multiple buckets in one
iteration. While using path
+ // previous snapshotId for a snapshot since it would process only one
bucket.
+ UUID expectedPreviousSnapshotId = currentSnapshotInfo == null ?
+ snapshotChainManager.getLatestGlobalSnapshotId() :
+ SnapshotUtils.getPreviousSnapshotId(currentSnapshotInfo,
snapshotChainManager);
+
+ IOzoneManagerLock lock =
getOzoneManager().getMetadataManager().getLock();
+
+ // Purge deleted Keys in the deletedTable && rename entries in the
snapshotRenamedTable which doesn't have a
+ // reference in the previous snapshot.
+ try (ReclaimableKeyFilter reclaimableKeyFilter = new
ReclaimableKeyFilter(getOzoneManager(),
+ omSnapshotManager, snapshotChainManager, currentSnapshotInfo,
keyManager, lock)) {
+ // Get pending keys that can be deleted
+ PendingKeysDeletion pendingKeysDeletion = currentSnapshotInfo == null
+ ? keyManager.getPendingDeletionKeys(reclaimableKeyFilter,
remainNum)
+ : keyManager.getPendingDeletionKeys(volume, bucket, startKey,
reclaimableKeyFilter, remainNum);
+ List<BlockGroup> keyBlocksList =
pendingKeysDeletion.getKeyBlocksList();
+ //submit purge requests if there are renamed entries to be purged or
keys to be purged.
Review Comment:
```suggestion
// Submit purge requests if there are renamed entries to be purged
or keys to be purged.
```
--
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]