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 78fc781829 HDDS-10369. Set Times API doesn't work with linked buckets. 
(#6220)
78fc781829 is described below

commit 78fc781829e871839fb9413d62a65a89b1dcec6b
Author: Sadanand Shenoy <[email protected]>
AuthorDate: Thu Feb 15 16:13:10 2024 +0530

    HDDS-10369. Set Times API doesn't work with linked buckets. (#6220)
---
 .../ozone/AbstractRootedOzoneFileSystemTest.java   | 35 ++++++++++++++++++++++
 .../ozone/om/request/key/OMKeySetTimesRequest.java |  4 ++-
 2 files changed, 38 insertions(+), 1 deletion(-)

diff --git 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractRootedOzoneFileSystemTest.java
 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractRootedOzoneFileSystemTest.java
index 03167ce11f..9d31ac30cb 100644
--- 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractRootedOzoneFileSystemTest.java
+++ 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractRootedOzoneFileSystemTest.java
@@ -2461,4 +2461,39 @@ abstract class AbstractRootedOzoneFileSystemTest {
     assertEquals(mtime, fileStatus.getModificationTime());
   }
 
+  @Test
+  public void testSetTimesForLinkedBucketPath() throws Exception {
+    // Create a file
+    OzoneBucket sourceBucket =
+        TestDataUtil.createVolumeAndBucket(client, bucketLayout);
+    Path volumePath1 =
+        new Path(OZONE_URI_DELIMITER, sourceBucket.getVolumeName());
+    Path sourceBucketPath = new Path(volumePath1, sourceBucket.getName());
+    Path path = new Path(sourceBucketPath, "key1");
+    try (FSDataOutputStream stream = fs.create(path)) {
+      stream.write(1);
+    }
+    OzoneVolume sourceVol = 
client.getObjectStore().getVolume(sourceBucket.getVolumeName());
+    String linkBucketName = UUID.randomUUID().toString();
+    createLinkBucket(sourceVol.getName(), linkBucketName,
+        sourceVol.getName(), sourceBucket.getName());
+
+    Path linkedBucketPath = new Path(volumePath1, linkBucketName);
+    Path keyInLinkedBucket = new Path(linkedBucketPath, "key1");
+
+    // test setTimes in linked bucket path
+    long mtime = 1000;
+    fs.setTimes(keyInLinkedBucket, mtime, 2000);
+
+    FileStatus fileStatus = fs.getFileStatus(path);
+    // verify that mtime is updated as expected.
+    assertEquals(mtime, fileStatus.getModificationTime());
+
+    long mtimeDontUpdate = -1;
+    fs.setTimes(keyInLinkedBucket, mtimeDontUpdate, 2000);
+
+    fileStatus = fs.getFileStatus(keyInLinkedBucket);
+    // verify that mtime is NOT updated as expected.
+    assertEquals(mtime, fileStatus.getModificationTime());
+  }
 }
diff --git 
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMKeySetTimesRequest.java
 
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMKeySetTimesRequest.java
index 1f5e623da0..e14cfaaad2 100644
--- 
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMKeySetTimesRequest.java
+++ 
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMKeySetTimesRequest.java
@@ -74,10 +74,12 @@ public class OMKeySetTimesRequest extends OMKeyRequest {
             .setKeyName(normalizedKeyPath)
             .build();
 
+    OzoneManagerProtocolProtos.KeyArgs newKeyArgs = 
resolveBucketLink(ozoneManager, keyArgs);
+
     return request.toBuilder()
         .setSetTimesRequest(
             setTimesRequest.toBuilder()
-                .setKeyArgs(keyArgs)
+                .setKeyArgs(newKeyArgs)
                 .setMtime(getModificationTime()))
         .build();
   }


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

Reply via email to