You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Aleksandr Polovtcev (Jira)" <ji...@apache.org> on 2022/09/26 08:12:00 UTC

[jira] [Commented] (IGNITE-17493) CMG service should use onLeaderElected callback in order to detect the fact that current node is a leader

    [ https://issues.apache.org/jira/browse/IGNITE-17493?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17609360#comment-17609360 ] 

Aleksandr Polovtcev commented on IGNITE-17493:
----------------------------------------------

Unfortunately, the listener implement in IGNITE-16379 is pretty much useless: since it is impossible to detect if a leadership is lost (or a non-local node has been elected as a leader), we still have to resort to polling the {{refreshLeader}} method. Therefore I decided to simply add a condition to the CMG leader topology listener to check if it is still the leader.

> CMG service should use onLeaderElected callback in order to detect the fact that current node is a leader
> ---------------------------------------------------------------------------------------------------------
>
>                 Key: IGNITE-17493
>                 URL: https://issues.apache.org/jira/browse/IGNITE-17493
>             Project: Ignite
>          Issue Type: Improvement
>            Reporter: Vyacheslav Koptilin
>            Assignee: Aleksandr Polovtcev
>            Priority: Major
>              Labels: ignite-3
>
> CmgRaftService service should use onLeaderElected callback in order to detect the fact that current node is a leader.
> {code:java}
>     /**
>      * Returns {@code true} if the current node is the CMG leader.
>      *
>      * @return {@code true} if the current node is the CMG leader.
>      */
>     // TODO: replace with onLeaderElected callback after https://issues.apache.org/jira/browse/IGNITE-16379 is implemented
>     public CompletableFuture<Boolean> isCurrentNodeLeader() {
>         ClusterNode thisNode = clusterService.topologyService().localMember();
>         return leader().thenApply(thisNode::equals);
>     }
>     private CompletableFuture<ClusterNode> leader() {
>         return raftService.refreshLeader().thenApply(v -> resolvePeer(raftService.leader()));
>     }
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)