Browse Source

HDFS-8364. Erasure coding: fix some minor bugs in EC CLI (Contributed by Walter Su)

Vinayakumar B 10 năm trước cách đây
mục cha
commit
bba15e06d2

+ 3 - 0
hadoop-hdfs-project/hadoop-hdfs/CHANGES-HDFS-EC-7285.txt

@@ -209,3 +209,6 @@
 
     HDFS-8195. Erasure coding: Fix file quota change when we complete/commit 
     the striped blocks. (Takuya Fukudome via zhz)
+
+    HDFS-8364. Erasure coding: fix some minor bugs in EC CLI
+    (Walter Su via vinayakumarb)

+ 1 - 0
hadoop-hdfs-project/hadoop-hdfs/src/main/bin/hdfs

@@ -28,6 +28,7 @@ function hadoop_usage
   echo "  datanode             run a DFS datanode"
   echo "  dfs                  run a filesystem command on the file system"
   echo "  dfsadmin             run a DFS admin client"
+  echo "  erasurecode          configure HDFS erasure coding zones"
   echo "  fetchdt              fetch a delegation token from the NameNode"
   echo "  fsck                 run a DFS filesystem checking utility"
   echo "  getconf              get config values from configuration"

+ 8 - 4
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/erasurecode/ECCommand.java

@@ -135,7 +135,7 @@ public abstract class ECCommand extends Command {
         out.println("EC Zone created successfully at " + item.path);
       } catch (IOException e) {
         throw new IOException("Unable to create EC zone for the path "
-            + item.path, e);
+            + item.path + ". " + e.getMessage());
       }
     }
   }
@@ -165,10 +165,14 @@ public abstract class ECCommand extends Command {
       DistributedFileSystem dfs = (DistributedFileSystem) item.fs;
       try {
         ErasureCodingZoneInfo ecZoneInfo = dfs.getErasureCodingZoneInfo(item.path);
-        out.println(ecZoneInfo.toString());
+        if (ecZoneInfo != null) {
+          out.println(ecZoneInfo.toString());
+        } else {
+          out.println("Path " + item.path + " is not in EC zone");
+        }
       } catch (IOException e) {
-        throw new IOException("Unable to create EC zone for the path "
-            + item.path, e);
+        throw new IOException("Unable to get EC zone for the path "
+            + item.path + ". " + e.getMessage());
       }
     }
   }

+ 35 - 0
hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testErasureCodingConf.xml

@@ -122,6 +122,24 @@
       </comparators>
     </test>
 
+    <test>
+      <description>createZone : create a zone twice</description>
+      <test-commands>
+        <command>-fs NAMENODE -mkdir /eczone</command>
+        <ec-admin-command>-fs NAMENODE -createZone /eczone</ec-admin-command>
+        <ec-admin-command>-fs NAMENODE -createZone /eczone</ec-admin-command>
+      </test-commands>
+      <cleanup-commands>
+        <command>-fs NAMENODE -rmdir /eczone</command>
+      </cleanup-commands>
+      <comparators>
+        <comparator>
+          <type>SubstringComparator</type>
+          <expected-output>Directory /eczone is already in an erasure coding zone</expected-output>
+        </comparator>
+      </comparators>
+    </test>
+
     <test>
       <description>createZone : default schema</description>
       <test-commands>
@@ -140,6 +158,23 @@
       </comparators>
     </test>
 
+    <test>
+      <description>getZoneInfo : get information about the EC zone at specified path not in zone</description>
+      <test-commands>
+        <command>-fs NAMENODE -mkdir /noec</command>
+        <ec-admin-command>-fs NAMENODE -getZoneInfo /noec</ec-admin-command>
+      </test-commands>
+      <cleanup-commands>
+        <command>-fs NAMENODE -rmdir /noec</command>
+      </cleanup-commands>
+      <comparators>
+        <comparator>
+          <type>SubstringComparator</type>
+          <expected-output>Path NAMENODE/noec is not in EC zone</expected-output>
+        </comparator>
+      </comparators>
+    </test>
+
     <test>
       <description>getZoneInfo : get information about the EC zone at specified path</description>
       <test-commands>