From 8f4bfb3ed5ce30b0412288fa7d2763e5a8fd9424 Mon Sep 17 00:00:00 2001 From: Xiao Chen Date: Tue, 13 Mar 2018 10:06:55 -0700 Subject: [PATCH] HDFS-13239. Fix non-empty dir warning message when setting default EC policy. Contributed by Bharat Viswanadham. (cherry picked from commit d6931c30c5a643ca192109b05a9c44da42a6318c) --- .../org/apache/hadoop/hdfs/tools/ECAdmin.java | 12 ++++---- .../test/resources/testErasureCodingConf.xml | 28 +++++++++++++++++-- 2 files changed, 30 insertions(+), 10 deletions(-) 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 e30b0836c89..9b9fe14e46d 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 @@ -358,17 +358,15 @@ public class ECAdmin extends Configured implements Tool { try { dfs.setErasureCodingPolicy(p, ecPolicyName); if (ecPolicyName == null){ - System.out.println("Set default erasure coding policy" + - " on " + path); - } else { - System.out.println("Set erasure coding policy " + ecPolicyName + - " on " + path); + ecPolicyName = "default"; } + System.out.println("Set " + ecPolicyName + " erasure coding policy on" + + " " + path); RemoteIterator 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); + "non-empty directory will not automatically convert existing " + + "files to " + ecPolicyName + " erasure coding policy"); } } catch (Exception e) { System.err.println(AdminHelper.prettifyException(e)); 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 265e628fd56..35a4048c014 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testErasureCodingConf.xml +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testErasureCodingConf.xml @@ -214,7 +214,7 @@ SubstringComparator - Set erasure coding policy RS-6-3-1024k on /ecdir + Set RS-6-3-1024k erasure coding policy on /ecdir @@ -232,7 +232,7 @@ SubstringComparator - Set erasure coding policy RS-6-3-1024k on /ecdir + Set RS-6-3-1024k erasure coding policy on /ecdir @@ -311,7 +311,7 @@ SubstringComparator - Warning: setting erasure coding policy on a non-empty directory will not automatically convert existing files to RS-6-3-1024 + Warning: setting erasure coding policy on a non-empty directory will not automatically convert existing files to RS-6-3-1024k erasure coding policy @@ -695,6 +695,28 @@ + + setPolicy : set erasure coding policy without given a specific policy name on a non empty directory + + -fs NAMENODE -mkdir /ecdir + -fs NAMENODE -mkdir /ecdir/ecsubdir + -fs NAMENODE -setPolicy -path /ecdir + + + -fs NAMENODE -rm -R /ecdir + + + + SubstringComparator + Set default erasure coding policy on /ecdir + + + SubstringComparator + Warning: setting erasure coding policy on a non-empty directory will not automatically convert existing files to default erasure coding policy + + + + getPolicy: get the default policy after setPolicy without given a specific policy name