XComp commented on code in PR #22422:
URL: https://github.com/apache/flink/pull/22422#discussion_r1173943821


##########
flink-runtime/src/main/java/org/apache/flink/runtime/leaderelection/LeaderElectionEventHandler.java:
##########
@@ -39,12 +40,29 @@ public interface LeaderElectionEventHandler {
      */
     void onGrantLeadership(UUID newLeaderSessionId);
 
+    /**
+     * Called by specific {@link LeaderElectionDriver} when the leadership is 
granted.
+     *
+     * <p>This method will trigger the grant event processing in a separate 
thread.
+     *
+     * @param newLeaderSessionId the valid leader session id
+     */
+    CompletableFuture<Void> onGrantLeadershipAsync(UUID newLeaderSessionId);

Review Comment:
   How would we determine that we're running in the main thread? We would need 
to get a reference to the owner of `DefaultLeaderElectionService`, wouldn't we? 
That way we would be able to check whether the call is run in the main thread 
of the owner. But this would closer coupling of the owner and the 
`DefaultLeaderElectionService`. Or do you have something else in mind which I'm 
missing? :thinking: 
   
   My understanding is that we have the following requirements:
   * `onGrantLeadership`, `onRevokeLeadership` and `onLeaderInformationChanged` 
should be called in a single thread to ensure sequential execution.
   * the methods shouldn't be called in the main thread of the 
`LeaderElectionService`'s owner. The k8s and ZK implementation do this 
implicitly through their event thread handling. The 
`DefaultMultipleComponentLeaderElectionService` doesn't do that (anymore). But 
that's an implementation detail of the service. That's why I thought that it's 
also the `DefaultMultipleComponentLeaderElectionService`'s responsibility to 
call the event processing functions asynchronously.
   
   WDYT?



-- 
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