hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zjs...@apache.org
Subject [49/50] [abbrv] hadoop git commit: HDFS-8205. CommandFormat#parse() should not parse option as value of option. (Contributed by Peter Shi and Xiaoyu Yao)
Date Mon, 27 Apr 2015 21:26:52 GMT
HDFS-8205. CommandFormat#parse() should not parse option as value of option. (Contributed by
Peter Shi and Xiaoyu Yao)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/72cb2de3
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/72cb2de3
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/72cb2de3

Branch: refs/heads/YARN-2928
Commit: 72cb2de31f6466176cd4f2ca12eb3ebcde6ca313
Parents: 3ee2409
Author: Arpit Agarwal <arp@apache.org>
Authored: Mon Apr 27 12:23:34 2015 -0700
Committer: Zhijie Shen <zjshen@apache.org>
Committed: Mon Apr 27 14:18:55 2015 -0700

----------------------------------------------------------------------
 .../apache/hadoop/fs/shell/CommandFormat.java   |  3 +-
 .../org/apache/hadoop/fs/shell/TestCount.java   | 28 +++++++++++++++
 hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt     |  3 ++
 .../org/apache/hadoop/hdfs/tools/DFSAdmin.java  |  4 +--
 .../src/test/resources/testHDFSConf.xml         | 38 ++++++++++++++++++++
 5 files changed, 73 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/72cb2de3/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/CommandFormat.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/CommandFormat.java
b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/CommandFormat.java
index 371168d..0aa3d65 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/CommandFormat.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/CommandFormat.java
@@ -114,7 +114,8 @@ public class CommandFormat {
         options.put(opt, Boolean.TRUE);
       } else if (optionsWithValue.containsKey(opt)) {
         args.remove(pos);
-        if (pos < args.size() && (args.size() > minPar)) {
+        if (pos < args.size() && (args.size() > minPar)
+                && !args.get(pos).startsWith("-")) {
           arg = args.get(pos);
           args.remove(pos);
         } else {

http://git-wip-us.apache.org/repos/asf/hadoop/blob/72cb2de3/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestCount.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestCount.java
b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestCount.java
index 22d9a21..44fc1e6 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestCount.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestCount.java
@@ -316,6 +316,34 @@ public class TestCount {
   }
 
   @Test
+  public void processPathWithQuotasByQTVH() throws Exception {
+    Path path = new Path("mockfs:/test");
+
+    when(mockFs.getFileStatus(eq(path))).thenReturn(fileStat);
+
+    PrintStream out = mock(PrintStream.class);
+
+    Count count = new Count();
+    count.out = out;
+
+    LinkedList<String> options = new LinkedList<String>();
+    options.add("-q");
+    options.add("-t");
+    options.add("-v");
+    options.add("-h");
+    options.add("dummy");
+    count.processOptions(options);
+    String withStorageTypeHeader =
+        // <----13---> <-------17------>
+        "   DISK_QUOTA    REM_DISK_QUOTA " +
+        "    SSD_QUOTA     REM_SSD_QUOTA " +
+        "ARCHIVE_QUOTA REM_ARCHIVE_QUOTA " +
+        "PATHNAME";
+    verify(out).println(withStorageTypeHeader);
+    verifyNoMoreInteractions(out);
+  }
+
+  @Test
   public void processPathWithQuotasByMultipleStorageTypesContent() throws Exception {
     Path path = new Path("mockfs:/test");
 

http://git-wip-us.apache.org/repos/asf/hadoop/blob/72cb2de3/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
index b7199c7..00b5db5 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
+++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
@@ -618,6 +618,9 @@ Release 2.7.1 - UNRELEASED
     HDFS-8070. Pre-HDFS-7915 DFSClient cannot use short circuit on
     post-HDFS-7915 DataNode (cmccabe)
 
+    HDFS-8205. CommandFormat#parse() should not parse option as
+    value of option. (Peter Shi and Xiaoyu Yao via Arpit Agarwal)
+
 Release 2.7.0 - 2015-04-20
 
   INCOMPATIBLE CHANGES

http://git-wip-us.apache.org/repos/asf/hadoop/blob/72cb2de3/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/DFSAdmin.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/DFSAdmin.java
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/DFSAdmin.java
index d608281..11f2c32 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/DFSAdmin.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/DFSAdmin.java
@@ -221,9 +221,9 @@ public class DFSAdmin extends FsShell {
     ClearSpaceQuotaCommand(String[] args, int pos, FileSystem fs) {
       super(fs);
       CommandFormat c = new CommandFormat(1, Integer.MAX_VALUE);
+      c.addOptionWithValue("storageType");
       List<String> parameters = c.parse(args, pos);
-      String storageTypeString =
-          StringUtils.popOptionWithArgument("-storageType", parameters);
+      String storageTypeString = c.getOptValue("storageType");
       if (storageTypeString != null) {
         this.type = StorageType.parseStorageType(storageTypeString);
       }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/72cb2de3/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testHDFSConf.xml
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testHDFSConf.xml b/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testHDFSConf.xml
index 2d3de1f..56713f5 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testHDFSConf.xml
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testHDFSConf.xml
@@ -7722,6 +7722,44 @@
     </test>
 
     <test> <!-- TESTED -->
+      <description>setSpaceQuota -storageType: directory with quota by storage type</description>
+      <test-commands>
+        <command>-fs NAMENODE -mkdir /ttt</command>
+        <dfs-admin-command>-fs NAMENODE -setSpaceQuota 1m -storageType DISK /ttt </dfs-admin-command>
+        <command>-fs NAMENODE -count -q -t DISK /ttt</command>
+      </test-commands>
+      <cleanup-commands>
+        <command>-fs NAMENODE -rm -r /ttt</command>
+      </cleanup-commands>
+      <comparators>
+        <comparator>
+          <type>RegexpComparator</type>
+          <expected-output>( |\t)*1048576( |\t)*1048576 /ttt</expected-output>
+        </comparator>
+      </comparators>
+    </test>
+
+    <test> <!-- TESTED -->
+      <description>clrSpaceQuota -storageType: directory quota by storage type</description>
+      <test-commands>
+        <command>-fs NAMENODE -mkdir /ttt</command>
+        <dfs-admin-command>-fs NAMENODE -setSpaceQuota 1m -storageType DISK /ttt </dfs-admin-command>
+        <command>-fs NAMENODE -count -q -t DISK /ttt</command>
+        <dfs-admin-command>-fs NAMENODE -clrSpaceQuota -storageType DISK /ttt </dfs-admin-command>
+        <command>-fs NAMENODE -count -q -t DISK /ttt</command>
+      </test-commands>
+      <cleanup-commands>
+        <command>-fs NAMENODE -rm -r /ttt</command>
+      </cleanup-commands>
+      <comparators>
+        <comparator>
+          <type>RegexpComparator</type>
+          <expected-output>( |\t)*none( |\t)*inf /ttt</expected-output>
+        </comparator>
+      </comparators>
+    </test>
+
+    <test> <!-- TESTED -->
       <description>count: directory using relative path with -q option</description>
       <test-commands>
         <command>-fs NAMENODE -mkdir -p dir1</command>


Mime
View raw message