smengcl commented on code in PR #9027:
URL: https://github.com/apache/hadoop/pull/9027#discussion_r4692063148
##########
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/CombinedHostFileManager.java:
##########
@@ -192,12 +216,27 @@ private void refresh(final String hostsFile, final int
readTimeout) throws IOExc
InetSocketAddress addr = parseEntry(hostsFile,
properties.getHostName(), properties.getPort());
if (addr != null) {
- hostProps.add(addr.getAddress(), properties);
+ hostProps.add(addr.getAddress(), properties,
+ otherAddressesOf(addr.getAddress()));
}
}
refresh(hostProps);
}
+ /**
+ * @return the host's other addresses, e.g. its IPv6 address for an entry
+ * given as an IPv4 literal.
+ */
+ private static Collection<InetAddress> otherAddressesOf(InetAddress addr) {
+ try {
+ return
Arrays.stream(InetAddress.getAllByName(addr.getCanonicalHostName()))
+ .filter(a -> !a.equals(addr)).collect(Collectors.toList());
Review Comment:
Thanks for checking. `InetAddress#getCanonicalHostName` already does this:
it returns the PTR name only if a forward lookup of that name includes the
original address, and otherwise returns the IP literal (see
`InetAddress#getHostFromNameService`). `getAllByName` on a literal returns just
`addr`, which the filter removes, so a stale or mismatched PTR adds no aliases.
I added a one line comment to make this explicit.
##########
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/DatanodeManager.java:
##########
@@ -1717,7 +1717,7 @@ public List<DatanodeDescriptor> getDatanodeListForReport(
nodes.add(dn);
}
- foundNodes.add(dn.getResolvedAddress());
+ foundNodes.add(hostConfigManager.getHostsFileAddress(dn));
Review Comment:
Good point. Added
`TestHostFileManager#testReportMatchesDatanodeRegisteredOnAlias`: a DataNode
registers on the IPv6 alias of an entry listed by IPv4, and the test asserts
that the DEAD report is empty and the ALL report has one node. It fails if
`getDatanodeListForReport` goes back to `getResolvedAddress()`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]