yandrey321 commented on code in PR #11118:
URL: https://github.com/apache/ozone/pull/11118#discussion_r3864488780
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMDirectoriesPurgeRequestWithFSO.java:
##########
@@ -134,93 +135,17 @@ public OMClientResponse
validateAndUpdateCache(OzoneManager ozoneManager, Execut
AUDIT.logWriteFailure(ozoneManager.buildAuditMessageForFailure(OMSystemAction.DIRECTORY_DELETION,
null, oe));
return new
OMDirectoriesPurgeResponseWithFSO(createErrorOMResponse(omResponse, oe));
}
+ PurgeApplyResult result = new PurgeApplyResult();
try {
- int numSubDirMoved = 0, numSubFilesMoved = 0, numDirsDeleted = 0;
- Map<VolumeBucketId, BucketNameInfo> volumeBucketIdMap =
purgeDirsRequest.getBucketNameInfosList().stream()
- .collect(Collectors.toMap(bucketNameInfo ->
- new VolumeBucketId(bucketNameInfo.getVolumeId(),
bucketNameInfo.getBucketId()),
- Function.identity()));
- for (OzoneManagerProtocolProtos.PurgePathRequest path : purgeRequests) {
- for (OzoneManagerProtocolProtos.KeyInfo key :
path.getMarkDeletedSubDirsList()) {
- ProcessedKeyInfo processed = processDeleteKey(key, path,
omMetadataManager);
- subDirNames.add(processed.deleteKey);
-
- omMetrics.decNumKeys();
- omMetrics.incNumKeyDeletesInternal();
- OmBucketInfo omBucketInfo = getBucketInfo(omMetadataManager,
- processed.volumeName, processed.bucketName);
- // bucketInfo can be null in case of delete volume or bucket
- // or key does not belong to bucket as bucket is recreated
- if (null != omBucketInfo && omBucketInfo.getObjectID() ==
path.getBucketId()) {
- omBucketInfo.decrUsedNamespace(1L, true);
- String ozoneDbKey =
omMetadataManager.getOzonePathKey(path.getVolumeId(),
- path.getBucketId(), processed.keyInfo.getParentObjectID(),
- processed.keyInfo.getFileName());
- omMetadataManager.getDirectoryTable().addCacheEntry(new
CacheKey<>(ozoneDbKey),
- CacheValue.get(context.getIndex()));
- volBucketInfoMap.putIfAbsent(processed.volBucketPair,
omBucketInfo);
- }
- }
-
- for (OzoneManagerProtocolProtos.KeyInfo key :
path.getDeletedSubFilesList()) {
- ProcessedKeyInfo processed = processDeleteKey(key, path,
omMetadataManager);
- subFileNames.add(processed.deleteKey);
-
- // If omKeyInfo has hsync metadata, delete its corresponding open
key as well
- String dbOpenKey;
- String hsyncClientId =
processed.keyInfo.getMetadata().get(OzoneConsts.HSYNC_CLIENT_ID);
- if (hsyncClientId != null) {
- long parentId = processed.keyInfo.getParentObjectID();
- dbOpenKey = omMetadataManager.getOpenFileName(path.getVolumeId(),
path.getBucketId(),
- parentId, processed.keyInfo.getFileName(), hsyncClientId);
- OmKeyInfo openKeyInfo =
omMetadataManager.getOpenKeyTable(getBucketLayout()).get(dbOpenKey);
- if (openKeyInfo != null) {
- openKeyInfo = openKeyInfo.withMetadataMutations(
- metadata -> metadata.put(DELETED_HSYNC_KEY, "true"));
- openKeyInfoMap.put(dbOpenKey, openKeyInfo);
- }
- }
-
- omMetrics.decNumKeys();
- omMetrics.incNumKeyDeletesInternal();
- numSubFilesMoved++;
- OmBucketInfo omBucketInfo = getBucketInfo(omMetadataManager,
- processed.volumeName, processed.bucketName);
- // bucketInfo can be null in case of delete volume or bucket
- // or key does not belong to bucket as bucket is recreated
- if (null != omBucketInfo
- && omBucketInfo.getObjectID() == path.getBucketId()) {
- long totalSize = sumBlockLengths(processed.keyInfo);
- omBucketInfo.decrUsedBytes(totalSize, true);
- omBucketInfo.decrUsedNamespace(1L, true);
- String ozoneDbKey =
omMetadataManager.getOzonePathKey(path.getVolumeId(),
- path.getBucketId(), processed.keyInfo.getParentObjectID(),
- processed.keyInfo.getFileName());
- omMetadataManager.getFileTable().addCacheEntry(new
CacheKey<>(ozoneDbKey),
- CacheValue.get(context.getIndex()));
- volBucketInfoMap.putIfAbsent(processed.volBucketPair,
omBucketInfo);
- }
- }
- if (path.hasDeletedDir()) {
- deletedDirNames.add(path.getDeletedDir());
- BucketNameInfo bucketNameInfo = volumeBucketIdMap.get(new
VolumeBucketId(path.getVolumeId(),
- path.getBucketId()));
- OmBucketInfo omBucketInfo = getBucketInfo(omMetadataManager,
- bucketNameInfo.getVolumeName(), bucketNameInfo.getBucketName());
- if (omBucketInfo != null && omBucketInfo.getObjectID() ==
path.getBucketId()) {
- omBucketInfo.purgeSnapshotUsedNamespace(1);
- volBucketInfoMap.put(Pair.of(omBucketInfo.getVolumeName(),
omBucketInfo.getBucketName()), omBucketInfo);
- }
- numDirsDeleted++;
- }
- }
+ // Phase 2 (under the bucket write lock): apply the prepared cache
tombstones, hsync open-key cleanup and
+ // aggregated per-bucket quota changes.
+ applyPreparedEntries(preparedSubDirs, preparedSubFiles,
preparedDirPurges, omMetadataManager,
Review Comment:
Created [HDDS-16297](https://issues.apache.org/jira/browse/HDDS-16297) for
addressing this concern.
--
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]