You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by li...@apache.org on 2016/11/30 05:01:23 UTC
[33/48] hadoop git commit: HADOOP-13828. Implement
getFileChecksum(path,
length) for ViewFileSystem. Contributed by Manoj Govindassamy.
HADOOP-13828. Implement getFileChecksum(path, length) for ViewFileSystem. Contributed by Manoj Govindassamy.
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/a2b1ff02
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/a2b1ff02
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/a2b1ff02
Branch: refs/heads/HADOOP-13345
Commit: a2b1ff0257bde26d1f64454e97bc1225294a30b9
Parents: 5d5614f
Author: Andrew Wang <wa...@apache.org>
Authored: Mon Nov 28 11:54:43 2016 -0800
Committer: Andrew Wang <wa...@apache.org>
Committed: Mon Nov 28 11:54:43 2016 -0800
----------------------------------------------------------------------
.../hadoop/fs/viewfs/ChRootedFileSystem.java | 6 ++++
.../apache/hadoop/fs/viewfs/ViewFileSystem.java | 9 ++++++
.../fs/viewfs/TestViewFileSystemHdfs.java | 29 ++++++++++++++++++++
3 files changed, 44 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/a2b1ff02/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ChRootedFileSystem.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ChRootedFileSystem.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ChRootedFileSystem.java
index 9f61af6..272433f 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ChRootedFileSystem.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ChRootedFileSystem.java
@@ -222,6 +222,12 @@ class ChRootedFileSystem extends FilterFileSystem {
}
@Override
+ public FileChecksum getFileChecksum(final Path f, final long length)
+ throws IOException {
+ return super.getFileChecksum(fullPath(f), length);
+ }
+
+ @Override
public FileStatus getFileStatus(final Path f)
throws IOException {
return super.getFileStatus(fullPath(f));
http://git-wip-us.apache.org/repos/asf/hadoop/blob/a2b1ff02/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java
index 9061b2a..ed1bda2 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java
@@ -350,6 +350,15 @@ public class ViewFileSystem extends FileSystem {
return res.targetFileSystem.getFileChecksum(res.remainingPath);
}
+ @Override
+ public FileChecksum getFileChecksum(final Path f, final long length)
+ throws AccessControlException, FileNotFoundException,
+ IOException {
+ InodeTree.ResolveResult<FileSystem> res =
+ fsState.resolve(getUriPath(f), true);
+ return res.targetFileSystem.getFileChecksum(res.remainingPath, length);
+ }
+
private static FileStatus fixFileStatus(FileStatus orig,
Path qualified) throws IOException {
// FileStatus#getPath is a fully qualified path relative to the root of
http://git-wip-us.apache.org/repos/asf/hadoop/blob/a2b1ff02/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemHdfs.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemHdfs.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemHdfs.java
index 0e420d0..58b77f6 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemHdfs.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemHdfs.java
@@ -31,6 +31,8 @@ import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.crypto.key.JavaKeyStoreProvider;
import org.apache.hadoop.fs.CommonConfigurationKeys;
import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
+import org.apache.hadoop.fs.FileChecksum;
+import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.FileSystemTestHelper;
import org.apache.hadoop.fs.FsConstants;
@@ -218,4 +220,31 @@ public class TestViewFileSystemHdfs extends ViewFileSystemBaseTest {
DFSTestUtil.FsShellRun("-df /", 0, null, newConf);
DFSTestUtil.FsShellRun("-df", 0, null, newConf);
}
+
+ @Test
+ public void testFileChecksum() throws IOException {
+ ViewFileSystem viewFs = (ViewFileSystem) fsView;
+ Path mountDataRootPath = new Path("/data");
+ String fsTargetFileName = "debug.log";
+ Path fsTargetFilePath = new Path(targetTestRoot, "data/debug.log");
+ Path mountDataFilePath = new Path(mountDataRootPath, fsTargetFileName);
+
+ fileSystemTestHelper.createFile(fsTarget, fsTargetFilePath);
+ FileStatus fileStatus = viewFs.getFileStatus(mountDataFilePath);
+ long fileLength = fileStatus.getLen();
+
+ FileChecksum fileChecksumViaViewFs =
+ viewFs.getFileChecksum(mountDataFilePath);
+ FileChecksum fileChecksumViaTargetFs =
+ fsTarget.getFileChecksum(fsTargetFilePath);
+ Assert.assertTrue("File checksum not matching!",
+ fileChecksumViaViewFs.equals(fileChecksumViaTargetFs));
+
+ fileChecksumViaViewFs =
+ viewFs.getFileChecksum(mountDataFilePath, fileLength / 2);
+ fileChecksumViaTargetFs =
+ fsTarget.getFileChecksum(fsTargetFilePath, fileLength / 2);
+ Assert.assertTrue("File checksum not matching!",
+ fileChecksumViaViewFs.equals(fileChecksumViaTargetFs));
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org