From 5addacb1e301991a8285a221c726f66330cd6d08 Mon Sep 17 00:00:00 2001 From: Andrew Wang Date: Wed, 8 Mar 2017 08:47:38 -0800 Subject: [PATCH] HDFS-11152. Start erasure coding policy ID number from 1 instead of 0 to void potential unexpected errors. Contributed by SammiChen. --- .../org/apache/hadoop/hdfs/protocol/HdfsConstants.java | 10 +++++----- .../hdfs/server/namenode/FSImageFormatPBINode.java | 3 +++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/HdfsConstants.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/HdfsConstants.java index a9f1839245..d2209a4995 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/HdfsConstants.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/HdfsConstants.java @@ -144,11 +144,11 @@ public enum DatanodeReportType { ALL, LIVE, DEAD, DECOMMISSIONING, ENTERING_MAINTENANCE } - public static final byte RS_6_3_POLICY_ID = 0; - public static final byte RS_3_2_POLICY_ID = 1; - public static final byte RS_6_3_LEGACY_POLICY_ID = 2; - public static final byte XOR_2_1_POLICY_ID = 3; - public static final byte RS_10_4_POLICY_ID = 4; + public static final byte RS_6_3_POLICY_ID = 1; + public static final byte RS_3_2_POLICY_ID = 2; + public static final byte RS_6_3_LEGACY_POLICY_ID = 3; + public static final byte XOR_2_1_POLICY_ID = 4; + public static final byte RS_10_4_POLICY_ID = 5; /* Hidden constructor */ protected HdfsConstants() { diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormatPBINode.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormatPBINode.java index 0ceae7816d..17b1da7422 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormatPBINode.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormatPBINode.java @@ -342,6 +342,9 @@ private INodeFile loadINodeFile(INodeSection.INode n) { for (int i = 0; i < bp.size(); ++i) { BlockProto b = bp.get(i); if (isStriped) { + Preconditions.checkState(ecPolicy.getId() > 0, + "File with ID " + n.getId() + + " has an invalid erasure coding policy ID " + ecPolicy.getId()); blocks[i] = new BlockInfoStriped(PBHelperClient.convert(b), ecPolicy); } else { blocks[i] = new BlockInfoContiguous(PBHelperClient.convert(b),