From 151c5deaf15f7c13efba9b9141089804196fae92 Mon Sep 17 00:00:00 2001 From: Andrew Wang Date: Thu, 3 Jul 2014 20:10:54 +0000 Subject: [PATCH] HDFS-6511. BlockManager#computeInvalidateWork() could do nothing. Contributed by Juan Yu. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1607735 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 2 ++ .../hdfs/server/blockmanagement/BlockManager.java | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 75223992e6..0f04bc1879 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -264,6 +264,8 @@ Release 2.6.0 - UNRELEASED HDFS-6613. Improve logging in caching classes. (wang) + HDFS-6511. BlockManager#computeInvalidateWork() could do nothing. (Juan Yu via wang) + OPTIMIZATIONS BUG FIXES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java index b200f4daf4..dbecf5a631 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java @@ -1226,8 +1226,14 @@ int computeInvalidateWork(int nodesToProcess) { nodesToProcess = Math.min(nodes.size(), nodesToProcess); int blockCnt = 0; - for(int nodeCnt = 0; nodeCnt < nodesToProcess; nodeCnt++ ) { - blockCnt += invalidateWorkForOneNode(nodes.get(nodeCnt)); + for (DatanodeInfo dnInfo : nodes) { + int blocks = invalidateWorkForOneNode(dnInfo); + if (blocks > 0) { + blockCnt += blocks; + if (--nodesToProcess == 0) { + break; + } + } } return blockCnt; }