From 03163f9de260a45e4975d1718ac5592fc32764c2 Mon Sep 17 00:00:00 2001 From: wangzhaohui <32935220+wzhallright@users.noreply.github.com> Date: Thu, 18 May 2023 14:42:11 +0800 Subject: [PATCH] HDFS-17011. Fix the metric of "HttpPort" at DataNodeInfo (#5657). Contributed by Zhaohui Wang. Reviewed-by: Inigo Goiri Signed-off-by: Ayush Saxena --- .../java/org/apache/hadoop/hdfs/server/datanode/DataNode.java | 2 +- .../apache/hadoop/hdfs/server/datanode/TestDataNodeMXBean.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java index b781053a76..41088cf59c 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java @@ -3558,7 +3558,7 @@ public String getDataPort(){ @Override // DataNodeMXBean public String getHttpPort(){ - return this.getConf().get("dfs.datanode.info.port"); + return String.valueOf(infoPort); } @Override // DataNodeMXBean diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeMXBean.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeMXBean.java index 28330139bc..9241f57cf3 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeMXBean.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeMXBean.java @@ -92,6 +92,7 @@ public void testDataNodeMXBean() throws Exception { Assert.assertEquals(datanode.getRpcPort(),rpcPort); // get attribute "HttpPort" String httpPort = (String)mbs.getAttribute(mxbeanName, "HttpPort"); + Assert.assertNotNull(httpPort); Assert.assertEquals(datanode.getHttpPort(),httpPort); // get attribute "NamenodeAddresses" String namenodeAddresses = (String)mbs.getAttribute(mxbeanName,