You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by so...@apache.org on 2020/08/25 15:15:52 UTC
[hadoop] branch branch-3.1 updated: HDFS-14852. Removing from
LowRedundancyBlocks does not remove the block from all queues. Contributed
by Fei Hui.
This is an automated email from the ASF dual-hosted git repository.
sodonnell pushed a commit to branch branch-3.1
in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/branch-3.1 by this push:
new 0f23466 HDFS-14852. Removing from LowRedundancyBlocks does not remove the block from all queues. Contributed by Fei Hui.
0f23466 is described below
commit 0f234667dde4f7156ad1aa09a8601dbc7e5cb0eb
Author: S O'Donnell <so...@cloudera.com>
AuthorDate: Tue Aug 25 15:18:36 2020 +0100
HDFS-14852. Removing from LowRedundancyBlocks does not remove the block from all queues. Contributed by Fei Hui.
(cherry picked from commit 6a49bf9bffbe9bad1c719fc3a3b734f0060df70a)
---
.../hadoop/hdfs/server/blockmanagement/BlockManager.java | 2 +-
.../hdfs/server/blockmanagement/LowRedundancyBlocks.java | 5 +++--
.../server/blockmanagement/TestLowRedundancyBlockQueues.java | 11 +++++++++++
3 files changed, 15 insertions(+), 3 deletions(-)
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 b80e58f..a6647db 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
@@ -2462,7 +2462,7 @@ public class BlockManager implements BlockStatsMXBean {
* with the most up-to-date block information (e.g. genstamp).
*/
BlockInfo bi = blocksMap.getStoredBlock(timedOutItems[i]);
- if (bi == null) {
+ if (bi == null || bi.isDeleted()) {
continue;
}
NumberReplicas num = countNodes(timedOutItems[i]);
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/LowRedundancyBlocks.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/LowRedundancyBlocks.java
index 8cf9dd4..f6ef248 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/LowRedundancyBlocks.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/LowRedundancyBlocks.java
@@ -382,17 +382,18 @@ class LowRedundancyBlocks implements Iterable<BlockInfo> {
} else {
// Try to remove the block from all queues if the block was
// not found in the queue for the given priority level.
+ boolean found = false;
for (int i = 0; i < LEVEL; i++) {
if (i != priLevel && priorityQueues.get(i).remove(block)) {
NameNode.blockStateChangeLog.debug(
"BLOCK* NameSystem.LowRedundancyBlock.remove: Removing block" +
" {} from priority queue {}", block, i);
decrementBlockStat(block, i, oldExpectedReplicas);
- return true;
+ found = true;
}
}
+ return found;
}
- return false;
}
private void decrementBlockStat(BlockInfo blockInfo, int priLevel,
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestLowRedundancyBlockQueues.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestLowRedundancyBlockQueues.java
index e66182d..e63a8d8 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestLowRedundancyBlockQueues.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestLowRedundancyBlockQueues.java
@@ -276,4 +276,15 @@ public class TestLowRedundancyBlockQueues {
}
fail("Block " + block + " not found in level " + level);
}
+
+ @Test
+ public void testRemoveBlockInManyQueues() {
+ LowRedundancyBlocks neededReconstruction = new LowRedundancyBlocks();
+ BlockInfo block = new BlockInfoContiguous(new Block(), (short)1024);
+ neededReconstruction.add(block, 2, 0, 1, 3);
+ neededReconstruction.add(block, 0, 0, 0, 3);
+ neededReconstruction.remove(block, LowRedundancyBlocks.LEVEL);
+ assertFalse("Should not contain the block.",
+ neededReconstruction.contains(block));
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org