You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by he...@apache.org on 2022/05/22 13:59:56 UTC

[hadoop] branch trunk updated: HDFS-16584.Record StandbyNameNode information when Balancer is running. (#4333). Contributed by JiangHua Zhu.

This is an automated email from the ASF dual-hosted git repository.

hexiaoqiao pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 4fd4208439c HDFS-16584.Record StandbyNameNode information when Balancer is running. (#4333). Contributed by JiangHua Zhu.
4fd4208439c is described below

commit 4fd4208439c997b90f64942c14231228ef82c4f7
Author: jianghuazhu <74...@qq.com>
AuthorDate: Sun May 22 21:59:38 2022 +0800

    HDFS-16584.Record StandbyNameNode information when Balancer is running. (#4333). Contributed by JiangHua Zhu.
    
    Signed-off-by: litao <to...@gmail.com>
    Signed-off-by: He Xiaoqiao <he...@apache.org>
---
 .../hadoop/hdfs/server/balancer/NameNodeConnector.java     | 14 +++++++++++---
 .../hdfs/server/balancer/TestBalancerWithHANameNodes.java  |  8 ++++++--
 2 files changed, 17 insertions(+), 5 deletions(-)

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 238457bcb86..34be025203d 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.Closeable;
 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;
@@ -260,13 +261,15 @@ public class NameNodeConnector implements Closeable {
     }
     boolean isRequestStandby = false;
     NamenodeProtocol nnProxy = null;
+    InetSocketAddress standbyAddress = null;
     try {
       ProxyPair proxyPair = getProxy();
       isRequestStandby = proxyPair.isRequestStandby;
       ClientProtocol proxy = proxyPair.clientProtocol;
       if (isRequestStandby) {
+        standbyAddress = RPC.getServerAddress(proxy);
         nnProxy = NameNodeProxies.createNonHAProxy(
-            config, RPC.getServerAddress(proxy), NamenodeProtocol.class,
+            config, standbyAddress, NamenodeProtocol.class,
             UserGroupInformation.getCurrentUser(), false).getProxy();
       } else {
         nnProxy = namenode;
@@ -274,7 +277,8 @@ public class NameNodeConnector implements Closeable {
       return nnProxy.getBlocks(datanode, size, minBlockSize, timeInterval);
     } finally {
       if (isRequestStandby) {
-        LOG.info("Request #getBlocks to Standby NameNode success.");
+        LOG.info("Request #getBlocks to Standby NameNode success. " +
+            "remoteAddress: {}", standbyAddress.getHostString());
       }
     }
   }
@@ -297,15 +301,19 @@ public class NameNodeConnector implements Closeable {
   public DatanodeStorageReport[] getLiveDatanodeStorageReport()
       throws IOException {
     boolean isRequestStandby = false;
+    InetSocketAddress standbyAddress = null;
     try {
       ProxyPair proxyPair = getProxy();
       isRequestStandby = proxyPair.isRequestStandby;
       ClientProtocol proxy = proxyPair.clientProtocol;
+      if (isRequestStandby) {
+        standbyAddress = RPC.getServerAddress(proxy);
+      }
       return proxy.getDatanodeStorageReport(DatanodeReportType.LIVE);
     } finally {
       if (isRequestStandby) {
         LOG.info("Request #getLiveDatanodeStorageReport to Standby " +
-            "NameNode success.");
+            "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 9b4ba5ccb73..d69051c8d7a 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
@@ -202,15 +202,19 @@ public class TestBalancerWithHANameNodes {
     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));
       assertTrue(log.getOutput().contains(
-          "Request #getLiveDatanodeStorageReport to Standby NameNode success"));
+          "Request #getLiveDatanodeStorageReport to Standby NameNode success. " +
+            "remoteAddress: " + standbyNameNode));
     } finally {
       cluster.shutdown();
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org