You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@kafka.apache.org by "Gwen Shapira (JIRA)" <ji...@apache.org> on 2015/03/01 08:15:04 UTC

[jira] [Commented] (KAFKA-1991) Clean ControllerStats initialization

    [ https://issues.apache.org/jira/browse/KAFKA-1991?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14342011#comment-14342011 ] 

Gwen Shapira commented on KAFKA-1991:
-------------------------------------

Nice catch! Thanks for finding and fixing.

+1 (non-binding)

> Clean ControllerStats initialization
> ------------------------------------
>
>                 Key: KAFKA-1991
>                 URL: https://issues.apache.org/jira/browse/KAFKA-1991
>             Project: Kafka
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 0.8.2.0
>            Reporter: Grant Henke
>            Priority: Trivial
>         Attachments: KAFKA-1991.patch
>
>
> This is just a trivial clean up. Values defined by an object are instantiated lazily and are initialized the first time the object is used. 
> This could cause confusion and down the road issues about when/what metrics are initialized in the ControllerStats object. KafkaServer.scala makes a call to each value to initialize it but Scala is not actually behaving that way.
> The change matches the BrokerTopicStats implementation
> example:
> scala> object ControllerStats {
>      |    val uncleanLeaderElectionRate = {
>      |             println("initializing uncleanLeaderElectionRate")
>      |             "uncleanLeaderElectionRate"
>      |         }
>      |    val leaderElectionTimer = {
>      |         println("initializing leaderElectionTimer")
>      |         "leaderElectionTimer"
>      |    }
>      | }
> defined object ControllerStats
> scala> ControllerStats.uncleanLeaderElectionRate
> initializing uncleanLeaderElectionRate
> initializing leaderElectionTimer
> res7: String = uncleanLeaderElectionRate



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)