This is an automated email from the ASF dual-hosted git repository. ayushsaxena pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/trunk by this push: new 91b01a1 HDFS-14807. SetTimes updates all negative values apart from -1. Contributed by Ayush Saxena. 91b01a1 is described below commit 91b01a1db794581c67e1ccf9aabaa7cafd686c48 Author: Ayush Saxena <ayushsax...@apache.org> AuthorDate: Tue Sep 3 18:08:42 2019 +0530 HDFS-14807. SetTimes updates all negative values apart from -1. Contributed by Ayush Saxena. --- .../main/java/org/apache/hadoop/hdfs/protocol/ClientProtocol.java | 6 +++--- .../java/org/apache/hadoop/hdfs/server/namenode/FSDirAttrOp.java | 4 ++-- .../src/test/java/org/apache/hadoop/hdfs/TestSetTimes.java | 7 +++++++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/ClientProtocol.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/ClientProtocol.java index da93707..35969a3 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/ClientProtocol.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/ClientProtocol.java @@ -1145,11 +1145,11 @@ public interface ClientProtocol { * Sets the modification and access time of the file to the specified time. * @param src The string representation of the path * @param mtime The number of milliseconds since Jan 1, 1970. - * Setting mtime to -1 means that modification time should not + * Setting negative mtime means that modification time should not * be set by this call. * @param atime The number of milliseconds since Jan 1, 1970. - * Setting atime to -1 means that access time should not be set - * by this call. + * Setting negative atime means that access time should not be + * set by this call. * * @throws org.apache.hadoop.security.AccessControlException permission denied * @throws java.io.FileNotFoundException file <code>src</code> is not found diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirAttrOp.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirAttrOp.java index b0a36b9..65b528a 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirAttrOp.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirAttrOp.java @@ -475,14 +475,14 @@ public class FSDirAttrOp { boolean status = false; INode inode = iip.getLastINode(); int latest = iip.getLatestSnapshotId(); - if (mtime != -1) { + if (mtime >= 0) { inode = inode.setModificationTime(mtime, latest); status = true; } // if the last access time update was within the last precision interval, // then no need to store access time - if (atime != -1 && (status || force + if (atime >= 0 && (status || force || atime > inode.getAccessTime() + fsd.getAccessTimePrecision())) { inode.setAccessTime(atime, latest, fsd.getFSNamesystem().getSnapshotManager(). diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestSetTimes.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestSetTimes.java index a90d139..74cde2a 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestSetTimes.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestSetTimes.java @@ -139,6 +139,13 @@ public class TestSetTimes { " (" + mtime1 + ")"); assertTrue(atime1 != 0); + // check setting negative value for atime and mtime. + fileSys.setTimes(file1, -2, -2); + // The values shouldn't change. + stat = fileSys.getFileStatus(file1); + assertEquals(mtime1, stat.getModificationTime()); + assertEquals(atime1, stat.getAccessTime()); + // // record dir times // --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-commits-h...@hadoop.apache.org