Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5884,6 +5884,7 @@ private INodeFile checkUCBlock(ExtendedBlock block,
*/
void reportBadBlocks(LocatedBlock[] blocks) throws IOException {
checkOperation(OperationCategory.WRITE);
InetAddress remoteIp = Server.getRemoteIp();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ain't the correct way to do as I previously mentioned, use getClientMachine()
Something like this on top of your present changes

diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
index b624ab76cc0..ed95c912171 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
@@ -5882,9 +5882,8 @@ private INodeFile checkUCBlock(ExtendedBlock block,
   /**
    * Client is reporting some bad block locations.
    */
-  void reportBadBlocks(LocatedBlock[] blocks) throws IOException {
+  void reportBadBlocks(String clientMachine, LocatedBlock[] blocks) throws IOException {
     checkOperation(OperationCategory.WRITE);
-    InetAddress remoteIp = Server.getRemoteIp();
     writeLock();
     try {
       checkOperation(OperationCategory.WRITE);
@@ -5894,7 +5893,7 @@ void reportBadBlocks(LocatedBlock[] blocks) throws IOException {
         String[] storageIDs = blocks[i].getStorageIDs();
         for (int j = 0; j < nodes.length; j++) {
           NameNode.stateChangeLog.info("*DIR* reportBadBlocks for block: {} on"
-              + " datanode: {}" + " client: {}", blk, nodes[j].getXferAddr(), remoteIp);
+              + " datanode: {}" + " client: {}", blk, nodes[j].getXferAddr(), clientMachine);
           blockManager.findAndMarkBlockAsCorrupt(blk, nodes[j],
               storageIDs == null ? null: storageIDs[j],
               "client machine reported it");
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNodeRpcServer.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNodeRpcServer.java
index b19bfc13acf..eae945c7458 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNodeRpcServer.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNodeRpcServer.java
@@ -991,7 +991,7 @@ public boolean complete(String src, String clientName,
   @Override // ClientProtocol, DatanodeProtocol
   public void reportBadBlocks(LocatedBlock[] blocks) throws IOException {
     checkNNStartup();
-    namesystem.reportBadBlocks(blocks);
+    namesystem.reportBadBlocks(getClientMachine(), blocks);
   }
 
   @Override // ClientProtocol

writeLock();
try {
checkOperation(OperationCategory.WRITE);
Expand All @@ -5893,7 +5894,7 @@ void reportBadBlocks(LocatedBlock[] blocks) throws IOException {
String[] storageIDs = blocks[i].getStorageIDs();
for (int j = 0; j < nodes.length; j++) {
NameNode.stateChangeLog.info("*DIR* reportBadBlocks for block: {} on"
+ " datanode: {}", blk, nodes[j].getXferAddr());
+ " datanode: {}" + " client: {}", blk, nodes[j].getXferAddr(), remoteIp);
blockManager.findAndMarkBlockAsCorrupt(blk, nodes[j],
storageIDs == null ? null: storageIDs[j],
"client machine reported it");
Expand Down