From f43e0ffa7ebf1c6d35d4f6d4fe3f9e65ef2de4a1 Mon Sep 17 00:00:00 2001 From: Aaron Myers Date: Mon, 27 Jun 2011 07:05:50 +0000 Subject: [PATCH] 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 --- hdfs/CHANGES.txt | 3 +++ .../hdfs/protocol/DSQuotaExceededException.java | 3 ++- .../hdfs/org/apache/hadoop/cli/testHDFSConf.xml | 2 +- .../hdfs/org/apache/hadoop/hdfs/TestQuota.java | 17 +++++++++++++++++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/hdfs/CHANGES.txt b/hdfs/CHANGES.txt index 7b764128fae..28d9d0b1953 100644 --- a/hdfs/CHANGES.txt +++ b/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 diff --git a/hdfs/src/java/org/apache/hadoop/hdfs/protocol/DSQuotaExceededException.java b/hdfs/src/java/org/apache/hadoop/hdfs/protocol/DSQuotaExceededException.java index 55a3964be1e..eb97b540cc7 100644 --- a/hdfs/src/java/org/apache/hadoop/hdfs/protocol/DSQuotaExceededException.java +++ b/hdfs/src/java/org/apache/hadoop/hdfs/protocol/DSQuotaExceededException.java @@ -41,7 +41,8 @@ public String getMessage() { 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; } diff --git a/hdfs/src/test/hdfs/org/apache/hadoop/cli/testHDFSConf.xml b/hdfs/src/test/hdfs/org/apache/hadoop/cli/testHDFSConf.xml index 89e6a394ba9..8b4e6c8e75e 100644 --- a/hdfs/src/test/hdfs/org/apache/hadoop/cli/testHDFSConf.xml +++ b/hdfs/src/test/hdfs/org/apache/hadoop/cli/testHDFSConf.xml @@ -15440,7 +15440,7 @@ RegexpComparator - put: The DiskSpace quota of /dir1 is exceeded: quota=1024 diskspace consumed=[0-9.]+[kmg]* + put: The DiskSpace quota of /dir1 is exceeded: quota=1.0k diskspace consumed=[0-9.]+[kmg]* diff --git a/hdfs/src/test/hdfs/org/apache/hadoop/hdfs/TestQuota.java b/hdfs/src/test/hdfs/org/apache/hadoop/hdfs/TestQuota.java index 42e09d957ab..9a90b6bfa44 100644 --- a/hdfs/src/test/hdfs/org/apache/hadoop/hdfs/TestQuota.java +++ b/hdfs/src/test/hdfs/org/apache/hadoop/hdfs/TestQuota.java @@ -54,6 +54,23 @@ private void runCommand(DFSAdmin admin, String args[], boolean expectEror) } } + /** + * 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 */