GetTokens returns sorted list of tokens owned by all instances within the ring.
()
| 493 | |
| 494 | // GetTokens returns sorted list of tokens owned by all instances within the ring. |
| 495 | func (d *Desc) GetTokens() []uint32 { |
| 496 | instances := make([][]uint32, 0, len(d.Ingesters)) |
| 497 | for _, instance := range d.Ingesters { |
| 498 | // Tokens may not be sorted for an older version which, so we enforce sorting here. |
| 499 | tokens := instance.Tokens |
| 500 | if !sort.IsSorted(Tokens(tokens)) { |
| 501 | sort.Sort(Tokens(tokens)) |
| 502 | } |
| 503 | |
| 504 | instances = append(instances, tokens) |
| 505 | } |
| 506 | |
| 507 | return MergeTokens(instances) |
| 508 | } |
| 509 | |
| 510 | // getTokensByZone returns instances tokens grouped by zone. Tokens within each zone |
| 511 | // are guaranteed to be sorted. |