|
|
|
@ -310,8 +310,11 @@ func (m *Memberlist) probeNode(node *nodeState) {
|
|
|
|
|
|
|
|
|
|
// Get some random live nodes.
|
|
|
|
|
m.nodeLock.RLock()
|
|
|
|
|
excludes := []string{m.config.Name, node.Name}
|
|
|
|
|
kNodes := kRandomNodes(m.config.IndirectChecks, excludes, m.nodes)
|
|
|
|
|
kNodes := kRandomNodes(m.config.IndirectChecks, m.nodes, func(n *nodeState) bool {
|
|
|
|
|
return n.Name == m.config.Name ||
|
|
|
|
|
n.Name == node.Name ||
|
|
|
|
|
n.State != stateAlive
|
|
|
|
|
})
|
|
|
|
|
m.nodeLock.RUnlock()
|
|
|
|
|
|
|
|
|
|
// Attempt an indirect ping.
|
|
|
|
@ -460,10 +463,24 @@ func (m *Memberlist) resetNodes() {
|
|
|
|
|
func (m *Memberlist) gossip() {
|
|
|
|
|
defer metrics.MeasureSince([]string{"memberlist", "gossip"}, time.Now())
|
|
|
|
|
|
|
|
|
|
// Get some random live nodes
|
|
|
|
|
// Get some random live, suspect, or recently dead nodes
|
|
|
|
|
m.nodeLock.RLock()
|
|
|
|
|
excludes := []string{m.config.Name}
|
|
|
|
|
kNodes := kRandomNodes(m.config.GossipNodes, excludes, m.nodes)
|
|
|
|
|
kNodes := kRandomNodes(m.config.GossipNodes, m.nodes, func(n *nodeState) bool {
|
|
|
|
|
if n.Name == m.config.Name {
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch n.State {
|
|
|
|
|
case stateAlive, stateSuspect:
|
|
|
|
|
return false
|
|
|
|
|
|
|
|
|
|
case stateDead:
|
|
|
|
|
return time.Since(n.StateChange) > m.config.GossipToTheDeadTime
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
m.nodeLock.RUnlock()
|
|
|
|
|
|
|
|
|
|
// Compute the bytes available
|
|
|
|
@ -497,8 +514,10 @@ func (m *Memberlist) gossip() {
|
|
|
|
|
func (m *Memberlist) pushPull() {
|
|
|
|
|
// Get a random live node
|
|
|
|
|
m.nodeLock.RLock()
|
|
|
|
|
excludes := []string{m.config.Name}
|
|
|
|
|
nodes := kRandomNodes(1, excludes, m.nodes)
|
|
|
|
|
nodes := kRandomNodes(1, m.nodes, func(n *nodeState) bool {
|
|
|
|
|
return n.Name == m.config.Name ||
|
|
|
|
|
n.State != stateAlive
|
|
|
|
|
})
|
|
|
|
|
m.nodeLock.RUnlock()
|
|
|
|
|
|
|
|
|
|
// If no nodes, bail
|
|
|
|
|