From 2ca73445f5c2929d9c2ff4232dca58a63a0570a0 Mon Sep 17 00:00:00 2001 From: Colin Patrick Mccabe Date: Wed, 15 Jun 2016 22:47:01 -0700 Subject: [PATCH] HDFS-10525. Fix NPE in CacheReplicationMonitor#rescanCachedBlockMap (Xiao Chen via cmccabe) --- .../server/blockmanagement/CacheReplicationMonitor.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/CacheReplicationMonitor.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/CacheReplicationMonitor.java index b4b5e234f6b..ca8d72ac65e 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/CacheReplicationMonitor.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/CacheReplicationMonitor.java @@ -502,6 +502,14 @@ public class CacheReplicationMonitor extends Thread implements Closeable { CachedBlock cblock = it.next(); BlockInfo blockInfo = blockManager. getStoredBlock(new Block(cblock.getBlockId())); + if (blockInfo == null) { + // Cannot find this block on the NameNode, skip this block from + // capacity calculation. Later logic will handle this block. + LOG.debug("Block {}: cannot be found in block manager and hence" + + " skipped from calculation for node {}.", cblock.getBlockId(), + dn.getDatanodeUuid()); + continue; + } if (blockInfo.getNumBytes() > remaining) { LOG.debug("Block {}: removing from PENDING_CACHED for node {} " + "because it cannot fit in remaining cache size {}.",