apoorvmittal10 commented on PR #17796:
URL: https://github.com/apache/kafka/pull/17796#issuecomment-2474731772

   > @apoorvmittal10 what is the purpose of this listener? Is is so that SPM 
can clean up its in-memory state when it is no longer the leader for a 
partition?
   
   Yes, that's the purpose.
   
   
   > If that's the main use case, I think we should consider tying into the 
metadata system directly rather than coupling ourselves to Partition.
   
   So as far as I see the code there exists 1 approach taken by coordinators: 
in replica manager where we have a method `becomeLeaderOrFollower` where we 
pass `onLeadershipChange` method. The `onLeadershipChange` method triggers 
`groupCoordinator` and `txnCordinators`, `onElection` and `onResignation` 
methods. The 2) approach is by invoking the listeners on partition change.
   
   I am not sure if we do get leadership change notifications from metadata 
system. Not sure if we could have some kind of leaderEpochChange listener to 
see the partition epoch bump and do some actions. But I found the listeners 
approach much sensible.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to