|
@@ -19,6 +19,7 @@ package org.apache.hadoop.yarn.server.resourcemanager;
|
|
|
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.io.InputStream;
|
|
|
|
+import java.net.InetAddress;
|
|
import java.net.InetSocketAddress;
|
|
import java.net.InetSocketAddress;
|
|
import java.nio.ByteBuffer;
|
|
import java.nio.ByteBuffer;
|
|
import java.util.Arrays;
|
|
import java.util.Arrays;
|
|
@@ -39,6 +40,7 @@ import org.apache.commons.logging.LogFactory;
|
|
import org.apache.hadoop.conf.Configuration;
|
|
import org.apache.hadoop.conf.Configuration;
|
|
import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
|
|
import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
|
|
import org.apache.hadoop.ipc.Server;
|
|
import org.apache.hadoop.ipc.Server;
|
|
|
|
+import org.apache.hadoop.net.NetUtils;
|
|
import org.apache.hadoop.net.Node;
|
|
import org.apache.hadoop.net.Node;
|
|
import org.apache.hadoop.security.authorize.PolicyProvider;
|
|
import org.apache.hadoop.security.authorize.PolicyProvider;
|
|
import org.apache.hadoop.service.AbstractService;
|
|
import org.apache.hadoop.service.AbstractService;
|
|
@@ -126,6 +128,7 @@ public class ResourceTrackerService extends AbstractService implements
|
|
private DynamicResourceConfiguration drConf;
|
|
private DynamicResourceConfiguration drConf;
|
|
|
|
|
|
private final AtomicLong timelineCollectorVersion = new AtomicLong(0);
|
|
private final AtomicLong timelineCollectorVersion = new AtomicLong(0);
|
|
|
|
+ private boolean checkIpHostnameInRegistration;
|
|
|
|
|
|
public ResourceTrackerService(RMContext rmContext,
|
|
public ResourceTrackerService(RMContext rmContext,
|
|
NodesListManager nodesListManager,
|
|
NodesListManager nodesListManager,
|
|
@@ -162,6 +165,9 @@ public class ResourceTrackerService extends AbstractService implements
|
|
+ " should be larger than 0.");
|
|
+ " should be larger than 0.");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ checkIpHostnameInRegistration = conf.getBoolean(
|
|
|
|
+ YarnConfiguration.RM_NM_REGISTRATION_IP_HOSTNAME_CHECK_KEY,
|
|
|
|
+ YarnConfiguration.DEFAULT_RM_NM_REGISTRATION_IP_HOSTNAME_CHECK_KEY);
|
|
minAllocMb = conf.getInt(
|
|
minAllocMb = conf.getInt(
|
|
YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_MB,
|
|
YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_MB,
|
|
YarnConfiguration.DEFAULT_RM_SCHEDULER_MINIMUM_ALLOCATION_MB);
|
|
YarnConfiguration.DEFAULT_RM_SCHEDULER_MINIMUM_ALLOCATION_MB);
|
|
@@ -350,6 +356,23 @@ public class ResourceTrackerService extends AbstractService implements
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (checkIpHostnameInRegistration) {
|
|
|
|
+ InetSocketAddress nmAddress =
|
|
|
|
+ NetUtils.createSocketAddrForHost(host, cmPort);
|
|
|
|
+ InetAddress inetAddress = Server.getRemoteIp();
|
|
|
|
+ if (inetAddress != null && nmAddress.isUnresolved()) {
|
|
|
|
+ // Reject registration of unresolved nm to prevent resourcemanager
|
|
|
|
+ // getting stuck at allocations.
|
|
|
|
+ final String message =
|
|
|
|
+ "hostname cannot be resolved (ip=" + inetAddress.getHostAddress()
|
|
|
|
+ + ", hostname=" + host + ")";
|
|
|
|
+ LOG.warn("Unresolved nodemanager registration: " + message);
|
|
|
|
+ response.setDiagnosticsMessage(message);
|
|
|
|
+ response.setNodeAction(NodeAction.SHUTDOWN);
|
|
|
|
+ return response;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
// Check if this node is a 'valid' node
|
|
// Check if this node is a 'valid' node
|
|
if (!this.nodesListManager.isValidNode(host) &&
|
|
if (!this.nodesListManager.isValidNode(host) &&
|
|
!isNodeInDecommissioning(nodeId)) {
|
|
!isNodeInDecommissioning(nodeId)) {
|