|
@@ -142,6 +142,7 @@ public class DatanodeManager {
|
|
|
*/
|
|
|
private boolean hasClusterEverBeenMultiRack = false;
|
|
|
|
|
|
+ private final boolean checkIpHostnameInRegistration;
|
|
|
/**
|
|
|
* The number of datanodes for each software version. This list should change
|
|
|
* during rolling upgrades.
|
|
@@ -210,6 +211,12 @@ public class DatanodeManager {
|
|
|
LOG.info(DFSConfigKeys.DFS_BLOCK_INVALIDATE_LIMIT_KEY
|
|
|
+ "=" + this.blockInvalidateLimit);
|
|
|
|
|
|
+ this.checkIpHostnameInRegistration = conf.getBoolean(
|
|
|
+ DFSConfigKeys.DFS_NAMENODE_DATANODE_REGISTRATION_IP_HOSTNAME_CHECK_KEY,
|
|
|
+ DFSConfigKeys.DFS_NAMENODE_DATANODE_REGISTRATION_IP_HOSTNAME_CHECK_DEFAULT);
|
|
|
+ LOG.info(DFSConfigKeys.DFS_NAMENODE_DATANODE_REGISTRATION_IP_HOSTNAME_CHECK_KEY
|
|
|
+ + "=" + checkIpHostnameInRegistration);
|
|
|
+
|
|
|
this.avoidStaleDataNodesForRead = conf.getBoolean(
|
|
|
DFSConfigKeys.DFS_NAMENODE_AVOID_STALE_DATANODE_FOR_READ_KEY,
|
|
|
DFSConfigKeys.DFS_NAMENODE_AVOID_STALE_DATANODE_FOR_READ_DEFAULT);
|
|
@@ -733,11 +740,13 @@ public class DatanodeManager {
|
|
|
// Mostly called inside an RPC, update ip and peer hostname
|
|
|
String hostname = dnAddress.getHostName();
|
|
|
String ip = dnAddress.getHostAddress();
|
|
|
- if (!isNameResolved(dnAddress)) {
|
|
|
+ if (checkIpHostnameInRegistration && !isNameResolved(dnAddress)) {
|
|
|
// Reject registration of unresolved datanode to prevent performance
|
|
|
// impact of repetitive DNS lookups later.
|
|
|
- LOG.warn("Unresolved datanode registration from " + ip);
|
|
|
- throw new DisallowedDatanodeException(nodeReg);
|
|
|
+ final String message = "hostname cannot be resolved (ip="
|
|
|
+ + ip + ", hostname=" + hostname + ")";
|
|
|
+ LOG.warn("Unresolved datanode registration: " + message);
|
|
|
+ throw new DisallowedDatanodeException(nodeReg, message);
|
|
|
}
|
|
|
// update node registration with the ip and hostname from rpc request
|
|
|
nodeReg.setIpAddr(ip);
|
|
@@ -1185,17 +1194,17 @@ public class DatanodeManager {
|
|
|
/**
|
|
|
* Checks if name resolution was successful for the given address. If IP
|
|
|
* address and host name are the same, then it means name resolution has
|
|
|
- * failed. As a special case, the loopback address is also considered
|
|
|
+ * failed. As a special case, local addresses are also considered
|
|
|
* acceptable. This is particularly important on Windows, where 127.0.0.1 does
|
|
|
* not resolve to "localhost".
|
|
|
*
|
|
|
* @param address InetAddress to check
|
|
|
- * @return boolean true if name resolution successful or address is loopback
|
|
|
+ * @return boolean true if name resolution successful or address is local
|
|
|
*/
|
|
|
private static boolean isNameResolved(InetAddress address) {
|
|
|
String hostname = address.getHostName();
|
|
|
String ip = address.getHostAddress();
|
|
|
- return !hostname.equals(ip) || address.isLoopbackAddress();
|
|
|
+ return !hostname.equals(ip) || NetUtils.isLocalAddress(address);
|
|
|
}
|
|
|
|
|
|
private void setDatanodeDead(DatanodeDescriptor node) {
|