HDFS-14274. EC: NPE While Listing EC Policy For A Directory Following Replication Policy. Contributed by Ayush Saxena.
This commit is contained in:
parent
00c5ffaee2
commit
35d4f32b32
@ -188,7 +188,7 @@ public String getErasureCodingPolicyName(INode inode) {
|
||||
String ecPolicyName = WritableUtils.readString(din);
|
||||
return dir.getFSNamesystem()
|
||||
.getErasureCodingPolicyManager()
|
||||
.getByName(ecPolicyName)
|
||||
.getErasureCodingPolicyByName(ecPolicyName)
|
||||
.getName();
|
||||
}
|
||||
} else if (inode.getParent() != null) {
|
||||
|
@ -255,6 +255,22 @@ public ErasureCodingPolicy getByName(String name) {
|
||||
return ecpi.getPolicy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a {@link ErasureCodingPolicy} by policy name, including system
|
||||
* policy, user defined policy and Replication policy.
|
||||
* @return ecPolicy, or null if not found
|
||||
*/
|
||||
public ErasureCodingPolicy getErasureCodingPolicyByName(String name) {
|
||||
final ErasureCodingPolicyInfo ecpi = getPolicyInfoByName(name);
|
||||
if (ecpi == null) {
|
||||
if (name.equalsIgnoreCase(ErasureCodeConstants.REPLICATION_POLICY_NAME)) {
|
||||
return SystemErasureCodingPolicies.getReplicationPolicy();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return ecpi.getPolicy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a {@link ErasureCodingPolicyInfo} by policy name, including system
|
||||
* policy and user defined policy.
|
||||
|
@ -1055,5 +1055,24 @@
|
||||
</comparators>
|
||||
</test>
|
||||
|
||||
<test>
|
||||
<description>ls: file with replication Policy</description>
|
||||
<test-commands>
|
||||
<command>-fs NAMENODE -mkdir -p /ecdir</command>
|
||||
<ec-admin-command>-fs NAMENODE -setPolicy -path /ecdir -replicate</ec-admin-command>
|
||||
<command>-fs NAMENODE -touchz /ecdir/file1</command>
|
||||
<command>-fs NAMENODE -ls -e /</command>
|
||||
</test-commands>
|
||||
<cleanup-commands>
|
||||
<command>-fs NAMENODE -rmdir /ecdir</command>
|
||||
</cleanup-commands>
|
||||
<comparators>
|
||||
<comparator>
|
||||
<type>RegexpComparator</type>
|
||||
<expected-output>^drwxr-xr-x( )*-( )*USERNAME( )*supergroup( )*[A-Za-z0-9-]{1,}( )*0( )*[0-9]{4,}-[0-9]{2,}-[0-9]{2,} [0-9]{2,}:[0-9]{2,}( )*/ecdir</expected-output>
|
||||
</comparator>
|
||||
</comparators>
|
||||
</test>
|
||||
|
||||
</tests>
|
||||
</configuration>
|
||||
|
Loading…
Reference in New Issue
Block a user