fix style and throw exception instead of print
This commit is contained in:
parent
a2dbe5df80
commit
597aeb1fba
|
@ -210,9 +210,9 @@ public class DFSAdmin extends FsShell {
|
||||||
"\" is not a valid value for a quota.");
|
"\" is not a valid value for a quota.");
|
||||||
}
|
}
|
||||||
if (HdfsConstants.QUOTA_DONT_SET == this.quota) {
|
if (HdfsConstants.QUOTA_DONT_SET == this.quota) {
|
||||||
System.err.print("WARN: \"" + this.quota +
|
throw new IllegalArgumentException("WARN: \"" + this.quota +
|
||||||
"\" means QUOTA_DONT_SET, quota will not be set, "
|
"\" means QUOTA_DONT_SET, quota will not be set, " +
|
||||||
+ "it keep the old values. \n");
|
"it keep the old values.");
|
||||||
}
|
}
|
||||||
this.args = parameters.toArray(new String[parameters.size()]);
|
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.");
|
throw new IllegalArgumentException("\"" + str + "\" is not a valid value for a quota.");
|
||||||
}
|
}
|
||||||
if (HdfsConstants.QUOTA_DONT_SET == quota) {
|
if (HdfsConstants.QUOTA_DONT_SET == quota) {
|
||||||
System.err.print("WARN: \"" + this.quota +
|
throw new IllegalArgumentException("WARN: \"" + this.quota +
|
||||||
"\" means QUOTA_DONT_SET, quota will not be set, "
|
"\" means QUOTA_DONT_SET, quota will not be set, " +
|
||||||
+ "it keep the old values. \n");
|
"it keep the old values.");
|
||||||
}
|
}
|
||||||
String storageTypeString =
|
String storageTypeString =
|
||||||
StringUtils.popOptionWithArgument("-storageType", parameters);
|
StringUtils.popOptionWithArgument("-storageType", parameters);
|
||||||
|
|
|
@ -1236,14 +1236,15 @@ public class TestQuota {
|
||||||
final int ret = ToolRunner.run(
|
final int ret = ToolRunner.run(
|
||||||
dfsAdmin,
|
dfsAdmin,
|
||||||
new String[] {"-setQuota",
|
new String[] {"-setQuota",
|
||||||
String.valueOf(HdfsConstants.QUOTA_DONT_SET), dir.toString()});
|
String.valueOf(HdfsConstants.QUOTA_DONT_SET),
|
||||||
assertEquals(0, ret);
|
dir.toString()});
|
||||||
|
assertEquals(-1, ret);
|
||||||
scanIntoList(ERR_STREAM, outs);
|
scanIntoList(ERR_STREAM, outs);
|
||||||
assertEquals(1, outs.size());
|
assertEquals(2, outs.size());
|
||||||
assertThat(outs.get(0),
|
assertThat(outs.get(0),
|
||||||
is(allOf(containsString("WARN:"),
|
is(allOf(containsString("WARN:"),
|
||||||
containsString("means QUOTA_DONT_SET, quota will not be set, " +
|
containsString("means QUOTA_DONT_SET, quota will " +
|
||||||
"it keep the old values."))));
|
"not be set, it keep the old values."))));
|
||||||
|
|
||||||
final List<String> outs1 = Lists.newArrayList();
|
final List<String> outs1 = Lists.newArrayList();
|
||||||
/* set quota 0 */
|
/* set quota 0 */
|
||||||
|
@ -1280,14 +1281,15 @@ public class TestQuota {
|
||||||
final int ret = ToolRunner.run(
|
final int ret = ToolRunner.run(
|
||||||
dfsAdmin,
|
dfsAdmin,
|
||||||
new String[] {"-setSpaceQuota",
|
new String[] {"-setSpaceQuota",
|
||||||
String.valueOf(HdfsConstants.QUOTA_DONT_SET), dir.toString()});
|
String.valueOf(HdfsConstants.QUOTA_DONT_SET),
|
||||||
assertEquals(0, ret);
|
dir.toString()});
|
||||||
|
assertEquals(-1, ret);
|
||||||
scanIntoList(ERR_STREAM, outs);
|
scanIntoList(ERR_STREAM, outs);
|
||||||
assertEquals(1, outs.size());
|
assertEquals(2, outs.size());
|
||||||
assertThat(outs.get(0),
|
assertThat(outs.get(0),
|
||||||
is(allOf(containsString("WARN:"),
|
is(allOf(containsString("WARN:"),
|
||||||
containsString("means QUOTA_DONT_SET, quota will not be set, " +
|
containsString("means QUOTA_DONT_SET, quota will " +
|
||||||
"it keep the old values."))));
|
"not be set, it keep the old values."))));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue