getTokensByZone returns instances tokens grouped by zone. Tokens within each zone are guaranteed to be sorted.
()
| 520 | // getTokensByZone returns instances tokens grouped by zone. Tokens within each zone |
| 521 | // are guaranteed to be sorted. |
| 522 | func (d *Desc) getTokensByZone() map[string][]uint32 { |
| 523 | zones := map[string][][]uint32{} |
| 524 | for _, instance := range d.Ingesters { |
| 525 | // Tokens may not be sorted for an older version which, so we enforce sorting here. |
| 526 | tokens := instance.Tokens |
| 527 | if !sort.IsSorted(Tokens(tokens)) { |
| 528 | sort.Sort(Tokens(tokens)) |
| 529 | } |
| 530 | |
| 531 | zones[instance.Zone] = append(zones[instance.Zone], tokens) |
| 532 | } |
| 533 | |
| 534 | // Merge tokens per zone. |
| 535 | return MergeTokensByZone(zones) |
| 536 | } |
| 537 | |
| 538 | // getInstancesByAddr returns instances id by its address |
| 539 | func (d *Desc) getInstancesByAddr() map[string]string { |