HDFS-10242. Cannot create space quota of zero. Contributed by Takashi Ohnishi.

This commit is contained in:
Akira Ajisaka 2016-05-17 15:53:09 +09:00
parent ccc93e7812
commit 9fe5828f05
3 changed files with 5 additions and 5 deletions

View File

@ -296,7 +296,7 @@ protected String getQuotaUsage(boolean hOption) {
quotaStr = formatSize(quota, hOption); quotaStr = formatSize(quota, hOption);
quotaRem = formatSize(quota-fileAndDirectoryCount, hOption); quotaRem = formatSize(quota-fileAndDirectoryCount, hOption);
} }
if (spaceQuota > 0) { if (spaceQuota >= 0) {
spaceQuotaStr = formatSize(spaceQuota, hOption); spaceQuotaStr = formatSize(spaceQuota, hOption);
spaceQuotaRem = formatSize(spaceQuota - spaceConsumed, hOption); spaceQuotaRem = formatSize(spaceQuota - spaceConsumed, hOption);
} }
@ -314,7 +314,7 @@ protected String getTypesQuotaUsage(boolean hOption,
String quotaStr = QUOTA_NONE; String quotaStr = QUOTA_NONE;
String quotaRem = QUOTA_INF; String quotaRem = QUOTA_INF;
if (typeQuota > 0) { if (typeQuota >= 0) {
quotaStr = formatSize(typeQuota, hOption); quotaStr = formatSize(typeQuota, hOption);
quotaRem = formatSize(typeQuota - typeConsumed, hOption); quotaRem = formatSize(typeQuota - typeConsumed, hOption);
} }

View File

@ -2368,7 +2368,7 @@ void setQuota(String src, long namespaceQuota, long storagespaceQuota)
if ((namespaceQuota <= 0 && if ((namespaceQuota <= 0 &&
namespaceQuota != HdfsConstants.QUOTA_DONT_SET && namespaceQuota != HdfsConstants.QUOTA_DONT_SET &&
namespaceQuota != HdfsConstants.QUOTA_RESET) || namespaceQuota != HdfsConstants.QUOTA_RESET) ||
(storagespaceQuota <= 0 && (storagespaceQuota < 0 &&
storagespaceQuota != HdfsConstants.QUOTA_DONT_SET && storagespaceQuota != HdfsConstants.QUOTA_DONT_SET &&
storagespaceQuota != HdfsConstants.QUOTA_RESET)) { storagespaceQuota != HdfsConstants.QUOTA_RESET)) {
throw new IllegalArgumentException("Invalid values for quota : " + throw new IllegalArgumentException("Invalid values for quota : " +

View File

@ -63,7 +63,7 @@ private void runCommand(DFSAdmin admin, String args[], boolean expectEror)
throws Exception { throws Exception {
int val = admin.run(args); int val = admin.run(args);
if (expectEror) { if (expectEror) {
assertEquals(val, -1); assertEquals(-1, val);
} else { } else {
assertTrue(val>=0); assertTrue(val>=0);
} }
@ -263,7 +263,7 @@ public void testQuotaCommands() throws Exception {
// 16a: set the quota of /test to be 0 // 16a: set the quota of /test to be 0
args = new String[]{"-setQuota", "0", parent.toString()}; args = new String[]{"-setQuota", "0", parent.toString()};
runCommand(admin, args, true); runCommand(admin, args, true);
runCommand(admin, true, "-setSpaceQuota", "0", args[2]); runCommand(admin, false, "-setSpaceQuota", "0", args[2]);
// 16b: set the quota of /test to be -1 // 16b: set the quota of /test to be -1
args[1] = "-1"; args[1] = "-1";