Update memberlist vendor deps

This commit is contained in:
Kyle Havlovitz 2016-12-13 18:53:40 -05:00
parent 9853df3b8f
commit 42bc44634b
No known key found for this signature in database
GPG Key ID: 8A5E6B173056AD6C
4 changed files with 50 additions and 29 deletions

View File

@ -126,8 +126,12 @@ type Config struct {
// per GossipInterval. Increasing this number causes the gossip messages // per GossipInterval. Increasing this number causes the gossip messages
// to propagate across the cluster more quickly at the expense of // to propagate across the cluster more quickly at the expense of
// increased bandwidth. // increased bandwidth.
GossipInterval time.Duration //
GossipNodes int // GossipToTheDeadTime is the interval after which a node has died that
// we will still try to gossip to it. This gives it a chance to refute.
GossipInterval time.Duration
GossipNodes int
GossipToTheDeadTime time.Duration
// EnableCompression is used to control message compression. This can // EnableCompression is used to control message compression. This can
// be used to reduce bandwidth usage at the cost of slightly more CPU // be used to reduce bandwidth usage at the cost of slightly more CPU
@ -212,8 +216,9 @@ func DefaultLANConfig() *Config {
DisableTcpPings: false, // TCP pings are safe, even with mixed versions DisableTcpPings: false, // TCP pings are safe, even with mixed versions
AwarenessMaxMultiplier: 8, // Probe interval backs off to 8 seconds AwarenessMaxMultiplier: 8, // Probe interval backs off to 8 seconds
GossipNodes: 3, // Gossip to 3 nodes GossipNodes: 3, // Gossip to 3 nodes
GossipInterval: 200 * time.Millisecond, // Gossip more rapidly GossipInterval: 200 * time.Millisecond, // Gossip more rapidly
GossipToTheDeadTime: 30 * time.Second, // Same as push/pull
EnableCompression: true, // Enable compression by default EnableCompression: true, // Enable compression by default
@ -238,6 +243,7 @@ func DefaultWANConfig() *Config {
conf.ProbeInterval = 5 * time.Second conf.ProbeInterval = 5 * time.Second
conf.GossipNodes = 4 // Gossip less frequently, but to an additional node conf.GossipNodes = 4 // Gossip less frequently, but to an additional node
conf.GossipInterval = 500 * time.Millisecond conf.GossipInterval = 500 * time.Millisecond
conf.GossipToTheDeadTime = 60 * time.Second
return conf return conf
} }
@ -254,6 +260,7 @@ func DefaultLocalConfig() *Config {
conf.ProbeTimeout = 200 * time.Millisecond conf.ProbeTimeout = 200 * time.Millisecond
conf.ProbeInterval = time.Second conf.ProbeInterval = time.Second
conf.GossipInterval = 100 * time.Millisecond conf.GossipInterval = 100 * time.Millisecond
conf.GossipToTheDeadTime = 15 * time.Second
return conf return conf
} }

View File

