You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2020/12/31 08:02:35 UTC

[GitHub] [ozone] captainzmc commented on a change in pull request #1746: HDDS-4631. Fix client set quota with 0.

captainzmc commented on a change in pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#discussion_r550423090



##########
File path: hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/client/OzoneQuota.java
##########
@@ -190,14 +201,44 @@ public static OzoneQuota parseQuota(String quotaInBytes,
           " value cannot be greater than Long.MAX_VALUE BYTES");
     }
 
-    if (nSize < 0) {
-      throw new IllegalArgumentException("Quota cannot be negative.");
+    if (nSize <= 0) {
+      throw new IllegalArgumentException("Invalid values for quota: " + nSize);
     }
 
-    return new OzoneQuota(quotaInNamespace,
-        new RawQuotaInBytes(currUnit, nSize));
+    return new OzoneQuota(new RawQuotaInBytes(currUnit, nSize));
   }
 
+  /**
+   * Parses a user provided string Namespace quota and returns the
+   * Quota Object.
+   *
+   * @param quotaInNamespace Volume quota in counts
+   *
+   * @return OzoneQuota object
+   */
+  public static OzoneQuota parseNameSpaceQuota(String quotaInNamespace) {
+    long nameSpaceQuota = Long.parseLong(quotaInNamespace);
+    if (nameSpaceQuota <= 0) {

Review comment:
       If the user specifies quota when creating bucket and volume,the default is -1, indicating that quota is not enabled.
   
   A quota value of -2 is a special case, because older clusters such as previous versions of Ozone1.0, volume Info and bucket Info do not have quotaInBytes and quotaInNamespace in them. After such a cluster is upgraded to Ozone1.1, these fields become to 0 when getting volume Info and bucket Info because they didn't exist before, so in HDDS-4562 proto is set to -2 by default, indicating that these volumes and buckets are old, and their quota is also not enabled. Currently, it is not recommended to enable quota for these volumes and buckets because their usedbyte and usedNamespace are incorrect. So, -2 is more used to distinguish between old volumes and buckets. Later if we can support recalculation of usedbyte and usedNamespace. This lets us know which volumes and buckets need to be recalculated.
   
   To disable quota, use the clrquota method instead of setquota.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org