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 le...@apache.org on 2017/12/15 18:06:08 UTC
hadoop git commit: HDFS-12819. Setting/Unsetting EC policy shows
warning if the directory is not empty. (Contributed by Lei (Eddy) Xu)
Repository: hadoop
Updated Branches:
refs/heads/branch-3.0 53033c69f -> 2821edf6d
HDFS-12819. Setting/Unsetting EC policy shows warning if the directory is not empty. (Contributed by Lei (Eddy) Xu)
(cherry picked from commit 1c15b1751c0698bd3063d5c25f556d4821b161d2)
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/2821edf6
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/2821edf6
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/2821edf6
Branch: refs/heads/branch-3.0
Commit: 2821edf6d0ae78a939af86b824f253397e5af024
Parents: 53033c6
Author: Lei Xu <le...@apache.org>
Authored: Fri Dec 15 10:04:43 2017 -0800
Committer: Lei Xu <le...@apache.org>
Committed: Fri Dec 15 10:06:00 2017 -0800
----------------------------------------------------------------------
.../org/apache/hadoop/hdfs/tools/ECAdmin.java | 14 ++++++++
.../test/resources/testErasureCodingConf.xml | 37 ++++++++++++++++++++
2 files changed, 51 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/2821edf6/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/ECAdmin.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/ECAdmin.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/ECAdmin.java
index a28f227..e30b083 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/ECAdmin.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/ECAdmin.java
@@ -19,7 +19,9 @@ package org.apache.hadoop.hdfs.tools;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.conf.Configured;
+import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.RemoteIterator;
import org.apache.hadoop.hdfs.DistributedFileSystem;
import org.apache.hadoop.hdfs.protocol.AddErasureCodingPolicyResponse;
import org.apache.hadoop.hdfs.protocol.ErasureCodingPolicy;
@@ -362,6 +364,12 @@ public class ECAdmin extends Configured implements Tool {
System.out.println("Set erasure coding policy " + ecPolicyName +
" on " + path);
}
+ RemoteIterator<FileStatus> dirIt = dfs.listStatusIterator(p);
+ if (dirIt.hasNext()) {
+ System.out.println("Warning: setting erasure coding policy on a " +
+ "non-empty directory will not automatically convert existing" +
+ " files to " + ecPolicyName);
+ }
} catch (Exception e) {
System.err.println(AdminHelper.prettifyException(e));
return 3;
@@ -412,6 +420,12 @@ public class ECAdmin extends Configured implements Tool {
try {
dfs.unsetErasureCodingPolicy(p);
System.out.println("Unset erasure coding policy from " + path);
+ RemoteIterator<FileStatus> dirIt = dfs.listStatusIterator(p);
+ if (dirIt.hasNext()) {
+ System.out.println("Warning: unsetting erasure coding policy on a " +
+ "non-empty directory will not automatically convert existing" +
+ " files to replicated data.");
+ }
} catch (Exception e) {
System.err.println(AdminHelper.prettifyException(e));
return 2;
http://git-wip-us.apache.org/repos/asf/hadoop/blob/2821edf6/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testErasureCodingConf.xml
----------------------------------------------------------------------
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 9988ff3..e667213 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testErasureCodingConf.xml
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testErasureCodingConf.xml
@@ -299,6 +299,24 @@
</test>
<test>
+ <description>setPolicy : set policy on non-empty directory</description>
+ <test-commands>
+ <command>-fs NAMENODE -mkdir /ecdir</command>
+ <command>-fs NAMENODE -touchz /ecdir/file1</command>
+ <ec-admin-command>-fs NAMENODE -setPolicy -policy RS-6-3-1024k -path /ecdir</ec-admin-command>
+ </test-commands>
+ <cleanup-commands>
+ <command>-fs NAMENODE -rm -R /ecdir</command>
+ </cleanup-commands>
+ <comparators>
+ <comparator>
+ <type>SubstringComparator</type>
+ <expected-output>Warning: setting erasure coding policy on an non-empty directory will not automatically convert existing data to RS-6-3-1024</expected-output>
+ </comparator>
+ </comparators>
+ </test>
+
+ <test>
<description>unsetPolicy : unset inherited EC policy, has no effect</description>
<test-commands>
<command>-fs NAMENODE -mkdir /ecdir</command>
@@ -322,6 +340,25 @@
</test>
<test>
+ <description>unsetPolicy : unset policy on non-empty directory</description>
+ <test-commands>
+ <command>-fs NAMENODE -mkdir /ecdir</command>
+ <ec-admin-command>-fs NAMENODE -setPolicy -policy RS-6-3-1024k -path /ecdir</ec-admin-command>
+ <command>-fs NAMENODE -touchz /ecdir/file1</command>
+ <ec-admin-command>-fs NAMENODE -unsetPolicy -path /ecdir</ec-admin-command>
+ </test-commands>
+ <cleanup-commands>
+ <command>-fs NAMENODE -rm -R /ecdir</command>
+ </cleanup-commands>
+ <comparators>
+ <comparator>
+ <type>SubstringComparator</type>
+ <expected-output>Warning: unsetting erasure coding policy on an non-empty directory will not automatically convert existing data to replicated data</expected-output>
+ </comparator>
+ </comparators>
+ </test>
+
+ <test>
<description>getPolicy : get EC policy information at specified path, which doesn't have an EC policy</description>
<test-commands>
<command>-fs NAMENODE -mkdir /noec</command>
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org