Hexiaoqiao commented on a change in pull request #2037:
URL: https://github.com/apache/hadoop/pull/2037#discussion_r449842359
##########
File path:
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/DFSAdmin.java
##########
@@ -201,8 +201,19 @@ public void run(Path path) throws IOException {
super(conf);
CommandFormat c = new CommandFormat(2, Integer.MAX_VALUE);
List<String> parameters = c.parse(args, pos);
- this.quota =
-
StringUtils.TraditionalBinaryPrefix.string2long(parameters.remove(0));
+ String str = parameters.get(0).trim();
+ try {
+ this.quota = StringUtils.TraditionalBinaryPrefix
+ .string2long(parameters.remove(0));
+ } catch(NumberFormatException e){
+ throw new IllegalArgumentException("\"" + str +
+ "\" is not a valid value for a quota.");
+ }
+ if (HdfsConstants.QUOTA_DONT_SET == this.quota) {
+ System.out.print("WARN: \"" + this.quota +
Review comment:
IMO, it should be using `System.err.print`.
Another side, it is better to throw exception and no need to execute the
following logic if meet invalid parameter.
##########
File path:
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/DFSAdmin.java
##########
@@ -323,6 +334,11 @@ public void run(Path path) throws IOException {
} catch (NumberFormatException nfe) {
throw new IllegalArgumentException("\"" + str + "\" is not a valid
value for a quota.");
}
+ if (HdfsConstants.QUOTA_DONT_SET == quota) {
+ System.out.print("WARN: \"" + this.quota +
Review comment:
the same as last comment.
##########
File path:
hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSClient.java
##########
@@ -2553,16 +2553,17 @@ void setQuota(String src, long namespaceQuota, long
storagespaceQuota)
throws IOException {
checkOpen();
// sanity check
- if ((namespaceQuota <= 0 &&
- namespaceQuota != HdfsConstants.QUOTA_DONT_SET &&
- namespaceQuota != HdfsConstants.QUOTA_RESET) ||
- (storagespaceQuota < 0 &&
+ if (namespaceQuota <= 0 &&
+ namespaceQuota != HdfsConstants.QUOTA_DONT_SET &&
+ namespaceQuota != HdfsConstants.QUOTA_RESET){
+ throw new IllegalArgumentException("Invalid values for " +
+ "namespace quota : " + namespaceQuota);
+ }
+ if (storagespaceQuota < 0 &&
Review comment:
this condition statement should be `if (storagesapceQuoat <= 0)`?
----------------------------------------------------------------
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]