RingCompare compares this ring against another one and returns one of Equal, EqualButStatesAndTimestamps, EqualButReadOnly or Different.
(o *Desc)
| 557 | |
| 558 | // RingCompare compares this ring against another one and returns one of Equal, EqualButStatesAndTimestamps, EqualButReadOnly or Different. |
| 559 | func (d *Desc) RingCompare(o *Desc) CompareResult { |
| 560 | if d == nil { |
| 561 | if o == nil || len(o.Ingesters) == 0 { |
| 562 | return Equal |
| 563 | } |
| 564 | return Different |
| 565 | } |
| 566 | if o == nil { |
| 567 | if len(d.Ingesters) == 0 { |
| 568 | return Equal |
| 569 | } |
| 570 | return Different |
| 571 | } |
| 572 | |
| 573 | if len(d.Ingesters) != len(o.Ingesters) { |
| 574 | return Different |
| 575 | } |
| 576 | |
| 577 | equalStatesAndTimestamps := true |
| 578 | equalReadOnly := true |
| 579 | |
| 580 | for name, ing := range d.Ingesters { |
| 581 | oing, ok := o.Ingesters[name] |
| 582 | if !ok { |
| 583 | return Different |
| 584 | } |
| 585 | |
| 586 | if ing.Addr != oing.Addr { |
| 587 | return Different |
| 588 | } |
| 589 | |
| 590 | if ing.Zone != oing.Zone { |
| 591 | return Different |
| 592 | } |
| 593 | |
| 594 | if ing.RegisteredTimestamp != oing.RegisteredTimestamp { |
| 595 | return Different |
| 596 | } |
| 597 | |
| 598 | if len(ing.Tokens) != len(oing.Tokens) { |
| 599 | return Different |
| 600 | } |
| 601 | |
| 602 | for ix, t := range ing.Tokens { |
| 603 | if oing.Tokens[ix] != t { |
| 604 | return Different |
| 605 | } |
| 606 | } |
| 607 | |
| 608 | if ing.Timestamp != oing.Timestamp { |
| 609 | equalStatesAndTimestamps = false |
| 610 | } |
| 611 | |
| 612 | if ing.State != oing.State { |
| 613 | if ing.State == READONLY || oing.State == READONLY { |
| 614 | equalReadOnly = false |
| 615 | } else { |
| 616 | equalStatesAndTimestamps = false |
no outgoing calls