From common-commits-return-96336-archive-asf-public=cust-asf.ponee.io@hadoop.apache.org Tue Sep 3 13:01:06 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id AB11B180637 for ; Tue, 3 Sep 2019 15:01:06 +0200 (CEST) Received: (qmail 3415 invoked by uid 500); 3 Sep 2019 14:54:32 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 3406 invoked by uid 99); 3 Sep 2019 14:54:32 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Sep 2019 14:54:32 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 7D1F387446; Tue, 3 Sep 2019 13:01:05 +0000 (UTC) Date: Tue, 03 Sep 2019 13:01:05 +0000 To: "common-commits@hadoop.apache.org" Subject: [hadoop] branch trunk updated: HDFS-14807. SetTimes updates all negative values apart from -1. Contributed by Ayush Saxena. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <156751566499.24971.9692715587979081306@gitbox.apache.org> From: ayushsaxena@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: hadoop X-Git-Refname: refs/heads/trunk X-Git-Reftype: branch X-Git-Oldrev: 0f549ec02a2c4421c22a5b719371d6f8c31e7f70 X-Git-Newrev: 91b01a1db794581c67e1ccf9aabaa7cafd686c48 X-Git-Rev: 91b01a1db794581c67e1ccf9aabaa7cafd686c48 X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated 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 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 src 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-unsubscribe@hadoop.apache.org For additional commands, e-mail: common-commits-help@hadoop.apache.org