RemoveInvalid removes invalid nodes from the list of pools.
(state *pb.MembershipState)
| 105 | |
| 106 | // RemoveInvalid removes invalid nodes from the list of pools. |
| 107 | func (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. |
no test coverage detected