This is an automated email from the ASF dual-hosted git repository.

adoroszlai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new 28fe3437a5f HDDS-13916. Remove setModificationTime and setOwner from 
OmBucketInfo (#9291)
28fe3437a5f is described below

commit 28fe3437a5f812b427851460ce2c72510e175d28
Author: Russole <[email protected]>
AuthorDate: Sat Nov 15 00:45:20 2025 +0800

    HDDS-13916. Remove setModificationTime and setOwner from OmBucketInfo 
(#9291)
---
 .../hadoop/ozone/om/helpers/OmBucketInfo.java      | 12 ++------
 .../om/request/bucket/OMBucketSetOwnerRequest.java | 14 +++++----
 .../om/request/key/OMKeyRenameRequestWithFSO.java  | 36 ++++++++++++----------
 3 files changed, 30 insertions(+), 32 deletions(-)

diff --git 
a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmBucketInfo.java
 
b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmBucketInfo.java
index b938a1fff7b..b10dcbb2822 100644
--- 
a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmBucketInfo.java
+++ 
b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmBucketInfo.java
@@ -76,7 +76,7 @@ public final class OmBucketInfo extends WithObjectID 
implements Auditable, CopyO
   /**
    * modification time of bucket.
    */
-  private long modificationTime;
+  private final long modificationTime;
 
   /**
    * Bucket encryption key info if encryption is enabled.
@@ -108,7 +108,7 @@ public final class OmBucketInfo extends WithObjectID 
implements Auditable, CopyO
    */
   private final BucketLayout bucketLayout;
 
-  private String owner;
+  private final String owner;
 
   private OmBucketInfo(Builder b) {
     super(b);
@@ -335,14 +335,6 @@ public String getOwner() {
     return owner;
   }
 
-  public void setModificationTime(long modificationTime) {
-    this.modificationTime = modificationTime;
-  }
-
-  public void setOwner(String ownerName) {
-    this.owner = ownerName;
-  }
-
   /**
    * Returns new builder class that builds a OmBucketInfo.
    *
diff --git 
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/OMBucketSetOwnerRequest.java
 
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/OMBucketSetOwnerRequest.java
index e60d5019ff4..3d63a1d4b1a 100644
--- 
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/OMBucketSetOwnerRequest.java
+++ 
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/OMBucketSetOwnerRequest.java
@@ -147,24 +147,26 @@ public OMClientResponse 
validateAndUpdateCache(OzoneManager ozoneManager, Execut
         return omClientResponse;
       }
 
-      omBucketInfo.setOwner(newOwner);
+      OmBucketInfo newOmBucketInfo = omBucketInfo.toBuilder()
+          .setOwner(newOwner)
+          .setModificationTime(setBucketPropertyRequest.getModificationTime())
+          .build();
+
       LOG.debug("Updating bucket owner to {} for bucket: {} in volume: {}",
           newOwner, bucketName, volumeName);
 
-      omBucketInfo.setModificationTime(
-          setBucketPropertyRequest.getModificationTime());
       // Set the updateID to current transaction log index
-      omBucketInfo.setUpdateID(transactionLogIndex);
+      newOmBucketInfo.setUpdateID(transactionLogIndex);
 
       // Update table cache.
       omMetadataManager.getBucketTable().addCacheEntry(
           new CacheKey<>(bucketKey),
-          CacheValue.get(transactionLogIndex, omBucketInfo));
+          CacheValue.get(transactionLogIndex, newOmBucketInfo));
 
       omResponse.setSetBucketPropertyResponse(
           SetBucketPropertyResponse.newBuilder().setResponse(true).build());
       omClientResponse = new OMBucketSetOwnerResponse(
-          omResponse.build(), omBucketInfo);
+          omResponse.build(), newOmBucketInfo);
     } catch (IOException | InvalidPathException ex) {
       success = false;
       exception = ex;
diff --git 
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMKeyRenameRequestWithFSO.java
 
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMKeyRenameRequestWithFSO.java
index 8163b902dbb..98c2986b793 100644
--- 
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMKeyRenameRequestWithFSO.java
+++ 
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMKeyRenameRequestWithFSO.java
@@ -300,7 +300,7 @@ private OMClientResponse renameKey(OmKeyInfo toKeyParent, 
String toKeyName,
       fromKeyValue.setParentObjectID(omBucketInfo.getObjectID());
     }
     // Set modification time
-    setModificationTime(ommm, omBucketInfo, toKeyParent, volumeId, bucketId,
+    omBucketInfo = setModificationTime(ommm, omBucketInfo, toKeyParent, 
volumeId, bucketId,
         modificationTime, dirTable, trxnLogIndex);
     fromKeyParent = OMFileRequest.getKeyParentDir(fromKeyValue.getVolumeName(),
         fromKeyValue.getBucketName(), fromKeyName, ozoneManager, metadataMgr);
@@ -308,7 +308,7 @@ private OMClientResponse renameKey(OmKeyInfo toKeyParent, 
String toKeyName,
       // Get omBucketInfo only when needed to reduce unnecessary DB IO
       omBucketInfo = metadataMgr.getBucketTable().get(bucketKey);
     }
-    setModificationTime(ommm, omBucketInfo, fromKeyParent, volumeId,
+    omBucketInfo = setModificationTime(ommm, omBucketInfo, fromKeyParent, 
volumeId,
         bucketId, modificationTime, dirTable, trxnLogIndex);
 
     // destination dbKeyName
@@ -345,7 +345,7 @@ private OMClientResponse renameKey(OmKeyInfo toKeyParent, 
String toKeyName,
   }
 
   @SuppressWarnings("checkstyle:ParameterNumber")
-  private void setModificationTime(OMMetadataManager omMetadataManager,
+  private OmBucketInfo setModificationTime(OMMetadataManager omMetadataManager,
       OmBucketInfo bucketInfo, OmKeyInfo keyParent,
       long volumeId, long bucketId, long modificationTime,
       Table<String, OmDirectoryInfo> dirTable, long trxnLogIndex)
@@ -359,20 +359,24 @@ private void setModificationTime(OMMetadataManager 
omMetadataManager,
       dirTable.addCacheEntry(new CacheKey<>(dbToKeyParent),
           CacheValue.get(trxnLogIndex,
               OMFileRequest.getDirectoryInfo(keyParent)));
-    } else {
-      // For FSO a bucket is root of the filesystem, so rename an
-      // object at the root of a bucket need change bucket's modificationTime
-      if (bucketInfo == null) {
-        throw new OMException("Bucket not found",
-            OMException.ResultCodes.BUCKET_NOT_FOUND);
-      }
-      bucketInfo.setModificationTime(modificationTime);
-      String bucketKey = omMetadataManager.getBucketKey(
-          bucketInfo.getVolumeName(), bucketInfo.getBucketName());
-      omMetadataManager.getBucketTable().addCacheEntry(
-          new CacheKey<>(bucketKey),
-          CacheValue.get(trxnLogIndex, bucketInfo));
+      return bucketInfo;
+    }
+    // For FSO a bucket is root of the filesystem, so rename an
+    // object at the root of a bucket need change bucket's modificationTime
+    if (bucketInfo == null) {
+      throw new OMException("Bucket not found",
+          OMException.ResultCodes.BUCKET_NOT_FOUND);
     }
+    OmBucketInfo newBucketInfo = bucketInfo.toBuilder()
+        .setModificationTime(modificationTime)
+        .build();
+    String bucketKey = omMetadataManager.getBucketKey(
+        newBucketInfo.getVolumeName(), newBucketInfo.getBucketName());
+    omMetadataManager.getBucketTable().addCacheEntry(
+        new CacheKey<>(bucketKey),
+        CacheValue.get(trxnLogIndex, newBucketInfo));
+
+    return newBucketInfo;
   }
 
   private Map<String, String> buildAuditMap(


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to