From 61a9b4f58b639e71c564d84b529ac66aaae7f8ef Mon Sep 17 00:00:00 2001 From: Wei-Chiu Chuang Date: Tue, 14 Aug 2018 11:51:27 -0700 Subject: [PATCH] HDFS-13758. DatanodeManager should throw exception if it has BlockRecoveryCommand but the block is not under construction. Contributed by chencan. --- .../hdfs/server/blockmanagement/DatanodeManager.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/DatanodeManager.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/DatanodeManager.java index 7d5d73c9a4..1131506b6b 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/DatanodeManager.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/DatanodeManager.java @@ -1542,7 +1542,7 @@ private void setDatanodeDead(DatanodeDescriptor node) { } private BlockRecoveryCommand getBlockRecoveryCommand(String blockPoolId, - DatanodeDescriptor nodeinfo) { + DatanodeDescriptor nodeinfo) throws IOException { BlockInfo[] blocks = nodeinfo.getLeaseRecoveryCommand(Integer.MAX_VALUE); if (blocks == null) { return null; @@ -1550,7 +1550,10 @@ private BlockRecoveryCommand getBlockRecoveryCommand(String blockPoolId, BlockRecoveryCommand brCommand = new BlockRecoveryCommand(blocks.length); for (BlockInfo b : blocks) { BlockUnderConstructionFeature uc = b.getUnderConstructionFeature(); - assert uc != null; + if(uc == null) { + throw new IOException("Recovery block " + b + + "where it is not under construction."); + } final DatanodeStorageInfo[] storages = uc.getExpectedStorageLocations(); // Skip stale nodes during recovery final List recoveryLocations =