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



##########
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) {
+      throw new IllegalArgumentException(
+          "Invalid values for quota: " + nameSpaceQuota);
+    }
+    return new OzoneQuota(nameSpaceQuota, new RawQuotaInBytes(Units.BYTES, 
-1));
+  }
+
+  /**
+   * Parses a user provided string and returns the
+   * Quota Object.
+   *
+   * @param quotaInBytes Volume quota in bytes
+   * @param quotaInNamespace Volume quota in counts
+   *
+   * @return OzoneQuota object
+   */
+  public static OzoneQuota parseQuota(String quotaInBytes,
+      String quotaInNamespace) {

Review comment:
       Hi @linyiqun , thanks for review the code.  We found bugs in production 
cluster with the previous implementation which doesn't distinguish the cases 
that user doesn't set the quota and user set the quota to 0.  So it's better to 
make it clear to avoid bugs caused by concept vague.  
   
   In summary, for quota in bucket and volume,  
   1) quota value will be -2  to indicates it's 1.0.0 bucket/volume 
   2) quota value will be -1 if  bucket/volume created without explicitly set 
quota value in 1.1.0
   3) quota > 0 indicates quota is enabled
   4) throw exception if user set quota to 0 to keep consistent with current 
HDFS behavior
   
   I‘m not sure If I have answered your question. Let me know if a further 
explanation is needed. 
   




----------------------------------------------------------------
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:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to