Return-Path: X-Original-To: apmail-hadoop-common-commits-archive@www.apache.org Delivered-To: apmail-hadoop-common-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1897D19F0E for ; Tue, 5 Apr 2016 14:17:24 +0000 (UTC) Received: (qmail 85169 invoked by uid 500); 5 Apr 2016 14:17:23 -0000 Delivered-To: apmail-hadoop-common-commits-archive@hadoop.apache.org Received: (qmail 85106 invoked by uid 500); 5 Apr 2016 14:17:23 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: common-dev@hadoop.apache.org Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 85097 invoked by uid 99); 5 Apr 2016 14:17:23 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Apr 2016 14:17:23 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 76235DFDE0; Tue, 5 Apr 2016 14:17:23 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: kihwal@apache.org To: common-commits@hadoop.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: hadoop git commit: HDFS-10239. Fsshell mv fails if port usage doesn't match in src and destination paths. Contributed by Kuhu Shukla. Date: Tue, 5 Apr 2016 14:17:23 +0000 (UTC) Repository: hadoop Updated Branches: refs/heads/branch-2.8 9d3c51eb5 -> f9764d073 HDFS-10239. Fsshell mv fails if port usage doesn't match in src and destination paths. Contributed by Kuhu Shukla. Conflicts: hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSShell.java (cherry picked from commit ef3da823573cbf16fd1d84479330dd457f95e0ff) Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/f9764d07 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/f9764d07 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/f9764d07 Branch: refs/heads/branch-2.8 Commit: f9764d073fd8bc70ae63614f166aeac0325d6a4d Parents: 9d3c51e Author: Kihwal Lee Authored: Tue Apr 5 09:16:51 2016 -0500 Committer: Kihwal Lee Committed: Tue Apr 5 09:16:51 2016 -0500 ---------------------------------------------------------------------- .../apache/hadoop/fs/shell/MoveCommands.java | 6 +++- .../org/apache/hadoop/hdfs/TestDFSShell.java | 33 +++++++++++++++++++- 2 files changed, 37 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/f9764d07/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/MoveCommands.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/MoveCommands.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/MoveCommands.java index 1c7316a..20cecb4 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/MoveCommands.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/MoveCommands.java @@ -100,7 +100,11 @@ class MoveCommands { @Override protected void processPath(PathData src, PathData target) throws IOException { - if (!src.fs.getUri().equals(target.fs.getUri())) { + String srcUri = src.fs.getUri().getScheme() + "://" + + src.fs.getUri().getHost(); + String dstUri = target.fs.getUri().getScheme() + "://" + + target.fs.getUri().getHost(); + if (!srcUri.equals(dstUri)) { throw new PathIOException(src.toString(), "Does not match target filesystem"); } http://git-wip-us.apache.org/repos/asf/hadoop/blob/f9764d07/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSShell.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSShell.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSShell.java index b396762..a9791b3 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSShell.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSShell.java @@ -521,7 +521,38 @@ public class TestDFSShell { } } } - + + @Test + public void testMoveWithTargetPortEmpty() throws Exception { + Configuration conf = new HdfsConfiguration(); + MiniDFSCluster cluster = null; + try { + cluster = new MiniDFSCluster.Builder(conf) + .format(true) + .numDataNodes(2) + .nameNodePort(8020) + .waitSafeMode(true) + .build(); + FileSystem srcFs = cluster.getFileSystem(); + FsShell shell = new FsShell(); + shell.setConf(conf); + String[] argv = new String[2]; + argv[0] = "-mkdir"; + argv[1] = "/testfile"; + ToolRunner.run(shell, argv); + argv = new String[3]; + argv[0] = "-mv"; + argv[1] = srcFs.getUri() + "/testfile"; + argv[2] = "hdfs://localhost/testfile2"; + int ret = ToolRunner.run(shell, argv); + assertEquals("mv should have succeeded", 0, ret); + } finally { + if (cluster != null) { + cluster.shutdown(); + } + } + } + @Test (timeout = 30000) public void testURIPaths() throws Exception { Configuration srcConf = new HdfsConfiguration();