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
This commit is contained in:
Kihwal Lee 2016-04-05 09:07:24 -05:00
parent eeff2e35f8
commit ef3da82357
2 changed files with 37 additions and 2 deletions

View File

@ -100,7 +100,11 @@ class MoveCommands {
@Override @Override
protected void processPath(PathData src, PathData target) throws IOException { 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(), throw new PathIOException(src.toString(),
"Does not match target filesystem"); "Does not match target filesystem");
} }

View File

@ -522,6 +522,37 @@ 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) @Test (timeout = 30000)
public void testURIPaths() throws Exception { public void testURIPaths() throws Exception {
Configuration srcConf = new HdfsConfiguration(); Configuration srcConf = new HdfsConfiguration();