Hexiaoqiao commented on a change in pull request #2037:
URL: https://github.com/apache/hadoop/pull/2037#discussion_r449981097
##########
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:
I mean if we should update `storagespaceQuota < 0` to `storagespaceQuota
<= 0`, rather than whole condition statement.
##########
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:
or how about return directly? I think it is not necessary to send RPC
request to NameNode if has checked the parameter is invalid.
----------------------------------------------------------------
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]