linyiqun commented on a change in pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#discussion_r557834504
##########
File path:
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/client/OzoneQuota.java
##########
@@ -145,16 +164,14 @@ public static String formatQuota(OzoneQuota quota) {
}
/**
- * Parses a user provided string and returns the
+ * Parses a user provided string space quota and returns the
* Quota Object.
*
* @param quotaInBytes Volume quota in bytes
Review comment:
volume quota should be ozone quota since this quota can also the bucket
quota
##########
File path:
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/client/OzoneQuota.java
##########
@@ -190,14 +207,49 @@ 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 space 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
Review comment:
Same comment as above.
##########
File path:
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/client/OzoneQuota.java
##########
@@ -190,14 +207,49 @@ 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 space 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) {
+ if (Strings.isNullOrEmpty(quotaInNamespace)) {
+ throw new IllegalArgumentException(
+ "Quota string cannot be null or empty.");
+ }
+ long nameSpaceQuota = Long.parseLong(quotaInNamespace);
+ if (nameSpaceQuota <= 0) {
+ throw new IllegalArgumentException(
+ "Invalid values for namespace 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
Review comment:
Same comment as above.
----------------------------------------------------------------
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]