From 3ab2e79ad7786623798c5c8816fcdb4173b09da1 Mon Sep 17 00:00:00 2001 From: Steve Loughran Date: Sat, 8 Oct 2011 10:41:56 +0000 Subject: [PATCH] HDFS-2209 datanode connection failure logging git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1180353 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../org/apache/hadoop/hdfs/DFSInputStream.java | 14 +++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 1d63cab059..3aa6b1daa3 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -798,6 +798,9 @@ Release 0.23.0 - Unreleased HDFS-2209. Make MiniDFS easier to embed in other apps. (stevel) + HDFS-2205. Log message for failed connection to datanode is not + followed by a success message. (Ravi Prakash via stevel) + OPTIMIZATIONS HDFS-1458. Improve checkpoint performance by avoiding unnecessary image diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSInputStream.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSInputStream.java index e446122efb..2964ccb5a7 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSInputStream.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSInputStream.java @@ -388,6 +388,8 @@ private synchronized DatanodeInfo blockSeekTo(long target) throws IOException { DatanodeInfo chosenNode = null; int refetchToken = 1; // only need to get a new access token once + boolean connectFailedOnce = false; + while (true) { // // Compute desired block @@ -409,6 +411,10 @@ private synchronized DatanodeInfo blockSeekTo(long target) throws IOException { accessToken, offsetIntoBlock, blk.getNumBytes() - offsetIntoBlock, buffersize, verifyChecksum, dfsClient.clientName); + if(connectFailedOnce) { + DFSClient.LOG.info("Successfully connected to " + targetAddr + + " for block " + blk.getBlockId()); + } return chosenNode; } catch (IOException ex) { if (ex instanceof InvalidBlockTokenException && refetchToken > 0) { @@ -428,11 +434,9 @@ private synchronized DatanodeInfo blockSeekTo(long target) throws IOException { refetchToken--; fetchBlockAt(target); } else { - DFSClient.LOG.warn("Failed to connect to " + targetAddr - + ", add to deadNodes and continue " + ex); - if (DFSClient.LOG.isDebugEnabled()) { - DFSClient.LOG.debug("Connection failure ", ex); - } + connectFailedOnce = true; + DFSClient.LOG.warn("Failed to connect to " + targetAddr + " for block" + + ", add to deadNodes and continue. " + ex, ex); // Put chosen node into dead list, continue addToDeadNodes(chosenNode); }