MCPcopy Create free account
hub / github.com/apache/kvrocks-controller / GetLeaderID

Method GetLeaderID

store/engine/raft/node_test.go:125–138  ·  view source on GitHub ↗

GetLeaderNode returns the leader node, if there is no leader or reach consensus return raft.None. excludeNodeID is the node ID that will be excluded from the leader check, it's useful when we want to check if the leader is changed.

(excludeNodeID uint64)

Source from the content-addressed store, hash-verified

123// excludeNodeID is the node ID that will be excluded from the leader check, it's useful when we want to
124// check if the leader is changed.
125func (c *TestCluster) GetLeaderID(excludeNodeID uint64) uint64 {
126 leaderID := raft.None
127 for _, n := range c.nodes {
128 if n.config.ID == excludeNodeID {
129 continue
130 }
131 // If the leader is not the same means nodes are not reach consensus.
132 if leaderID != raft.None && leaderID != n.GetRaftLead() {
133 return raft.None
134 }
135 leaderID = n.GetRaftLead()
136 }
137 return leaderID
138}
139
140func (c *TestCluster) ListNodes() []*Node {
141 return c.nodes

Callers 2

IsReadyMethod · 0.95
TestCluster_MultiNodesFunction · 0.95

Calls 1

GetRaftLeadMethod · 0.80

Tested by

no test coverage detected