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



##########
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:
       The above advice only solves our problem of creating volume or bucket, 
not setquota.
   The string quotainNamespace in parseQuota is still useful for verifying 
whether the user passed quotainNamespace.Let's look at this case:
   
   If the original volume space and namespace quoat were 100 and 10T, 
respectively, we reset the space quota separately:
   ozone sh volume setquota vol1 --space-quota 20TB
   OzoneConsts.QUOTA_RESET is the default quota for VolumeArgs. The space and 
namespace quota for vol1 will change to -1 and 20T, which is not expected.
   
   I think it makes more sense to handle these cases in Ozonequota #parseQuota. 
Also, spaceQuota is currently a String in parseQuota, which makes our 
client-side processing logic more consistent.




----------------------------------------------------------------
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