From 5b8a99bf49696abb146590c32422b0e10f68e77f 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. (cherry picked from commit 7d6792e5d2001e1a83ae75a4777324a3b01c557a) --- .../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 95f3fee34d8..d816cb2aca8 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 class ContentSummaryComputationContext { 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 35a4048c014..ac48898bc78 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testErasureCodingConf.xml +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testErasureCodingConf.xml @@ -990,5 +990,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 + + + +