You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by su...@apache.org on 2019/02/13 17:47:58 UTC
[hadoop] branch trunk updated: HDFS-14274. EC: NPE While Listing EC
Policy For A Directory Following Replication Policy. Contributed by Ayush
Saxena.
This is an automated email from the ASF dual-hosted git repository.
surendralilhore pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/trunk by this push:
new 35d4f32 HDFS-14274. EC: NPE While Listing EC Policy For A Directory Following Replication Policy. Contributed by Ayush Saxena.
35d4f32 is described below
commit 35d4f32b32a3ba05332811caf3d245d9c3dcf1a5
Author: Surendra Singh Lilhore <su...@apache.org>
AuthorDate: Wed Feb 13 23:06:46 2019 +0530
HDFS-14274. EC: NPE While Listing EC Policy For A Directory Following Replication Policy. Contributed by Ayush Saxena.
---
.../namenode/ContentSummaryComputationContext.java | 2 +-
.../server/namenode/ErasureCodingPolicyManager.java | 16 ++++++++++++++++
.../src/test/resources/testErasureCodingConf.xml | 19 +++++++++++++++++++
3 files changed, 36 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 2e7c78a..0263f2a 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()
- .getByName(ecPolicyName)
+ .getErasureCodingPolicyByName(ecPolicyName)
.getName();
}
} else if (inode.getParent() != null) {
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ErasureCodingPolicyManager.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ErasureCodingPolicyManager.java
index 327de41..d9f7e9a 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ErasureCodingPolicyManager.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ErasureCodingPolicyManager.java
@@ -256,6 +256,22 @@ public final class ErasureCodingPolicyManager {
}
/**
+ * 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.
* @return ecPolicy, or null if not found
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 c280eca..2cc08f4 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testErasureCodingConf.xml
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testErasureCodingConf.xml
@@ -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>
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org