HDFS-10186. DirectoryScanner: Improve logs by adding full path of both actual and expected block directories. Contributed by Rakesh R

This commit is contained in:
Tsz-Wo Nicholas Sze 2016-04-07 12:36:29 +08:00
parent b5e6ad457f
commit bccc28914b
1 changed files with 7 additions and 5 deletions

View File

@ -902,8 +902,7 @@ private LinkedList<ScanInfo> compileReport(FsVolumeSpi vol,
break; break;
} }
} }
verifyFileLocation(blockFile.getParentFile(), bpFinalizedDir, verifyFileLocation(blockFile, bpFinalizedDir, blockId);
blockId);
report.add(new ScanInfo(blockId, blockFile, metaFile, vol)); report.add(new ScanInfo(blockId, blockFile, metaFile, vol));
} }
return report; return report;
@ -913,12 +912,15 @@ private LinkedList<ScanInfo> compileReport(FsVolumeSpi vol,
* Verify whether the actual directory location of block file has the * Verify whether the actual directory location of block file has the
* expected directory path computed using its block ID. * expected directory path computed using its block ID.
*/ */
private void verifyFileLocation(File actualBlockDir, private void verifyFileLocation(File actualBlockFile,
File bpFinalizedDir, long blockId) { File bpFinalizedDir, long blockId) {
File blockDir = DatanodeUtil.idToBlockDir(bpFinalizedDir, 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 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);
} }
} }