HDFS-9069. TestNameNodeMetricsLogger failing -port in use. (stevel)

This commit is contained in:
Steve Loughran 2015-09-14 10:36:34 +01:00
parent b705d9d0ac
commit c951d56556
2 changed files with 6 additions and 2 deletions

View File

@ -975,6 +975,9 @@ Release 2.8.0 - UNRELEASED
HDFS-9041. Move entries in META-INF/services/o.a.h.fs.FileSystem to HDFS-9041. Move entries in META-INF/services/o.a.h.fs.FileSystem to
hdfs-client. (Mingliang Liu via wheat9) hdfs-client. (Mingliang Liu via wheat9)
HDFS-9069. TestNameNodeMetricsLogger failing -port in use.
(stevel)
Release 2.7.2 - UNRELEASED Release 2.7.2 - UNRELEASED
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -25,6 +25,7 @@ import org.apache.commons.logging.impl.Log4JLogger;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hdfs.HdfsConfiguration; import org.apache.hadoop.hdfs.HdfsConfiguration;
import org.apache.hadoop.metrics2.util.MBeans; import org.apache.hadoop.metrics2.util.MBeans;
import org.apache.hadoop.net.ServerSocketUtil;
import org.apache.hadoop.test.GenericTestUtils; import org.apache.hadoop.test.GenericTestUtils;
import org.apache.log4j.Appender; import org.apache.log4j.Appender;
import org.apache.log4j.AppenderSkeleton; import org.apache.log4j.AppenderSkeleton;
@ -118,8 +119,8 @@ public class TestNameNodeMetricsLogger {
return new TestNameNode(conf); return new TestNameNode(conf);
} }
private int getRandomPort() { private int getRandomPort() throws IOException {
return 10000 + random.nextInt(50000); return ServerSocketUtil.getPort(0, 10);
} }
private void addAppender(Log log, Appender appender) { private void addAppender(Log log, Appender appender) {