You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by gw...@apache.org on 2016/08/19 18:59:15 UTC
kafka git commit: KAFKA-4053: remove redundant if/else statements in
TopicCommand
Repository: kafka
Updated Branches:
refs/heads/trunk 880bde5ac -> 33447cb4b
KAFKA-4053: remove redundant if/else statements in TopicCommand
Author: Shuai Zhang <sh...@gmail.com>
Reviewers: Gwen Shapira
Closes #1751 from sh-z/KAFKA-4053
Project: http://git-wip-us.apache.org/repos/asf/kafka/repo
Commit: http://git-wip-us.apache.org/repos/asf/kafka/commit/33447cb4
Tree: http://git-wip-us.apache.org/repos/asf/kafka/tree/33447cb4
Diff: http://git-wip-us.apache.org/repos/asf/kafka/diff/33447cb4
Branch: refs/heads/trunk
Commit: 33447cb4beb8dd710a20556a6a2baf8307f03860
Parents: 880bde5
Author: Shuai Zhang <sh...@gmail.com>
Authored: Fri Aug 19 11:59:11 2016 -0700
Committer: Gwen Shapira <cs...@gmail.com>
Committed: Fri Aug 19 11:59:11 2016 -0700
----------------------------------------------------------------------
core/src/main/scala/kafka/admin/TopicCommand.scala | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/kafka/blob/33447cb4/core/src/main/scala/kafka/admin/TopicCommand.scala
----------------------------------------------------------------------
diff --git a/core/src/main/scala/kafka/admin/TopicCommand.scala b/core/src/main/scala/kafka/admin/TopicCommand.scala
index 657f26c..421486c 100755
--- a/core/src/main/scala/kafka/admin/TopicCommand.scala
+++ b/core/src/main/scala/kafka/admin/TopicCommand.scala
@@ -91,7 +91,7 @@ object TopicCommand extends Logging {
def createTopic(zkUtils: ZkUtils, opts: TopicCommandOptions) {
val topic = opts.options.valueOf(opts.topicOpt)
val configs = parseTopicConfigsToBeAdded(opts)
- val ifNotExists = if (opts.options.has(opts.ifNotExistsOpt)) true else false
+ val ifNotExists = opts.options.has(opts.ifNotExistsOpt)
if (Topic.hasCollisionChars(topic))
println("WARNING: Due to limitations in metric names, topics with a period ('.') or underscore ('_') could collide. To avoid issues it is best to use either, but not both.")
try {
@@ -116,7 +116,7 @@ object TopicCommand extends Logging {
def alterTopic(zkUtils: ZkUtils, opts: TopicCommandOptions) {
val topics = getTopics(zkUtils, opts)
- val ifExists = if (opts.options.has(opts.ifExistsOpt)) true else false
+ val ifExists = opts.options.has(opts.ifExistsOpt)
if (topics.isEmpty && !ifExists) {
throw new IllegalArgumentException("Topic %s does not exist on ZK path %s".format(opts.options.valueOf(opts.topicOpt),
opts.options.valueOf(opts.zkConnectOpt)))
@@ -163,7 +163,7 @@ object TopicCommand extends Logging {
def deleteTopic(zkUtils: ZkUtils, opts: TopicCommandOptions) {
val topics = getTopics(zkUtils, opts)
- val ifExists = if (opts.options.has(opts.ifExistsOpt)) true else false
+ val ifExists = opts.options.has(opts.ifExistsOpt)
if (topics.isEmpty && !ifExists) {
throw new IllegalArgumentException("Topic %s does not exist on ZK path %s".format(opts.options.valueOf(opts.topicOpt),
opts.options.valueOf(opts.zkConnectOpt)))
@@ -190,9 +190,9 @@ object TopicCommand extends Logging {
def describeTopic(zkUtils: ZkUtils, opts: TopicCommandOptions) {
val topics = getTopics(zkUtils, opts)
- val reportUnderReplicatedPartitions = if (opts.options.has(opts.reportUnderReplicatedPartitionsOpt)) true else false
- val reportUnavailablePartitions = if (opts.options.has(opts.reportUnavailablePartitionsOpt)) true else false
- val reportOverriddenConfigs = if (opts.options.has(opts.topicsWithOverridesOpt)) true else false
+ val reportUnderReplicatedPartitions = opts.options.has(opts.reportUnderReplicatedPartitionsOpt)
+ val reportUnavailablePartitions = opts.options.has(opts.reportUnavailablePartitionsOpt)
+ val reportOverriddenConfigs = opts.options.has(opts.topicsWithOverridesOpt)
val liveBrokers = zkUtils.getAllBrokersInCluster().map(_.id).toSet
for (topic <- topics) {
zkUtils.getPartitionAssignmentForTopics(List(topic)).get(topic) match {