diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 42eed140de0..29ecf7b9877 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -359,6 +359,9 @@ Release 2.8.0 - UNRELEASED IMPROVEMENTS + HDFS-2390. dfsadmin -setBalancerBandwidth does not validate -ve value + (Gautam Gopalakrishnan via harsh) + HDFS-8821. Explain message "Operation category X is not supported in state standby" (Gautam Gopalakrishnan via harsh) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/DFSAdmin.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/DFSAdmin.java index 014637bbc5b..298d55e6b19 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/DFSAdmin.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/DFSAdmin.java @@ -851,6 +851,11 @@ public class DFSAdmin extends FsShell { return exitCode; } + if (bandwidth < 0) { + System.err.println("Bandwidth should be a non-negative integer"); + return exitCode; + } + FileSystem fs = getFS(); if (!(fs instanceof DistributedFileSystem)) { System.err.println("FileSystem is " + fs.getUri()); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/TestDFSAdminWithHA.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/TestDFSAdminWithHA.java index 6859e436a4a..a6c0924b4ff 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/TestDFSAdminWithHA.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/TestDFSAdminWithHA.java @@ -192,6 +192,13 @@ public class TestDFSAdminWithHA { assertOutputMatches(message + newLine + message + newLine); } + @Test (timeout = 30000) + public void testSetNegativeBalancerBandwidth() throws Exception { + setUpHaCluster(false); + int exitCode = admin.run(new String[] {"-setBalancerBandwidth", "-10"}); + assertEquals("Negative bandwidth value must fail the command", -1, exitCode); + } + @Test (timeout = 30000) public void testMetaSave() throws Exception { setUpHaCluster(false);