GetTokens returns sorted list of tokens owned by all instances within the ring.
()
| 503 | |
| 504 | // GetTokens returns sorted list of tokens owned by all instances within the ring. |
| 505 | func (d *Desc) GetTokens() []uint32 { |
| 506 | instances := make([][]uint32, 0, len(d.Ingesters)) |
| 507 | for _, instance := range d.Ingesters { |
| 508 | // Tokens may not be sorted for an older version which, so we enforce sorting here. |
| 509 | tokens := instance.Tokens |
| 510 | if !sort.IsSorted(Tokens(tokens)) { |
| 511 | sort.Sort(Tokens(tokens)) |
| 512 | } |
| 513 | |
| 514 | instances = append(instances, tokens) |
| 515 | } |
| 516 | |
| 517 | return MergeTokens(instances) |
| 518 | } |
| 519 | |
| 520 | // getTokensByZone returns instances tokens grouped by zone. Tokens within each zone |
| 521 | // are guaranteed to be sorted. |