valepakh commented on code in PR #2152:
URL: https://github.com/apache/ignite-3/pull/2152#discussion_r1226333402
##########
modules/cluster-management/src/main/java/org/apache/ignite/internal/cluster/management/raft/CmgRaftService.java:
##########
@@ -228,6 +228,38 @@ public Set<String> nodeNames() {
.collect(toSet());
}
+ /**
+ * Returns a set of consistent IDs of the majority of the voting nodes of
the CMG, including a leader.
+ *
+ * @return Set of consistent IDs of the majority of the voting nodes of
the CMG, including a leader.
+ */
+ public CompletableFuture<Set<String>> majority() {
+ Peer leader = raftService.leader();
+
+ if (leader == null) {
+ return raftService.refreshLeader().thenCompose(v -> majority());
+ }
+
+ List<Peer> peers = raftService.peers();
+
+ assert peers != null;
+
+ int peersCount = peers.size();
+ String leaderId = leader.consistentId();
+
+ // Take half of the voting peers without the leader.
+ Set<String> result = peers.stream()
+ .map(Peer::consistentId)
+ .filter(consistentId -> !consistentId.equals(leaderId))
+ .limit(peersCount / 2)
+ .collect(toSet());
Review Comment:
It's a set mainly because the deployment APIs use sets.
--
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]