hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ka...@apache.org
Subject [21/50] hadoop git commit: HDFS-10216. Distcp -diff throws exception when handling relative path. Contributed by Takashi Ohnishi.
Date Mon, 25 Apr 2016 05:36:05 GMT
HDFS-10216. Distcp -diff throws exception when handling relative path. Contributed by Takashi
Ohnishi.


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

Branch: refs/heads/YARN-1011
Commit: 404f57f328b00a42ec8b952ad08cd7a80207c7f2
Parents: 0d1c115
Author: Jing Zhao <jing9@apache.org>
Authored: Thu Apr 14 10:35:22 2016 -0700
Committer: Jing Zhao <jing9@apache.org>
Committed: Thu Apr 14 10:35:22 2016 -0700

----------------------------------------------------------------------
 .../apache/hadoop/tools/SimpleCopyListing.java  |  2 +-
 .../org/apache/hadoop/tools/TestDistCpSync.java | 38 ++++++++++++++++++++
 2 files changed, 39 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/404f57f3/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/SimpleCopyListing.java
----------------------------------------------------------------------
diff --git a/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/SimpleCopyListing.java
b/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/SimpleCopyListing.java
index d2598a4..cabb7e3 100644
--- a/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/SimpleCopyListing.java
+++ b/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/SimpleCopyListing.java
@@ -191,7 +191,7 @@ public class SimpleCopyListing extends CopyListing {
       authority = fs.getUri().getAuthority();
     }
 
-    return new Path(scheme, authority, path.toUri().getPath());
+    return new Path(scheme, authority, makeQualified(path).toUri().getPath());
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/hadoop/blob/404f57f3/hadoop-tools/hadoop-distcp/src/test/java/org/apache/hadoop/tools/TestDistCpSync.java
----------------------------------------------------------------------
diff --git a/hadoop-tools/hadoop-distcp/src/test/java/org/apache/hadoop/tools/TestDistCpSync.java
b/hadoop-tools/hadoop-distcp/src/test/java/org/apache/hadoop/tools/TestDistCpSync.java
index 04de8e4..90e6840 100644
--- a/hadoop-tools/hadoop-distcp/src/test/java/org/apache/hadoop/tools/TestDistCpSync.java
+++ b/hadoop-tools/hadoop-distcp/src/test/java/org/apache/hadoop/tools/TestDistCpSync.java
@@ -674,4 +674,42 @@ public class TestDistCpSync {
 
     testAndVerify(numCreatedModified);
   }
+
+  private void initData9(Path dir) throws Exception {
+    final Path foo = new Path(dir, "foo");
+    final Path foo_f1 = new Path(foo, "f1");
+
+    DFSTestUtil.createFile(dfs, foo_f1, BLOCK_SIZE, DATA_NUM, 0L);
+  }
+
+  private void changeData9(Path dir) throws Exception {
+    final Path foo = new Path(dir, "foo");
+    final Path foo_f2 = new Path(foo, "f2");
+
+    DFSTestUtil.createFile(dfs, foo_f2, BLOCK_SIZE, DATA_NUM, 0L);
+  }
+
+  /**
+   * Test a case where the source path is relative.
+   */
+  @Test
+  public void testSync9() throws Exception {
+
+    // use /user/$USER/source for source directory
+    Path sourcePath = new Path(dfs.getWorkingDirectory(), "source");
+    initData9(sourcePath);
+    initData9(target);
+    dfs.allowSnapshot(sourcePath);
+    dfs.allowSnapshot(target);
+    dfs.createSnapshot(sourcePath, "s1");
+    dfs.createSnapshot(target, "s1");
+    changeData9(sourcePath);
+    dfs.createSnapshot(sourcePath, "s2");
+
+    String[] args = new String[]{"-update","-diff", "s1", "s2",
+                                   "source", target.toString()};
+    new DistCp(conf, OptionsParser.parse(args)).execute();
+    verifyCopy(dfs.getFileStatus(sourcePath),
+                 dfs.getFileStatus(target), false);
+  }
 }


Mime
View raw message