Browse Source

HDFS-9100. HDFS Balancer does not respect dfs.client.use.datanode.hostname. Contributed by Casey Brotherton.

Yongjun Zhang 9 years ago
parent
commit
1037ee580f

+ 3 - 0
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

+ 9 - 2
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/balancer/Dispatcher.java

@@ -50,6 +50,7 @@ import org.apache.hadoop.fs.StorageType;
 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 @@ public class Dispatcher {
       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 class Dispatcher {
         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() {