From 6955771261ad0047056eb7c2505ba9915fce60d3 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 b1ba39bcbe..cb0fae97af 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -1322,6 +1322,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 c8dc6ec0f0..6968bc4d3d 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.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 @@ private NameNode makeNameNode(boolean enableMetricsLogging) 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) {