You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@kafka.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2017/05/16 21:01:04 UTC

[jira] [Commented] (KAFKA-5258) move all partition and replica state transition rules into a map

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

ASF GitHub Bot commented on KAFKA-5258:
---------------------------------------

GitHub user onurkaraman opened a pull request:

    https://github.com/apache/kafka/pull/3071

    KAFKA-5258: move all partition and replica state transition rules into a map

    Today the PartitionStateMachine and ReplicaStateMachine defines and asserts the valid state transitions inline for each state. It would be cleaner to move all partition and replica state transition rules into a map and simply do the assertion at the top of the handleStateChange.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/onurkaraman/kafka KAFKA-5258

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/kafka/pull/3071.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #3071
    
----
commit 6ae6e2cad6137604e578ce6b12c1e566ebdac20f
Author: Onur Karaman <ok...@linkedin.com>
Date:   2017-05-16T20:56:03Z

    KAFKA-5258: move all partition and replica state transition rules into a map
    
    Today the PartitionStateMachine and ReplicaStateMachine defines and asserts the valid state transitions inline for each state. It would be cleaner to move all partition and replica state transition rules into a map and simply do the assertion at the top of the handleStateChange.

----


> move all partition and replica state transition rules into a map
> ----------------------------------------------------------------
>
>                 Key: KAFKA-5258
>                 URL: https://issues.apache.org/jira/browse/KAFKA-5258
>             Project: Kafka
>          Issue Type: Sub-task
>            Reporter: Onur Karaman
>            Assignee: Onur Karaman
>            Priority: Minor
>
> Today the PartitionStateMachine and ReplicaStateMachine defines and asserts the valid state transitions inline for each state, looking something like:
> {code}
> private def handleStateChange(...) {
>   targetState match {
>     case stateA => {
>       assertValidPreviousStates(topicAndPartition, List(stateX, stateY, stateZ), stateA)
>       // actual work
>     }
>     case stateB => {
>       assertValidPreviousStates(topicAndPartition, List(stateD, stateE), stateB)
>       // actual work
>     }
>   }
> }
> {code}
> It would be cleaner to move all partition and replica state transition rules into a map and simply do the assertion at the top of the handleStateChange method like so:
> {code}
> private val validPreviousStates: Map[State, Set[State]] = ...
> private def handleStateChange(...) {
>   assertValidTransition(targetState)
>   targetState match {
>     case stateA => {
>       // actual work
>     }
>     case stateB => {
>       // actual work
>     }
>   }
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)