diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/balancer/NameNodeConnector.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/balancer/NameNodeConnector.java index 7f54c63303..4e2079298d 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/balancer/NameNodeConnector.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/balancer/NameNodeConnector.java @@ -21,6 +21,7 @@ import java.io.IOException; import java.io.OutputStream; import java.net.InetAddress; +import java.net.InetSocketAddress; import java.net.URI; import java.util.ArrayList; import java.util.Arrays; @@ -255,6 +256,7 @@ public BlocksWithLocations getBlocks(DatanodeInfo datanode, long size, long } boolean isRequestStandby = false; NamenodeProtocol nnproxy = null; + InetSocketAddress standbyAddress = null; try { if (requestToStandby && nsId != null && HAUtil.isHAEnabled(config, nsId)) { @@ -264,8 +266,9 @@ public BlocksWithLocations getBlocks(DatanodeInfo datanode, long size, long try { if (proxy.getHAServiceState().equals( HAServiceProtocol.HAServiceState.STANDBY)) { + standbyAddress = RPC.getServerAddress(proxy); NamenodeProtocol sbn = NameNodeProxies.createNonHAProxy( - config, RPC.getServerAddress(proxy), NamenodeProtocol.class, + config, standbyAddress, NamenodeProtocol.class, UserGroupInformation.getCurrentUser(), false).getProxy(); nnproxy = sbn; isRequestStandby = true; @@ -287,7 +290,8 @@ public BlocksWithLocations getBlocks(DatanodeInfo datanode, long size, long return nnproxy.getBlocks(datanode, size, minBlockSize); } finally { if (isRequestStandby) { - LOG.info("Request #getBlocks to Standby NameNode success."); + LOG.info("Request #getBlocks to Standby NameNode success. " + + "remoteAddress: {}", standbyAddress.getHostString()); } } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/balancer/TestBalancerWithHANameNodes.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/balancer/TestBalancerWithHANameNodes.java index 8241f25e4a..cdfa76a9d1 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/balancer/TestBalancerWithHANameNodes.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/balancer/TestBalancerWithHANameNodes.java @@ -199,13 +199,16 @@ public void testBalancerRequestSBNWithHA() throws Exception { try { cluster.waitActive(); cluster.transitionToActive(0); + String standbyNameNode = cluster.getNameNode(1). + getNameNodeAddress().getHostString(); Thread.sleep(500); client = NameNodeProxies.createProxy(conf, FileSystem.getDefaultUri(conf), ClientProtocol.class).getProxy(); doTest(conf); // Check getBlocks request to Standby NameNode. assertTrue(log.getOutput().contains( - "Request #getBlocks to Standby NameNode success.")); + "Request #getBlocks to Standby NameNode success. remoteAddress: " + + standbyNameNode)); } finally { cluster.shutdown(); }