From e9b859f749103dc15fb4b4fc677f5586fceb20b3 Mon Sep 17 00:00:00 2001 From: Shweta Date: Fri, 5 Apr 2019 16:08:05 -0700 Subject: [PATCH] HDFS-14371. Improve Logging in FSNamesystem by adding parameterized logging. Contributed by Shweta. Signed-off-by: Wei-Chiu Chuang --- .../hdfs/server/namenode/FSNamesystem.java | 23 ++++++------------- 1 file changed, 7 insertions(+), 16 deletions(-) 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 ba806d2b52..82015b2f16 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 @@ -2413,10 +2413,8 @@ CryptoProtocolVersion chooseProtocolVersion( for (CryptoProtocolVersion c : supportedVersions) { if (c.equals(CryptoProtocolVersion.UNKNOWN)) { - if (LOG.isDebugEnabled()) { - LOG.debug("Ignoring unknown CryptoProtocolVersion provided by " + - "client: " + c.getUnknownValue()); - } + LOG.debug("Ignoring unknown CryptoProtocolVersion provided by " + + "client: {}", c.getUnknownValue()); continue; } if (c.equals(required)) { @@ -3693,9 +3691,7 @@ void commitBlockSynchronization(ExtendedBlock oldBlock, if (deleteblock) { // This may be a retry attempt so ignore the failure // to locate the block. - if (LOG.isDebugEnabled()) { - LOG.debug("Block (=" + oldBlock + ") not found"); - } + LOG.debug("Block (={}) not found", oldBlock); return; } else { throw new IOException("Block (=" + oldBlock + ") not found"); @@ -3729,9 +3725,8 @@ void commitBlockSynchronization(ExtendedBlock oldBlock, if ((!iFile.isUnderConstruction() || storedBlock.isComplete()) && iFile.getLastBlock().isComplete()) { if (LOG.isDebugEnabled()) { - LOG.debug("Unexpected block (=" + oldBlock - + ") since the file (=" + iFile.getLocalName() - + ") is not under construction"); + LOG.debug("Unexpected block (={}) since the file (={}) is not " + + "under construction", oldBlock, iFile.getLocalName()); } return; } @@ -5636,9 +5631,7 @@ Collection listCorruptFileBlocks(String path, } } cookieTab[0] = String.valueOf(skip); - if (LOG.isDebugEnabled()) { - LOG.debug("list corrupt file blocks returned: " + count); - } + LOG.debug("list corrupt file blocks returned: {}", count); return corruptFiles; } finally { readUnlock("listCorruptFileBlocks"); @@ -6370,9 +6363,7 @@ private List getCorruptFilesList() { } } } catch (StandbyException e) { - if (LOG.isDebugEnabled()) { - LOG.debug("Get corrupt file blocks returned error: " + e.getMessage()); - } + LOG.debug("Get corrupt file blocks returned error: {}", e.getMessage()); } catch (IOException e) { LOG.warn("Get corrupt file blocks returned error", e); }