From b2d4b7b1b902aa830d44889d7747a4e1b816ab9d Mon Sep 17 00:00:00 2001 From: Brahma Reddy Battula Date: Thu, 17 Nov 2016 10:22:30 +0530 Subject: [PATCH] HDFS-11134. Fix bind exception threw in TestRenameWhileOpen. Contributed By Yiqun Lin. --- .../hadoop/hdfs/TestRenameWhileOpen.java | 45 +++++-------------- 1 file changed, 12 insertions(+), 33 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestRenameWhileOpen.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestRenameWhileOpen.java index 949fc74de2..827577d1f8 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestRenameWhileOpen.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestRenameWhileOpen.java @@ -72,8 +72,6 @@ public void testWhileOpenRenameParent() throws IOException { doNothing().when(spyLog).endCurrentLogSegment(Mockito.anyBoolean()); DFSTestUtil.setEditLogForTesting(cluster.getNamesystem(), spyLog); - final int nnport = cluster.getNameNodePort(); - // create file1. Path dir1 = new Path("/user/a+b/dir1"); Path file1 = new Path(dir1, "file1"); @@ -111,22 +109,18 @@ public void testWhileOpenRenameParent() throws IOException { // for file3, since we just added a block to that file. cluster.getNameNode().stop(); - // Restart cluster with the same namenode port as before. + // Restart cluster. cluster.shutdown(); try {Thread.sleep(2*MAX_IDLE_TIME);} catch (InterruptedException e) {} - cluster = new MiniDFSCluster.Builder(conf).nameNodePort(nnport) - .format(false) - .build(); + cluster = new MiniDFSCluster.Builder(conf).format(false).build(); cluster.waitActive(); // restart cluster yet again. This triggers the code to read in // persistent leases from the edit log. cluster.shutdown(); try {Thread.sleep(5000);} catch (InterruptedException e) {} - cluster = new MiniDFSCluster.Builder(conf).nameNodePort(nnport) - .format(false) - .build(); + cluster = new MiniDFSCluster.Builder(conf).format(false).build(); cluster.waitActive(); fs = cluster.getFileSystem(); @@ -161,7 +155,6 @@ public void testWhileOpenRenameParentToNonexistentDir() throws IOException { try { cluster.waitActive(); fs = cluster.getFileSystem(); - final int nnport = cluster.getNameNodePort(); // create file1. Path dir1 = new Path("/user/dir1"); @@ -185,22 +178,18 @@ public void testWhileOpenRenameParentToNonexistentDir() throws IOException { Path dir3 = new Path("/user/dir3"); fs.rename(dir1, dir3); - // restart cluster with the same namenode port as before. + // restart cluster. // This ensures that leases are persisted in fsimage. cluster.shutdown(); try {Thread.sleep(2*MAX_IDLE_TIME);} catch (InterruptedException e) {} - cluster = new MiniDFSCluster.Builder(conf).nameNodePort(nnport) - .format(false) - .build(); + cluster = new MiniDFSCluster.Builder(conf).format(false).build(); cluster.waitActive(); // restart cluster yet again. This triggers the code to read in // persistent leases from fsimage. cluster.shutdown(); try {Thread.sleep(5000);} catch (InterruptedException e) {} - cluster = new MiniDFSCluster.Builder(conf).nameNodePort(nnport) - .format(false) - .build(); + cluster = new MiniDFSCluster.Builder(conf).format(false).build(); cluster.waitActive(); fs = cluster.getFileSystem(); @@ -236,7 +225,6 @@ public void testWhileOpenRenameToExistentDirectory() throws IOException { try { cluster.waitActive(); fs = cluster.getFileSystem(); - final int nnport = cluster.getNameNodePort(); // create file1. Path dir1 = new Path("/user/dir1"); @@ -252,22 +240,18 @@ public void testWhileOpenRenameToExistentDirectory() throws IOException { fs.rename(file1, dir2); - // restart cluster with the same namenode port as before. + // restart cluster. // This ensures that leases are persisted in fsimage. cluster.shutdown(); try {Thread.sleep(2*MAX_IDLE_TIME);} catch (InterruptedException e) {} - cluster = new MiniDFSCluster.Builder(conf).nameNodePort(nnport) - .format(false) - .build(); + cluster = new MiniDFSCluster.Builder(conf).format(false).build(); cluster.waitActive(); // restart cluster yet again. This triggers the code to read in // persistent leases from fsimage. cluster.shutdown(); try {Thread.sleep(5000);} catch (InterruptedException e) {} - cluster = new MiniDFSCluster.Builder(conf).nameNodePort(nnport) - .format(false) - .build(); + cluster = new MiniDFSCluster.Builder(conf).format(false).build(); cluster.waitActive(); fs = cluster.getFileSystem(); @@ -301,7 +285,6 @@ public void testWhileOpenRenameToNonExistentDirectory() throws IOException { try { cluster.waitActive(); fs = cluster.getFileSystem(); - final int nnport = cluster.getNameNodePort(); // create file1. Path dir1 = new Path("/user/dir1"); @@ -316,22 +299,18 @@ public void testWhileOpenRenameToNonExistentDirectory() throws IOException { fs.rename(file1, dir2); - // restart cluster with the same namenode port as before. + // restart cluster. // This ensures that leases are persisted in fsimage. cluster.shutdown(); try {Thread.sleep(2*MAX_IDLE_TIME);} catch (InterruptedException e) {} - cluster = new MiniDFSCluster.Builder(conf).nameNodePort(nnport) - .format(false) - .build(); + cluster = new MiniDFSCluster.Builder(conf).format(false).build(); cluster.waitActive(); // restart cluster yet again. This triggers the code to read in // persistent leases from fsimage. cluster.shutdown(); try {Thread.sleep(5000);} catch (InterruptedException e) {} - cluster = new MiniDFSCluster.Builder(conf).nameNodePort(nnport) - .format(false) - .build(); + cluster = new MiniDFSCluster.Builder(conf).format(false).build(); cluster.waitActive(); fs = cluster.getFileSystem();