reswqa commented on code in PR #22422:
URL: https://github.com/apache/flink/pull/22422#discussion_r1172594434
##########
flink-runtime/src/main/java/org/apache/flink/runtime/leaderelection/LeaderElectionEventHandler.java:
##########
@@ -39,12 +40,26 @@ public interface LeaderElectionEventHandler {
*/
void onGrantLeadership(UUID newLeaderSessionId);
+ /**
+ * Called by specific {@link LeaderElectionDriver} when the leadership is
granted. This method
+ * will trigger the grant event processing in a separate thread.
Review Comment:
Perhaps we should also add the specific description of `This method will
trigger the xxx processing in a separate thread.` for other `xxxAsync`
methods as well.
##########
flink-runtime/src/test/java/org/apache/flink/runtime/leaderelection/TestingLeaderElectionEventHandler.java:
##########
@@ -74,6 +75,15 @@ private void ifRunning(Runnable action) {
}
}
+ @Override
+ public CompletableFuture<Void> onGrantLeadershipAsync(UUID
newLeaderSessionId) {
Review Comment:
How about marking `TestingLeaderElectionEventHandler` and
`TestingLeaderContender` as `@Deprecated` first to prevent other developers
from using this class for testing and reduce the workload of ultimately
removing these two classes. 🤔
##########
flink-runtime/src/main/java/org/apache/flink/runtime/leaderelection/DefaultMultipleComponentLeaderElectionService.java:
##########
@@ -271,16 +239,22 @@ public void notifyAllKnownLeaderInformation(
leaderNameLeaderElectionEventHandlerPair :
leaderElectionEventHandlers.entrySet()) {
final String leaderName =
leaderNameLeaderElectionEventHandlerPair.getKey();
- if (leaderInformationByName.containsKey(leaderName)) {
- sendLeaderInformationChange(
-
leaderNameLeaderElectionEventHandlerPair.getValue(),
- leaderInformationByName.get(leaderName));
- } else {
- sendLeaderInformationChange(
-
leaderNameLeaderElectionEventHandlerPair.getValue(),
- LeaderInformation.empty());
- }
+ final LeaderElectionEventHandler leaderElectionEventHandler =
+ leaderNameLeaderElectionEventHandlerPair.getValue();
+ final LeaderInformation leaderInformation =
+ leaderInformationByName.containsKey(leaderName)
+ ? leaderInformationByName.get(leaderName)
+ : LeaderInformation.empty();
+
+ assertFatalError(
+
leaderElectionEventHandler.onLeaderInformationChangeAsync(
+ leaderInformation));
}
}
}
+
+ private void assertFatalError(CompletableFuture<Void> future) {
Review Comment:
If I don't take a closer look at the code logic, I feel like the name is
saying: This `CompletableFuture ` will definitely carry a fatal error. 🤔
Perhaps it's more appropriate to named it `handleFatalError` or
`handleException`?
--
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]