|
18 | 18 | package org.apache.hadoop.hdfs.server.blockmanagement; |
19 | 19 |
|
20 | 20 | import java.util.ArrayList; |
| 21 | +import java.util.Collection; |
21 | 22 | import java.util.HashSet; |
22 | 23 | import java.util.List; |
23 | 24 | import java.util.Map; |
|
30 | 31 | import org.apache.hadoop.hdfs.server.namenode.Namesystem; |
31 | 32 | import org.apache.hadoop.hdfs.server.protocol.StorageReport; |
32 | 33 | import org.apache.hadoop.hdfs.server.protocol.VolumeFailureSummary; |
33 | | -import org.apache.hadoop.hdfs.util.LightWeightHashSet; |
34 | 34 | import org.apache.hadoop.util.Daemon; |
35 | 35 | import org.apache.hadoop.util.StopWatch; |
36 | 36 | import org.apache.hadoop.util.Time; |
@@ -236,20 +236,18 @@ synchronized void register(final DatanodeDescriptor d) { |
236 | 236 | d.updateHeartbeatState(StorageReport.EMPTY_ARRAY, 0L, 0L, 0, 0, null); |
237 | 237 | stats.add(d); |
238 | 238 | } else { |
239 | | - // Only when active NN is out of safe mode. |
240 | 239 | if (!blockManager.isPopulatingReplQueues()) { |
241 | 240 | return; |
242 | 241 | } |
243 | 242 | // 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); |
247 | 244 | // Remove blocks from invalidateBlocks in blockManager. |
248 | 245 | 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) { |
253 | 251 | blockManager.postponeBlock(block); |
254 | 252 | } |
255 | 253 | } |
|
0 commit comments