kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rsiva...@apache.org
Subject kafka git commit: KAFKA-5837; Set defaults for ReassignPartitionsCommand correctly
Date Tue, 05 Sep 2017 23:33:12 GMT
Repository: kafka
Updated Branches:
  refs/heads/trunk 81e789ae3 -> 5d6996619


KAFKA-5837; Set defaults for ReassignPartitionsCommand correctly

Author: Rajini Sivaram <rajinisivaram@googlemail.com>

Reviewers: Dong Lin <lindong28@gmail.com>

Closes #3792 from rajinisivaram/KAFKA-5837


Project: http://git-wip-us.apache.org/repos/asf/kafka/repo
Commit: http://git-wip-us.apache.org/repos/asf/kafka/commit/5d699661
Tree: http://git-wip-us.apache.org/repos/asf/kafka/tree/5d699661
Diff: http://git-wip-us.apache.org/repos/asf/kafka/diff/5d699661

Branch: refs/heads/trunk
Commit: 5d69966195409d73e6e4d74e8a898fac754450cc
Parents: 81e789a
Author: Rajini Sivaram <rajinisivaram@googlemail.com>
Authored: Wed Sep 6 00:32:59 2017 +0100
Committer: Rajini Sivaram <rajinisivaram@googlemail.com>
Committed: Wed Sep 6 00:32:59 2017 +0100

----------------------------------------------------------------------
 .../scala/kafka/admin/ReassignPartitionsCommand.scala  |  4 ++--
 .../admin/ReassignPartitionsCommandArgsTest.scala      | 13 ++++++++++++-
 2 files changed, 14 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/5d699661/core/src/main/scala/kafka/admin/ReassignPartitionsCommand.scala
----------------------------------------------------------------------
diff --git a/core/src/main/scala/kafka/admin/ReassignPartitionsCommand.scala b/core/src/main/scala/kafka/admin/ReassignPartitionsCommand.scala
index e27e239..5dbcfcf 100755
--- a/core/src/main/scala/kafka/admin/ReassignPartitionsCommand.scala
+++ b/core/src/main/scala/kafka/admin/ReassignPartitionsCommand.scala
@@ -445,13 +445,13 @@ object ReassignPartitionsCommand extends Logging {
     val throttleOpt = parser.accepts("throttle", "The movement of partitions will be throttled
to this value (bytes/sec). Rerunning with this option, whilst a rebalance is in progress,
will alter the throttle value. The throttle rate should be at least 1 KB/s.")
                       .withRequiredArg()
                       .describedAs("throttle")
-                      .defaultsTo("-1")
                       .ofType(classOf[Long])
+                      .defaultsTo(-1)
     val timeoutOpt = parser.accepts("timeout", "The maximum time in ms allowed to wait for
partition reassignment execution to be successfully initiated")
                       .withRequiredArg()
                       .describedAs("timeout")
-                      .defaultsTo("10000")
                       .ofType(classOf[Long])
+                      .defaultsTo(10000)
     val options = parser.parse(args : _*)
   }
 }

http://git-wip-us.apache.org/repos/asf/kafka/blob/5d699661/core/src/test/scala/unit/kafka/admin/ReassignPartitionsCommandArgsTest.scala
----------------------------------------------------------------------
diff --git a/core/src/test/scala/unit/kafka/admin/ReassignPartitionsCommandArgsTest.scala
b/core/src/test/scala/unit/kafka/admin/ReassignPartitionsCommandArgsTest.scala
index 3a40cf8..49f3c1a 100644
--- a/core/src/test/scala/unit/kafka/admin/ReassignPartitionsCommandArgsTest.scala
+++ b/core/src/test/scala/unit/kafka/admin/ReassignPartitionsCommandArgsTest.scala
@@ -17,7 +17,7 @@
 package kafka.admin
 
 import kafka.utils.Exit
-import org.junit.Assert.assertTrue
+import org.junit.Assert._
 import org.junit.{After, Before, Test}
 import org.scalatest.junit.JUnitSuite
 
@@ -75,6 +75,17 @@ class ReassignPartitionsCommandArgsTest extends JUnitSuite {
     ReassignPartitionsCommand.validateAndParseArgs(args)
   }
 
+  @Test
+  def shouldUseDefaultsIfEnabled(): Unit = {
+    val args = Array(
+      "--zookeeper", "localhost:1234",
+      "--execute",
+      "--reassignment-json-file", "myfile.json")
+    val opts = ReassignPartitionsCommand.validateAndParseArgs(args)
+    assertEquals(10000L, opts.options.valueOf(opts.timeoutOpt))
+    assertEquals(-1L, opts.options.valueOf(opts.throttleOpt))
+  }
+
   /**
     * NO ARGS
     */


Mime
View raw message