hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject hadoop git commit: HADOOP-14430 the accessTime of FileStatus returned by SFTPFileSystem's getFileStatus method is always 0. Contributed by Hongyuan Li.
Date Thu, 25 May 2017 14:20:24 GMT
Repository: hadoop
Updated Branches:
  refs/heads/branch-2 07c14b35e -> 1efba62fd


HADOOP-14430 the accessTime of FileStatus returned by SFTPFileSystem's
getFileStatus method is always 0.
Contributed by Hongyuan Li.


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

Branch: refs/heads/branch-2
Commit: 1efba62fd73a24fd7da98c59d7acd4a9ab7a221a
Parents: 07c14b3
Author: Steve Loughran <stevel@apache.org>
Authored: Thu May 25 15:17:43 2017 +0100
Committer: Steve Loughran <stevel@apache.org>
Committed: Thu May 25 15:17:43 2017 +0100

----------------------------------------------------------------------
 .../org/apache/hadoop/fs/sftp/SFTPFileSystem.java     |  2 +-
 .../org/apache/hadoop/fs/sftp/TestSFTPFileSystem.java | 14 ++++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/1efba62f/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/sftp/SFTPFileSystem.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/sftp/SFTPFileSystem.java
b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/sftp/SFTPFileSystem.java
index 8b6267a..e4e7bbf 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/sftp/SFTPFileSystem.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/sftp/SFTPFileSystem.java
@@ -279,7 +279,7 @@ public class SFTPFileSystem extends FileSystem {
     // block sizes on server. The assumption could be less than ideal.
     long blockSize = DEFAULT_BLOCK_SIZE;
     long modTime = attr.getMTime() * 1000; // convert to milliseconds
-    long accessTime = 0;
+    long accessTime = attr.getATime() * 1000L;
     FsPermission permission = getPermissions(sftpFile);
     // not be able to get the real user group name, just use the user and group
     // id

http://git-wip-us.apache.org/repos/asf/hadoop/blob/1efba62f/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/sftp/TestSFTPFileSystem.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/sftp/TestSFTPFileSystem.java
b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/sftp/TestSFTPFileSystem.java
index 36aacee..ad54dc0 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/sftp/TestSFTPFileSystem.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/sftp/TestSFTPFileSystem.java
@@ -19,6 +19,8 @@ package org.apache.hadoop.fs.sftp;
 
 import java.io.IOException;
 import java.net.URI;
+import java.nio.file.Files;
+import java.nio.file.attribute.BasicFileAttributes;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
@@ -28,6 +30,7 @@ import org.apache.hadoop.fs.FSDataInputStream;
 import org.apache.hadoop.fs.FSDataOutputStream;
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.LocalFileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.util.Shell;
@@ -306,4 +309,15 @@ public class TestSFTPFileSystem {
     sftpFs.rename(file1, file2);
   }
 
+  @Test
+  public void testGetAccessTime() throws IOException {
+    Path file = touch(localFs, name.getMethodName().toLowerCase());
+    LocalFileSystem local = (LocalFileSystem)localFs;
+    java.nio.file.Path path = (local).pathToFile(file).toPath();
+    long accessTime1 = Files.readAttributes(path, BasicFileAttributes.class)
+        .lastAccessTime().toMillis();
+    long accessTime2 = sftpFs.getFileStatus(file).getAccessTime();
+    assertEquals(accessTime1, accessTime2);
+  }
+
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message