fix style and throw exception instead of print

This commit is contained in:
zhaoym6 2020-07-07 10:53:57 +08:00
parent a2dbe5df80
commit 597aeb1fba
2 changed files with 18 additions and 16 deletions

View File

@ -210,9 +210,9 @@ public class DFSAdmin extends FsShell {
"\" is not a valid value for a quota.");
}
if (HdfsConstants.QUOTA_DONT_SET == this.quota) {
System.err.print("WARN: \"" + this.quota +
"\" means QUOTA_DONT_SET, quota will not be set, "
+ "it keep the old values. \n");
throw new IllegalArgumentException("WARN: \"" + this.quota +
"\" means QUOTA_DONT_SET, quota will not be set, " +
"it keep the old values.");
}
this.args = parameters.toArray(new String[parameters.size()]);
}
@ -335,9 +335,9 @@ public class DFSAdmin extends FsShell {
throw new IllegalArgumentException("\"" + str + "\" is not a valid value for a quota.");
}
if (HdfsConstants.QUOTA_DONT_SET == quota) {
System.err.print("WARN: \"" + this.quota +
"\" means QUOTA_DONT_SET, quota will not be set, "
+ "it keep the old values. \n");
throw new IllegalArgumentException("WARN: \"" + this.quota +
"\" means QUOTA_DONT_SET, quota will not be set, " +
"it keep the old values.");
}
String storageTypeString =
StringUtils.popOptionWithArgument("-storageType", parameters);

View File

@ -1236,14 +1236,15 @@ public class TestQuota {
final int ret = ToolRunner.run(
dfsAdmin,
new String[] {"-setQuota",
String.valueOf(HdfsConstants.QUOTA_DONT_SET), dir.toString()});
assertEquals(0, ret);
String.valueOf(HdfsConstants.QUOTA_DONT_SET),
dir.toString()});
assertEquals(-1, ret);
scanIntoList(ERR_STREAM, outs);
assertEquals(1, outs.size());
assertEquals(2, outs.size());
assertThat(outs.get(0),
is(allOf(containsString("WARN:"),
containsString("means QUOTA_DONT_SET, quota will not be set, " +
"it keep the old values."))));
containsString("means QUOTA_DONT_SET, quota will " +
"not be set, it keep the old values."))));
final List<String> outs1 = Lists.newArrayList();
/* set quota 0 */
@ -1280,14 +1281,15 @@ public class TestQuota {
final int ret = ToolRunner.run(
dfsAdmin,
new String[] {"-setSpaceQuota",
String.valueOf(HdfsConstants.QUOTA_DONT_SET), dir.toString()});
assertEquals(0, ret);
String.valueOf(HdfsConstants.QUOTA_DONT_SET),
dir.toString()});
assertEquals(-1, ret);
scanIntoList(ERR_STREAM, outs);
assertEquals(1, outs.size());
assertEquals(2, outs.size());
assertThat(outs.get(0),
is(allOf(containsString("WARN:"),
containsString("means QUOTA_DONT_SET, quota will not be set, " +
"it keep the old values."))));
containsString("means QUOTA_DONT_SET, quota will " +
"not be set, it keep the old values."))));
}
/**