HDFS-16194. Simplify the code with DatanodeID#getXferAddrWithHostname (#3354). Contributed by tomscut.

This commit is contained in:
litao 2021-09-05 14:19:01 +08:00 committed by GitHub
parent cc6b545365
commit 364a1fbfb3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 7 deletions

View File

@ -484,7 +484,7 @@ private String getNodesImpl(final DatanodeReportType type) {
innerinfo.put("blockPoolUsed", node.getBlockPoolUsed()); innerinfo.put("blockPoolUsed", node.getBlockPoolUsed());
innerinfo.put("blockPoolUsedPercent", node.getBlockPoolUsedPercent()); innerinfo.put("blockPoolUsedPercent", node.getBlockPoolUsedPercent());
innerinfo.put("volfails", -1); // node.getVolumeFailures() innerinfo.put("volfails", -1); // node.getVolumeFailures()
info.put(node.getHostName() + ":" + node.getXferPort(), info.put(node.getXferAddrWithHostname(),
Collections.unmodifiableMap(innerinfo)); Collections.unmodifiableMap(innerinfo));
} }
} catch (StandbyException e) { } catch (StandbyException e) {

View File

@ -1815,10 +1815,9 @@ public SaslDataTransferServer getSaslServer() {
} }
/** /**
* @return name useful for logging * @return name useful for logging or display
*/ */
public String getDisplayName() { public String getDisplayName() {
// NB: our DatanodeID may not be set yet
return hostName + ":" + getXferPort(); return hostName + ":" + getXferPort();
} }

View File

@ -6537,7 +6537,7 @@ public String getLiveNodes() {
if (node.getUpgradeDomain() != null) { if (node.getUpgradeDomain() != null) {
innerinfo.put("upgradeDomain", node.getUpgradeDomain()); innerinfo.put("upgradeDomain", node.getUpgradeDomain());
} }
info.put(node.getHostName() + ":" + node.getXferPort(), innerinfo.build()); info.put(node.getXferAddrWithHostname(), innerinfo.build());
} }
return JSON.toString(info); return JSON.toString(info);
} }
@ -6560,7 +6560,7 @@ public String getDeadNodes() {
.put("xferaddr", node.getXferAddr()) .put("xferaddr", node.getXferAddr())
.put("location", node.getNetworkLocation()) .put("location", node.getNetworkLocation())
.build(); .build();
info.put(node.getHostName() + ":" + node.getXferPort(), innerinfo); info.put(node.getXferAddrWithHostname(), innerinfo);
} }
return JSON.toString(info); return JSON.toString(info);
} }
@ -6588,7 +6588,7 @@ public String getDecomNodes() {
.put("underReplicateInOpenFiles", .put("underReplicateInOpenFiles",
node.getLeavingServiceStatus().getUnderReplicatedInOpenFiles()) node.getLeavingServiceStatus().getUnderReplicatedInOpenFiles())
.build(); .build();
info.put(node.getHostName() + ":" + node.getXferPort(), innerinfo); info.put(node.getXferAddrWithHostname(), innerinfo);
} }
return JSON.toString(info); return JSON.toString(info);
} }
@ -6616,7 +6616,7 @@ public String getEnteringMaintenanceNodes() {
.put("underReplicateInOpenFiles", .put("underReplicateInOpenFiles",
node.getLeavingServiceStatus().getUnderReplicatedInOpenFiles()) node.getLeavingServiceStatus().getUnderReplicatedInOpenFiles())
.build(); .build();
nodesMap.put(node.getHostName() + ":" + node.getXferPort(), attrMap); nodesMap.put(node.getXferAddrWithHostname(), attrMap);
} }
return JSON.toString(nodesMap); return JSON.toString(nodesMap);
} }