From 7d6792e5d2001e1a83ae75a4777324a3b01c557a Mon Sep 17 00:00:00 2001 From: Takanobu Asanuma Date: Wed, 23 Jan 2019 10:03:06 +0900 Subject: [PATCH] HDFS-14218. EC: Ls -e throw NPE when directory ec policy is disabled. Contributed by Ayush Saxena. --- .../ContentSummaryComputationContext.java | 2 +- .../test/resources/testErasureCodingConf.xml | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ContentSummaryComputationContext.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ContentSummaryComputationContext.java index 14548e9e0d..2e7c78a205 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ContentSummaryComputationContext.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ContentSummaryComputationContext.java @@ -188,7 +188,7 @@ public String getErasureCodingPolicyName(INode inode) { String ecPolicyName = WritableUtils.readString(din); return dir.getFSNamesystem() .getErasureCodingPolicyManager() - .getEnabledPolicyByName(ecPolicyName) + .getByName(ecPolicyName) .getName(); } } else if (inode.getParent() != null) { diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testErasureCodingConf.xml b/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testErasureCodingConf.xml index 6411fe6dd8..c280eca42a 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testErasureCodingConf.xml +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testErasureCodingConf.xml @@ -1034,5 +1034,26 @@ + + ls: file with disabled EC Policy + + -fs NAMENODE -mkdir -p /ecdir + -fs NAMENODE -setPolicy -path /ecdir -policy XOR-2-1-1024k + -fs NAMENODE -touchz /ecdir/file1 + -fs NAMENODE -disablePolicy -policy XOR-2-1-1024k + -fs NAMENODE -ls -e /ecdir + + + -fs NAMENODE -rmdir /ecdir + -fs NAMENODE -enablePolicy -policy XOR-2-1-1024k + + + + RegexpComparator + ^-rw-r--r--( )*1( )*USERNAME( )*supergroup( )*[A-Za-z0-9-]{1,}( )*0( )*[0-9]{4,}-[0-9]{2,}-[0-9]{2,} [0-9]{2,}:[0-9]{2,}( )*/ecdir/file1 + + + +