Skip to content

Commit 64dc319

Browse files
committed
HDFS-17218. Fix some logic
1 parent 2cd0509 commit 64dc319

File tree

1 file changed

+7
-9
lines changed
  • hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement

1 file changed

+7
-9
lines changed

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/HeartbeatManager.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package org.apache.hadoop.hdfs.server.blockmanagement;
1919

2020
import java.util.ArrayList;
21+
import java.util.Collection;
2122
import java.util.HashSet;
2223
import java.util.List;
2324
import java.util.Map;
@@ -30,7 +31,6 @@
3031
import org.apache.hadoop.hdfs.server.namenode.Namesystem;
3132
import org.apache.hadoop.hdfs.server.protocol.StorageReport;
3233
import org.apache.hadoop.hdfs.server.protocol.VolumeFailureSummary;
33-
import org.apache.hadoop.hdfs.util.LightWeightHashSet;
3434
import org.apache.hadoop.util.Daemon;
3535
import org.apache.hadoop.util.StopWatch;
3636
import org.apache.hadoop.util.Time;
@@ -236,20 +236,18 @@ synchronized void register(final DatanodeDescriptor d) {
236236
d.updateHeartbeatState(StorageReport.EMPTY_ARRAY, 0L, 0L, 0, 0, null);
237237
stats.add(d);
238238
} else {
239-
// Only when active NN is out of safe mode.
240239
if (!blockManager.isPopulatingReplQueues()) {
241240
return;
242241
}
243242
// Remove blocks from excessRedundancyMap by datanode.
244-
LightWeightHashSet<BlockInfo> set = blockManager.removeBlocksFromExcessRedundancyMap(d);
245-
// Remove blocks from invalidateBlocks in datanode.
246-
d.clearInvalidateBlocks();
243+
Collection<BlockInfo> excessBlocks = blockManager.removeBlocksFromExcessRedundancyMap(d);
247244
// Remove blocks from invalidateBlocks in blockManager.
248245
blockManager.removeBlocksFromInvalidateBlocks(d);
249-
// Add blocks into postponed queue and
250-
// here add `set != null` to avoid the mock test UT failed.
251-
if (set != null && !set.isEmpty()) {
252-
for (BlockInfo block: set) {
246+
// Remove blocks from invalidateBlocks in datanode.
247+
d.clearInvalidateBlocks();
248+
// Add blocks into postponed queue, add excessBlocks != null to avoid the mock test UT failed.
249+
if (excessBlocks != null && !excessBlocks.isEmpty()) {
250+
for (BlockInfo block : excessBlocks) {
253251
blockManager.postponeBlock(block);
254252
}
255253
}

0 commit comments

Comments
 (0)