To make sure you have a complete answer here, the order of the replica list that you specify in the partition reassignment will affect the leader selection, but if the current leader is in the new replica list, it will not change the leadership to change.
That is, if your current replica list is [1, 2] and the leader is 1, and you change the replica list to [3, 1] nothing happens immediately except that 2 is removed as a replica and 3 is added. Upon a failure of broker 1 or a preferred replica election, broker 3 will take over leadership. If the new replica list is [3, 4], then upon completion of the reassignment, broker 3 will be selected as the new leader. The controller will prefer to select the first broker in the replica list as the leader. This means that if you do a partition reassignment and change the replica list from [1, 2] to [2, 1], nothing happens at first. But upon the next preferred replica election, broker 2 will be selected as the leader. -Todd On Wed, Aug 5, 2015 at 3:37 AM, tao xiao <xiaotao...@gmail.com> wrote: > I think I figured it out. As pointed out in > > https://cwiki.apache.org/confluence/display/KAFKA/Replication+tools#Replicationtools-6.ReassignPartitionsTool > > If the leader is not in the reassigned replica a new leader will be elected > and the tool doesn't pick the first one from the RAR as the leader > > On Wed, 5 Aug 2015 at 18:32 Jilin Xie <jilinxie1...@gmail.com> wrote: > > > Check the --replica-assignment parameter of the kafka-topics.sh. > > It does what you need. > > And there should also be similar configs in the api if you wanna do so by > > coding. > > > > On Wed, Aug 5, 2015 at 6:18 PM, tao xiao <xiaotao...@gmail.com> wrote: > > > > > Hi team, > > > > > > Is it possible to specify a leader broker for each topic partition when > > > doing partition reassignment? > > > > > > For example I have following json. Is the first broker in the replicas > > list > > > by default the leader of the partition e.g. broker 3 is the leader of > > topic > > > test5 and broker 2 is the leader of topic test3. or does Kafka > > > automatically pick the leader based on the leadership ratio > > > if auto.leader.rebalance.enable is on > > > > > > { > > > "version": 1, > > > "partitions": [ > > > { > > > "topic": "test5", > > > "partition": 0, > > > "replicas": [3, 1] > > > }, > > > { > > > "topic": "test3", > > > "partition": 0, > > > "replicas": [2,3] > > > }, > > > { > > > "topic": "test1", > > > "partition": 0, > > > "replicas": [1,2] > > > } > > > ] > > > } > > > > > >