You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by he...@apache.org on 2021/09/05 06:19:26 UTC
[hadoop] branch trunk updated: HDFS-16194. Simplify the code with
DatanodeID#getXferAddrWithHostname (#3354). Contributed by tomscut.
This is an automated email from the ASF dual-hosted git repository.
hexiaoqiao pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/trunk by this push:
new 364a1fb HDFS-16194. Simplify the code with DatanodeID#getXferAddrWithHostname (#3354). Contributed by tomscut.
364a1fb is described below
commit 364a1fbfb3e0bb18a0218c7ae8eeff6f5c09b6e6
Author: litao <to...@gmail.com>
AuthorDate: Sun Sep 5 14:19:01 2021 +0800
HDFS-16194. Simplify the code with DatanodeID#getXferAddrWithHostname (#3354). Contributed by tomscut.
---
.../hdfs/server/federation/metrics/NamenodeBeanMetrics.java | 2 +-
.../java/org/apache/hadoop/hdfs/server/datanode/DataNode.java | 3 +--
.../java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java | 8 ++++----
3 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/metrics/NamenodeBeanMetrics.java b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/metrics/NamenodeBeanMetrics.java
index 6a6b3da..c323942 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/metrics/NamenodeBeanMetrics.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/metrics/NamenodeBeanMetrics.java
@@ -484,7 +484,7 @@ public class NamenodeBeanMetrics
innerinfo.put("blockPoolUsed", node.getBlockPoolUsed());
innerinfo.put("blockPoolUsedPercent", node.getBlockPoolUsedPercent());
innerinfo.put("volfails", -1); // node.getVolumeFailures()
- info.put(node.getHostName() + ":" + node.getXferPort(),
+ info.put(node.getXferAddrWithHostname(),
Collections.unmodifiableMap(innerinfo));
}
} catch (StandbyException e) {
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 73dc584..e8ba99a 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
@@ -1815,10 +1815,9 @@ public class DataNode extends ReconfigurableBase
}
/**
- * @return name useful for logging
+ * @return name useful for logging or display
*/
public String getDisplayName() {
- // NB: our DatanodeID may not be set yet
return hostName + ":" + getXferPort();
}
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 7ccaae9..c4051b2 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
@@ -6537,7 +6537,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
if (node.getUpgradeDomain() != null) {
innerinfo.put("upgradeDomain", node.getUpgradeDomain());
}
- info.put(node.getHostName() + ":" + node.getXferPort(), innerinfo.build());
+ info.put(node.getXferAddrWithHostname(), innerinfo.build());
}
return JSON.toString(info);
}
@@ -6560,7 +6560,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
.put("xferaddr", node.getXferAddr())
.put("location", node.getNetworkLocation())
.build();
- info.put(node.getHostName() + ":" + node.getXferPort(), innerinfo);
+ info.put(node.getXferAddrWithHostname(), innerinfo);
}
return JSON.toString(info);
}
@@ -6588,7 +6588,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
.put("underReplicateInOpenFiles",
node.getLeavingServiceStatus().getUnderReplicatedInOpenFiles())
.build();
- info.put(node.getHostName() + ":" + node.getXferPort(), innerinfo);
+ info.put(node.getXferAddrWithHostname(), innerinfo);
}
return JSON.toString(info);
}
@@ -6616,7 +6616,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
.put("underReplicateInOpenFiles",
node.getLeavingServiceStatus().getUnderReplicatedInOpenFiles())
.build();
- nodesMap.put(node.getHostName() + ":" + node.getXferPort(), attrMap);
+ nodesMap.put(node.getXferAddrWithHostname(), attrMap);
}
return JSON.toString(nodesMap);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org