From 6464507cd1e71a2385c229cb70cf869698c7dc12 Mon Sep 17 00:00:00 2001 From: huhaiyang Date: Sat, 3 Feb 2024 19:20:04 +0800 Subject: [PATCH] HDFS-17369. Add uuid into datanode info for NameNodeMXBean (#6521) Contributed by Haiyang Hu. Reviewed-by: ZanderXu Signed-off-by: Shilun Fan --- .../org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java | 4 ++++ .../hadoop/hdfs/server/namenode/TestNameNodeMXBean.java | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java index 277cc42222..44b79a3e0e 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java @@ -6662,6 +6662,7 @@ public String getLiveNodes() { .put("infoSecureAddr", node.getInfoSecureAddr()) .put("xferaddr", node.getXferAddr()) .put("location", node.getNetworkLocation()) + .put("uuid", node.getDatanodeUuid()) .put("lastContact", getLastContact(node)) .put("usedSpace", getDfsUsed(node)) .put("adminState", node.getAdminState().toString()) @@ -6715,6 +6716,7 @@ public String getDeadNodes() { .put("adminState", node.getAdminState().toString()) .put("xferaddr", node.getXferAddr()) .put("location", node.getNetworkLocation()) + .put("uuid", node.getDatanodeUuid()) .build(); info.put(node.getXferAddrWithHostname(), innerinfo); } @@ -6737,6 +6739,7 @@ public String getDecomNodes() { . builder() .put("xferaddr", node.getXferAddr()) .put("location", node.getNetworkLocation()) + .put("uuid", node.getDatanodeUuid()) .put("underReplicatedBlocks", node.getLeavingServiceStatus().getUnderReplicatedBlocks()) .put("decommissionOnlyReplicas", @@ -6767,6 +6770,7 @@ public String getEnteringMaintenanceNodes() { . builder() .put("xferaddr", node.getXferAddr()) .put("location", node.getNetworkLocation()) + .put("uuid", node.getDatanodeUuid()) .put("underReplicatedBlocks", node.getLeavingServiceStatus().getUnderReplicatedBlocks()) .put("maintenanceOnlyReplicas", diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeMXBean.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeMXBean.java index bc46c4857a..89ae01ddd2 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeMXBean.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeMXBean.java @@ -211,7 +211,7 @@ public void testNameNodeMXBeanInfo() throws Exception { cluster.getDataNodes().get(3).getDatanodeId()); decommissionedNode.setDecommissioned(); - // Assert the location field is included in the mxbeanName + // Assert the location and uuid field is included in the mxbeanName // under different states String alivenodeinfo1 = (String) (mbs.getAttribute(mxbeanName, "LiveNodes")); @@ -219,6 +219,7 @@ public void testNameNodeMXBeanInfo() throws Exception { (Map>) JSON.parse(alivenodeinfo1); for (Map liveNode : liveNodes1.values()) { assertTrue(liveNode.containsKey("location")); + assertTrue(liveNode.containsKey("uuid")); } // get attributes DeadNodes