From c951d56556053aa1d14d2481d1904932ef69c018 Mon Sep 17 00:00:00 2001 From: Steve Loughran Date: Mon, 14 Sep 2015 10:36:34 +0100 Subject: [PATCH] HDFS-9069. TestNameNodeMetricsLogger failing -port in use. (stevel) --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../hdfs/server/namenode/TestNameNodeMetricsLogger.java | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 2d5a31eebbb..dff5174a497 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -975,6 +975,9 @@ Release 2.8.0 - UNRELEASED HDFS-9041. Move entries in META-INF/services/o.a.h.fs.FileSystem to hdfs-client. (Mingliang Liu via wheat9) + HDFS-9069. TestNameNodeMetricsLogger failing -port in use. + (stevel) + Release 2.7.2 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeMetricsLogger.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeMetricsLogger.java index c8dc6ec0f03..6968bc4d3d8 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeMetricsLogger.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeMetricsLogger.java @@ -25,6 +25,7 @@ import org.apache.commons.logging.impl.Log4JLogger; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hdfs.HdfsConfiguration; import org.apache.hadoop.metrics2.util.MBeans; +import org.apache.hadoop.net.ServerSocketUtil; import org.apache.hadoop.test.GenericTestUtils; import org.apache.log4j.Appender; import org.apache.log4j.AppenderSkeleton; @@ -118,8 +119,8 @@ public class TestNameNodeMetricsLogger { return new TestNameNode(conf); } - private int getRandomPort() { - return 10000 + random.nextInt(50000); + private int getRandomPort() throws IOException { + return ServerSocketUtil.getPort(0, 10); } private void addAppender(Log log, Appender appender) {