hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From y...@apache.org
Subject hadoop git commit: HDFS-9208. Disabling atime may fail clients like distCp. (Kihwal Lee via yliu)
Date Tue, 20 Oct 2015 03:42:22 GMT
Repository: hadoop
Updated Branches:
  refs/heads/branch-2 acc0e718d -> 03bb40612


HDFS-9208. Disabling atime may fail clients like distCp. (Kihwal Lee via yliu)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/03bb4061
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/03bb4061
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/03bb4061

Branch: refs/heads/branch-2
Commit: 03bb40612e56b3061760095289368172795fdc08
Parents: acc0e71
Author: yliu <yliu@apache.org>
Authored: Tue Oct 20 11:31:14 2015 +0800
Committer: yliu <yliu@apache.org>
Committed: Tue Oct 20 11:31:14 2015 +0800

----------------------------------------------------------------------
 hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt     |  3 ++
 .../hdfs/server/namenode/FSDirAttrOp.java       |  8 -----
 .../org/apache/hadoop/hdfs/TestSetTimes.java    | 31 ++++++++++++++++++++
 3 files changed, 34 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/03bb4061/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
index dbd333a..a867506 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
+++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
@@ -1254,6 +1254,9 @@ Release 2.8.0 - UNRELEASED
     HDFS-9237. NPE at TestDataNodeVolumeFailureToleration#tearDown.
     (Brahma Reddy Battula via ozawa)
 
+    HDFS-9208. Disabling atime may fail clients like distCp. (Kihwal Lee via
+    yliu)
+
 Release 2.7.2 - UNRELEASED
 
   INCOMPATIBLE CHANGES

http://git-wip-us.apache.org/repos/asf/hadoop/blob/03bb4061/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirAttrOp.java
----------------------------------------------------------------------
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 df0bc20..0a138f5 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
@@ -42,7 +42,6 @@ import java.util.Arrays;
 import java.util.EnumSet;
 import java.util.List;
 
-import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_ACCESSTIME_PRECISION_KEY;
 import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_QUOTA_BY_STORAGETYPE_ENABLED_KEY;
 import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_STORAGE_POLICY_ENABLED_KEY;
 
@@ -97,13 +96,6 @@ public class FSDirAttrOp {
   static HdfsFileStatus setTimes(
       FSDirectory fsd, String src, long mtime, long atime)
       throws IOException {
-    if (!fsd.isAccessTimeSupported() && atime != -1) {
-      throw new IOException(
-          "Access time for hdfs is not configured. " +
-              " Please set " + DFS_NAMENODE_ACCESSTIME_PRECISION_KEY
-              + " configuration parameter.");
-    }
-
     FSPermissionChecker pc = fsd.getPermissionChecker();
     byte[][] pathComponents = FSDirectory.getPathComponentsForReservedPath(src);
 

http://git-wip-us.apache.org/repos/asf/hadoop/blob/03bb4061/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestSetTimes.java
----------------------------------------------------------------------
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 4e6091b..a90d139 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
@@ -40,6 +40,7 @@ import org.apache.hadoop.hdfs.protocol.HdfsConstants.DatanodeReportType;
 import org.apache.hadoop.hdfs.server.namenode.NameNodeAdapter;
 import org.apache.hadoop.test.MockitoUtil;
 import org.apache.hadoop.util.Time;
+import org.junit.Assert;
 import org.junit.Test;
 import org.mockito.Mockito;
 
@@ -309,6 +310,36 @@ public class TestSetTimes {
     }
   }
 
+  /**
+   * Test whether atime can be set explicitly even when the atime support is
+   * disabled.
+   */
+  @Test
+  public void testAtimeUpdate() throws Exception {
+    Configuration conf = new HdfsConfiguration();
+    conf.setInt(DFSConfigKeys.DFS_NAMENODE_ACCESSTIME_PRECISION_KEY, 0);
+    MiniDFSCluster cluster = null;
+    FileSystem fs = null;
+
+    try {
+      cluster = new MiniDFSCluster.Builder(conf)
+          .numDataNodes(0)
+          .build();
+      fs = cluster.getFileSystem();
+
+      // Create an empty file
+      Path p = new Path("/testAtimeUpdate");
+      DFSTestUtil.createFile(cluster.getFileSystem(), p, 0, (short)1, 0L);
+
+      fs.setTimes(p, -1L, 123456L);
+      Assert.assertEquals(123456L, fs.getFileStatus(p).getAccessTime());
+    } finally {
+      if (cluster != null) {
+        cluster.shutdown();
+      }
+    }
+  }
+
   public static void main(String[] args) throws Exception {
     new TestSetTimes().testTimes();
   }


Mime
View raw message