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 class ContentSummaryComputationContext {
|
||||||
String ecPolicyName = WritableUtils.readString(din);
|
String ecPolicyName = WritableUtils.readString(din);
|
||||||
return dir.getFSNamesystem()
|
return dir.getFSNamesystem()
|
||||||
.getErasureCodingPolicyManager()
|
.getErasureCodingPolicyManager()
|
||||||
.getByName(ecPolicyName)
|
.getErasureCodingPolicyByName(ecPolicyName)
|
||||||
.getName();
|
.getName();
|
||||||
}
|
}
|
||||||
} else if (inode.getParent() != null) {
|
} else if (inode.getParent() != null) {
|
||||||
|
|
|
@ -255,6 +255,22 @@ public final class ErasureCodingPolicyManager {
|
||||||
return ecpi.getPolicy();
|
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
|
* Get a {@link ErasureCodingPolicyInfo} by policy name, including system
|
||||||
* policy and user defined policy.
|
* policy and user defined policy.
|
||||||
|
|
|
@ -1055,5 +1055,24 @@
|
||||||
</comparators>
|
</comparators>
|
||||||
</test>
|
</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>
|
</tests>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
Loading…
Reference in New Issue