From 262d769b4d31d03aa4bf78ef9ebb5774154d5a64 Mon Sep 17 00:00:00 2001 From: Tsz-Wo Nicholas Sze Date: Thu, 7 Apr 2016 12:36:29 +0800 Subject: [PATCH] HDFS-10186. DirectoryScanner: Improve logs by adding full path of both actual and expected block directories. Contributed by Rakesh R --- .../hdfs/server/datanode/DirectoryScanner.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DirectoryScanner.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DirectoryScanner.java index 61dfb14b9f4..dd864a56a18 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DirectoryScanner.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DirectoryScanner.java @@ -659,8 +659,7 @@ public class DirectoryScanner implements Runnable { break; } } - verifyFileLocation(blockFile.getParentFile(), bpFinalizedDir, - blockId); + verifyFileLocation(blockFile, bpFinalizedDir, blockId); report.add(new ScanInfo(blockId, blockFile, metaFile, vol)); } return report; @@ -670,12 +669,15 @@ public class DirectoryScanner implements Runnable { * Verify whether the actual directory location of block file has the * expected directory path computed using its block ID. */ - private void verifyFileLocation(File actualBlockDir, + private void verifyFileLocation(File actualBlockFile, File bpFinalizedDir, long blockId) { File blockDir = DatanodeUtil.idToBlockDir(bpFinalizedDir, blockId); - if (actualBlockDir.compareTo(blockDir) != 0) { + if (actualBlockFile.getParentFile().compareTo(blockDir) != 0) { + File expBlockFile = new File(blockDir, actualBlockFile.getName()); LOG.warn("Block: " + blockId - + " has to be upgraded to block ID-based layout"); + + " has to be upgraded to block ID-based layout. " + + "Actual block file path: " + actualBlockFile + + ", expected block file path: " + expBlockFile); } } }