sumitagrawl commented on code in PR #3973:
URL: https://github.com/apache/ozone/pull/3973#discussion_r1027841658
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMDirectoriesPurgeRequestWithFSO.java:
##########
@@ -48,12 +59,72 @@ public OMClientResponse validateAndUpdateCache(OzoneManager
ozoneManager,
List<OzoneManagerProtocolProtos.PurgePathRequest> purgeRequests =
purgeDirsRequest.getDeletedPathList();
+ Set<Pair<String, String>> lockSet = new HashSet<>();
+ Map<Pair<String, String>, OmBucketInfo> volBucketInfoMap = new HashMap<>();
+ OMMetadataManager omMetadataManager = ozoneManager.getMetadataManager();
+ try {
+ for (OzoneManagerProtocolProtos.PurgePathRequest path : purgeRequests) {
+ for (OzoneManagerProtocolProtos.KeyInfo key :
+ path.getMarkDeletedSubDirsList()) {
+ OmKeyInfo keyInfo = OmKeyInfo.getFromProtobuf(key);
+ String volumeName = keyInfo.getVolumeName();
+ String bucketName = keyInfo.getBucketName();
+ Pair<String, String> volBucketPair = Pair.of(volumeName, bucketName);
+ if (!lockSet.contains(volBucketPair)) {
+ omMetadataManager.getLock().acquireWriteLock(BUCKET_LOCK,
+ volumeName, bucketName);
+ lockSet.add(volBucketPair);
+ }
+ OmBucketInfo omBucketInfo = getBucketInfo(omMetadataManager,
+ volumeName, bucketName);
+ // bucketInfo can be null in case of delete volume or bucket
+ if (null != omBucketInfo) {
+ omBucketInfo.incrUsedNamespace(-1L);
+ volBucketInfoMap.putIfAbsent(volBucketPair, omBucketInfo);
+ }
+ }
+
+ for (OzoneManagerProtocolProtos.KeyInfo key :
+ path.getDeletedSubFilesList()) {
+ OmKeyInfo keyInfo = OmKeyInfo.getFromProtobuf(key);
+ String volumeName = keyInfo.getVolumeName();
+ String bucketName = keyInfo.getBucketName();
+ Pair<String, String> volBucketPair = Pair.of(volumeName, bucketName);
+ if (!lockSet.contains(volBucketPair)) {
+ omMetadataManager.getLock().acquireWriteLock(BUCKET_LOCK,
+ volumeName, bucketName);
+ lockSet.add(volBucketPair);
+ }
+ OmBucketInfo omBucketInfo = getBucketInfo(omMetadataManager,
+ volumeName, bucketName);
+ // bucketInfo can be null in case of delete volume or bucket
+ if (null != omBucketInfo) {
+ omBucketInfo.incrUsedBytes(-sumBlockLengths(keyInfo));
+ omBucketInfo.incrUsedNamespace(-1L);
+ volBucketInfoMap.putIfAbsent(volBucketPair, omBucketInfo);
+ }
+ }
+ }
+ } catch (IOException ex) {
+ // Case of IOException for fromProtobuf will not hanppen
+ // as this is created and send within OM
+ // only case of upgrade where compatibility is broken can have
+ throw new IllegalStateException(ex);
+ } finally {
+ lockSet.stream().forEach(e -> omMetadataManager.getLock()
+ .releaseWriteLock(BUCKET_LOCK, e.getKey(),
+ e.getValue()));
+ for (Map.Entry<Pair<String, String>, OmBucketInfo> entry :
+ volBucketInfoMap.entrySet()) {
+ entry.setValue(entry.getValue().copyObject());
Review Comment:
Followed similar logic as other place, before add to response, copy the
bucketInfo
--
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]