| 396 | } |
| 397 | |
| 398 | func (m *Smap) GetRandProxy(excludePrimary bool) (si *Snode, err error) { |
| 399 | var cnt int |
| 400 | for _, psi := range m.Pmap { |
| 401 | if psi.IsAnySet(NodeFlagsMaintDecomm) { |
| 402 | cnt++ |
| 403 | continue |
| 404 | } |
| 405 | if !excludePrimary || !m.IsPrimary(psi) { |
| 406 | return psi, nil |
| 407 | } |
| 408 | } |
| 409 | return nil, fmt.Errorf("failed to find a random proxy (num=%d, in-maintenance=%d, exclude-primary=%t)", |
| 410 | len(m.Pmap), cnt, excludePrimary) |
| 411 | } |
| 412 | |
| 413 | func (m *Smap) IsDuplicate(nsi *Snode) (osi *Snode, err error) { |
| 414 | for _, tsi := range m.Tmap { |