It might increase lock contention but writes to change the leadership occurs not so frequently so using readLock wouldn't be much of an issue I think. I also considered comparing ReplicaManager.localBrokerId with Partition.leaderReplicaIdOpt without a lock this will present an issue where the leader is changed and we might be comparing against old leader value.
Instead of using leaderReplicaIfLocal I can create another method "checkLeader" in Partition which will return a boolean after obtaining a readLock on leaderIsrUpdateLock. Right now there is unnecessary call going to getReplica.
This is an automatically generated e-mail. To reply, visit:
On July 15, 2014, 1:18 a.m., Sriharsha Chintalapani wrote: