HDFS-3482. Merging r1358812 from trunk to branch-2
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1614814 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2feffe5d81
commit
80b7f0f424
|
@ -146,6 +146,9 @@ Release 2.6.0 - UNRELEASED
|
||||||
XmlEditsVisitor.java is JVM vendor specific. Breaks IBM JAVA.
|
XmlEditsVisitor.java is JVM vendor specific. Breaks IBM JAVA.
|
||||||
(Amir Sanjar via stevel)
|
(Amir Sanjar via stevel)
|
||||||
|
|
||||||
|
HDFS-3482. hdfs balancer throws ArrayIndexOutOfBoundsException
|
||||||
|
if option is specified without values. ( Madhukara Phatak via umamahesh)
|
||||||
|
|
||||||
Release 2.5.0 - UNRELEASED
|
Release 2.5.0 - UNRELEASED
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -87,6 +87,7 @@ import org.apache.hadoop.util.StringUtils;
|
||||||
import org.apache.hadoop.util.Time;
|
import org.apache.hadoop.util.Time;
|
||||||
import org.apache.hadoop.util.Tool;
|
import org.apache.hadoop.util.Tool;
|
||||||
import org.apache.hadoop.util.ToolRunner;
|
import org.apache.hadoop.util.ToolRunner;
|
||||||
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
|
|
||||||
/** <p>The balancer is a tool that balances disk space usage on an HDFS cluster
|
/** <p>The balancer is a tool that balances disk space usage on an HDFS cluster
|
||||||
* when some datanodes become full or when new empty nodes join the cluster.
|
* when some datanodes become full or when new empty nodes join the cluster.
|
||||||
|
@ -1584,6 +1585,7 @@ public class Balancer {
|
||||||
if (args != null) {
|
if (args != null) {
|
||||||
try {
|
try {
|
||||||
for(int i = 0; i < args.length; i++) {
|
for(int i = 0; i < args.length; i++) {
|
||||||
|
checkArgument(args.length >= 2, "args = " + Arrays.toString(args));
|
||||||
if ("-threshold".equalsIgnoreCase(args[i])) {
|
if ("-threshold".equalsIgnoreCase(args[i])) {
|
||||||
i++;
|
i++;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -538,6 +538,39 @@ public class TestBalancer {
|
||||||
oneNodeTest(conf, true);
|
oneNodeTest(conf, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test parse method in Balancer#Cli class with wrong number of params
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBalancerCliParseWithWrongParams() {
|
||||||
|
String parameters[] = new String[] { "-threshold" };
|
||||||
|
String reason =
|
||||||
|
"IllegalArgumentException is expected when value is not specified";
|
||||||
|
try {
|
||||||
|
Balancer.Cli.parse(parameters);
|
||||||
|
fail(reason);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
parameters = new String[] { "-policy" };
|
||||||
|
try {
|
||||||
|
Balancer.Cli.parse(parameters);
|
||||||
|
fail(reason);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
parameters = new String[] { "-threshold 1 -policy" };
|
||||||
|
try {
|
||||||
|
Balancer.Cli.parse(parameters);
|
||||||
|
fail(reason);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param args
|
* @param args
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue