HDFS-14218. EC: Ls -e throw NPE when directory ec policy is disabled. Contributed by Ayush Saxena.

(cherry picked from commit 7d6792e5d2)
This commit is contained in:
Takanobu Asanuma 2019-01-23 10:03:06 +09:00
parent ba3f559724
commit 38e4bed224
2 changed files with 22 additions and 1 deletions

View File

@ -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) {

View File

@ -1010,5 +1010,26 @@
</comparators>
</test>
<test>
<description>ls: file with disabled EC Policy</description>
<test-commands>
<command>-fs NAMENODE -mkdir -p /ecdir</command>
<ec-admin-command>-fs NAMENODE -setPolicy -path /ecdir -policy XOR-2-1-1024k</ec-admin-command>
<command>-fs NAMENODE -touchz /ecdir/file1</command>
<ec-admin-command>-fs NAMENODE -disablePolicy -policy XOR-2-1-1024k</ec-admin-command>
<command>-fs NAMENODE -ls -e /ecdir</command>
</test-commands>
<cleanup-commands>
<command>-fs NAMENODE -rmdir /ecdir</command>
<ec-admin-command>-fs NAMENODE -enablePolicy -policy XOR-2-1-1024k</ec-admin-command>
</cleanup-commands>
<comparators>
<comparator>
<type>RegexpComparator</type>
<expected-output>^-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</expected-output>
</comparator>
</comparators>
</test>
</tests>
</configuration>