YARN-848. Fix NodeManager to register with RM using the fully qualified hostname. Contributed by Hitesh Shah.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1494385 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Siddharth Seth 2013-06-18 23:49:23 +00:00
parent 243bcd367f
commit ab647cfcdb
3 changed files with 15 additions and 2 deletions

View File

@ -616,6 +616,9 @@ Release 2.1.0-beta - UNRELEASED
YARN-812. Set default logger for application summary logger to
hadoop.root.logger. (sseth via acmurthy)
YARN-848. Nodemanager does not register with RM using the fully qualified
hostname. (Hitesh Shah via sseth)
BREAKDOWN OF HADOOP-8562 SUBTASKS AND RELATED JIRAS
YARN-158. Yarn creating package-info.java must not depend on sh.

View File

@ -253,8 +253,9 @@ public class ContainerManagerImpl extends CompositeService implements
this.setBlockNewContainerRequests(true);
server.start();
InetSocketAddress connectAddress = NetUtils.getConnectAddress(server);
NodeId nodeId = NodeId.newInstance(connectAddress.getHostName(),
connectAddress.getPort());
NodeId nodeId = NodeId.newInstance(
connectAddress.getAddress().getCanonicalHostName(),
connectAddress.getPort());
((NodeManager.NMContext)context).setNodeId(nodeId);
this.context.getNMTokenSecretManager().setNodeId(nodeId);
this.context.getContainerTokenSecretManager().setNodeId(nodeId);

View File

@ -23,6 +23,7 @@ import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.InetAddress;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
@ -125,6 +126,14 @@ public class TestContainerManager extends BaseContainerManagerTest {
containerManager.start();
InetAddress localAddr = InetAddress.getLocalHost();
String fqdn = localAddr.getCanonicalHostName();
if (!localAddr.getHostAddress().equals(fqdn)) {
// only check if fqdn is not same as ip
// api returns ip in case of resolution failure
Assert.assertEquals(fqdn, context.getNodeId().getHost());
}
// Just do a query for a non-existing container.
boolean throwsException = false;
try {