@ -310,8 +310,11 @@ func (m *Memberlist) probeNode(node *nodeState) {
// Get some random live nodes. // Get some random live nodes.
m.nodeLock.RLock() m.nodeLock.RLock()
excludes := []string{m.config.Name, node.Name} kNodes := kRandomNodes(m.config.IndirectChecks, m.nodes, func(n *nodeState) bool {
kNodes := kRandomNodes(m.config.IndirectChecks, excludes, m.nodes) return n.Name == m.config.Name ||
n.Name == node.Name ||
n.State != stateAlive
})
m.nodeLock.RUnlock() m.nodeLock.RUnlock()
// Attempt an indirect ping. // Attempt an indirect ping.
@ -460,10 +463,24 @@ func (m *Memberlist) resetNodes() {
func (m *Memberlist) gossip() { func (m *Memberlist) gossip() {
defer metrics.MeasureSince([]string{"memberlist", "gossip"}, time.Now()) 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() m.nodeLock.RLock()
excludes := []string{m.config.Name} kNodes := kRandomNodes(m.config.GossipNodes, m.nodes, func(n *nodeState) bool {
kNodes := kRandomNodes(m.config.GossipNodes, excludes, m.nodes) 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() m.nodeLock.RUnlock()
// Compute the bytes available // Compute the bytes available
@ -497,8 +514,10 @@ func (m *Memberlist) gossip() {
func (m *Memberlist) pushPull() { func (m *Memberlist) pushPull() {
// Get a random live node // Get a random live node
m.nodeLock.RLock() m.nodeLock.RLock()
excludes := []string{m.config.Name} nodes := kRandomNodes(1, m.nodes, func(n *nodeState) bool {
nodes := kRandomNodes(1, excludes, m.nodes) return n.Name == m.config.Name ||
n.State != stateAlive
})
m.nodeLock.RUnlock() m.nodeLock.RUnlock()
// If no nodes, bail // If no nodes, bail

View File

@ -155,8 +155,9 @@ func randomOffset(n int) int {
// suspicionTimeout computes the timeout that should be used when // suspicionTimeout computes the timeout that should be used when
// a node is suspected // a node is suspected
func suspicionTimeout(suspicionMult, n int, interval time.Duration) time.Duration { func suspicionTimeout(suspicionMult, n int, interval time.Duration) time.Duration {
nodeScale := math.Ceil(math.Log10(float64(n + 1))) nodeScale := math.Max(1.0, math.Log10(math.Max(1.0, float64(n))))
timeout := time.Duration(suspicionMult) * time.Duration(nodeScale) * interval // multiply by 1000 to keep some precision because time.Duration is an int64 type
timeout := time.Duration(suspicionMult) * time.Duration(nodeScale*1000) * interval / 1000
return timeout return timeout
} }
@ -207,9 +208,10 @@ func moveDeadNodes(nodes []*nodeState) int {
return n - numDead return n - numDead
} }
// kRandomNodes is used to select up to k random nodes, excluding a given // kRandomNodes is used to select up to k random nodes, excluding any nodes where
// node and any non-alive nodes. It is possible that less than k nodes are returned. // the filter function returns true. It is possible that less than k nodes are
func kRandomNodes(k int, excludes []string, nodes []*nodeState) []*nodeState { // returned.
func kRandomNodes(k int, nodes []*nodeState, filterFn func(*nodeState) bool) []*nodeState {
n := len(nodes) n := len(nodes)
kNodes := make([]*nodeState, 0, k) kNodes := make([]*nodeState, 0, k)
OUTER: OUTER:
@ -221,16 +223,9 @@ OUTER:
idx := randomOffset(n) idx := randomOffset(n)
node := nodes[idx] node := nodes[idx]
// Exclude node if match // Give the filter a shot at it.
for _, exclude := range excludes { if filterFn != nil && filterFn(node) {
if node.Name == exclude { continue OUTER
continue OUTER
}
}
// Exclude if not alive
if node.State != stateAlive {
continue
} }
// Check if we have this node already // Check if we have this node already

6
vendor/vendor.json vendored
View File

@ -528,10 +528,10 @@
"revisionTime": "2015-06-09T07:04:31Z" "revisionTime": "2015-06-09T07:04:31Z"
}, },
{ {
"checksumSHA1": "F2jm1h5jRic/Q0e3UEk4aqzS7k0=", "checksumSHA1": "hSoH77pX3FyU6kkYqOOYmf3r55Y=",
"path": "github.com/hashicorp/memberlist", "path": "github.com/hashicorp/memberlist",
"revision": "56f5fd70afa73f13bbe529192aeb3dc7bc4bc960", "revision": "9800c50ab79c002353852a9b1095e9591b161513",
"revisionTime": "2016-12-05T22:01:58Z" "revisionTime": "2016-12-13T23:44:46Z"
}, },
{ {
"checksumSHA1": "qnlqWJYV81ENr61SZk9c65R1mDo=", "checksumSHA1": "qnlqWJYV81ENr61SZk9c65R1mDo=",