MCPcopy
hub / github.com/dgraph-io/dgraph / RemoveInvalid

Method RemoveInvalid

conn/pool.go:107–125  ·  view source on GitHub ↗

RemoveInvalid removes invalid nodes from the list of pools.

(state *pb.MembershipState)

Source from the content-addressed store, hash-verified

105
106// RemoveInvalid removes invalid nodes from the list of pools.
107func (p *Pools) RemoveInvalid(state *pb.MembershipState) {
108 // Keeps track of valid IP addresses, assigned to active nodes. We do this
109 // to avoid removing valid IP addresses from the Removed list.
110 validAddr := make(map[string]struct{})
111 for _, group := range state.Groups {
112 for _, member := range group.Members {
113 validAddr[member.Addr] = struct{}{}
114 }
115 }
116 for _, member := range state.Zeros {
117 validAddr[member.Addr] = struct{}{}
118 }
119 for _, member := range state.Removed {
120 // Some nodes could have the same IP address. So, check before disconnecting.
121 if _, valid := validAddr[member.Addr]; !valid {
122 p.remove(member.Addr)
123 }
124 }
125}
126
127// Remove disconnects and removes the pool for addr. It is a no-op if addr is
128// not in the pool. Used to clean up stale connections after an address change.

Callers 2

checkQuorumMethod · 0.80
applyStateMethod · 0.80

Calls 1

removeMethod · 0.95

Tested by

no test coverage detected