From 1037ee580f87e6bf13155834c36f26794381678b Mon Sep 17 00:00:00 2001 From: Yongjun Zhang Date: Fri, 2 Oct 2015 11:56:55 -0700 Subject: [PATCH] HDFS-9100. HDFS Balancer does not respect dfs.client.use.datanode.hostname. Contributed by Casey Brotherton. --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../hadoop/hdfs/server/balancer/Dispatcher.java | 11 +++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index a280addc6e..ee1f87fe4f 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -1481,6 +1481,9 @@ Release 2.8.0 - UNRELEASED HDFS-9001. DFSUtil.getNsServiceRpcUris() can return too many entries in a non-HA, non-federated cluster. (Daniel Templeton via atm) + HDFS-9100. HDFS Balancer does not respect dfs.client.use.datanode.hostname. + (Casey Brotherton via Yongjun Zhang) + Release 2.7.2 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/balancer/Dispatcher.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/balancer/Dispatcher.java index 3b36555b12..5b3eb360f7 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/balancer/Dispatcher.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/balancer/Dispatcher.java @@ -50,6 +50,7 @@ import org.apache.hadoop.hdfs.DFSUtil; import org.apache.hadoop.hdfs.DFSUtilClient; import org.apache.hadoop.hdfs.DistributedFileSystem; +import org.apache.hadoop.hdfs.client.HdfsClientConfigKeys; import org.apache.hadoop.hdfs.protocol.Block; import org.apache.hadoop.hdfs.protocol.DatanodeInfo; import org.apache.hadoop.hdfs.protocol.ExtendedBlock; @@ -122,6 +123,8 @@ public class Dispatcher { private final int ioFileBufferSize; + private final boolean connectToDnViaHostname; + static class Allocator { private final int max; private int count = 0; @@ -322,8 +325,9 @@ private void dispatch() { DataInputStream in = null; try { sock.connect( - NetUtils.createSocketAddr(target.getDatanodeInfo().getXferAddr()), - HdfsConstants.READ_TIMEOUT); + NetUtils.createSocketAddr(target.getDatanodeInfo(). + getXferAddr(Dispatcher.this.connectToDnViaHostname)), + HdfsConstants.READ_TIMEOUT); sock.setKeepAlive(true); @@ -942,6 +946,9 @@ public Dispatcher(NameNodeConnector nnc, Set includedNodes, DataTransferSaslUtil.getSaslPropertiesResolver(conf), TrustedChannelResolver.getInstance(conf), nnc.fallbackToSimpleAuth); this.ioFileBufferSize = DFSUtilClient.getIoFileBufferSize(conf); + this.connectToDnViaHostname = conf.getBoolean( + HdfsClientConfigKeys.DFS_CLIENT_USE_DN_HOSTNAME, + HdfsClientConfigKeys.DFS_CLIENT_USE_DN_HOSTNAME_DEFAULT); } public DistributedFileSystem getDistributedFileSystem() {