Browse Source

HDFS-1723. quota errors messages should use the same scale. (Jim Plush via atm)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1140030 13f79535-47bb-0310-9956-ffa450edef68
Aaron Myers 14 năm trước cách đây
mục cha
commit
f43e0ffa7e

+ 3 - 0
hdfs/CHANGES.txt

@@ -529,6 +529,9 @@ Trunk (unreleased changes)
     HDFS-2087. Declare methods in DataTransferProtocol interface, and change
     Sender and Receiver to implement the interface.  (szetszwo)
 
+    HDFS-1723. quota errors messages should use the same scale. (Jim Plush via
+    atm)
+
   OPTIMIZATIONS
 
     HDFS-1458. Improve checkpoint performance by avoiding unnecessary image

+ 2 - 1
hdfs/src/java/org/apache/hadoop/hdfs/protocol/DSQuotaExceededException.java

@@ -41,7 +41,8 @@ public class DSQuotaExceededException extends QuotaExceededException {
     String msg = super.getMessage();
     if (msg == null) {
       return "The DiskSpace quota" + (pathName==null?"":(" of " + pathName)) + 
-          " is exceeded: quota=" + quota + " diskspace consumed=" + StringUtils.humanReadableInt(count);
+          " is exceeded: quota=" + StringUtils.humanReadableInt(quota) + 
+          " diskspace consumed=" + StringUtils.humanReadableInt(count);
     } else {
       return msg;
     }

+ 1 - 1
hdfs/src/test/hdfs/org/apache/hadoop/cli/testHDFSConf.xml

@@ -15440,7 +15440,7 @@
       <comparators>
         <comparator>
           <type>RegexpComparator</type>
-          <expected-output>put: The DiskSpace quota of /dir1 is exceeded: quota=1024 diskspace consumed=[0-9.]+[kmg]*</expected-output>
+          <expected-output>put: The DiskSpace quota of /dir1 is exceeded: quota=1.0k diskspace consumed=[0-9.]+[kmg]*</expected-output>
         </comparator>
       </comparators>
     </test>

+ 17 - 0
hdfs/src/test/hdfs/org/apache/hadoop/hdfs/TestQuota.java

@@ -54,6 +54,23 @@ public class TestQuota {
     }
   }
   
+  /**
+   * Tests to make sure we're getting human readable Quota exception messages
+   * Test for @link{ NSQuotaExceededException, DSQuotaExceededException}
+   * @throws Exception
+   */
+  @Test
+  public void testDSQuotaExceededExceptionIsHumanReadable() throws Exception {
+    Integer bytes = 1024;
+    try {
+      throw new DSQuotaExceededException(bytes, bytes);
+    } catch(DSQuotaExceededException e) {
+      
+      assertEquals("The DiskSpace quota is exceeded: quota=1.0k " +
+          "diskspace consumed=1.0k", e.getMessage());
+    }
+  }
+  
   /** Test quota related commands: 
    *    setQuota, clrQuota, setSpaceQuota, clrSpaceQuota, and count 
    */