|
@@ -130,8 +130,15 @@ func (ht hostToken) String() string {
|
|
|
// a data structure for organizing the relationship between tokens and hosts
|
|
// a data structure for organizing the relationship between tokens and hosts
|
|
|
type tokenRing struct {
|
|
type tokenRing struct {
|
|
|
partitioner partitioner
|
|
partitioner partitioner
|
|
|
- tokens []hostToken
|
|
|
|
|
- hosts []*HostInfo
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // tokens map token range to primary replica.
|
|
|
|
|
+ // The elements in tokens are sorted by token ascending.
|
|
|
|
|
+ // The range for a given item in tokens starts after preceding range and ends with the token specified in
|
|
|
|
|
+ // token. The end token is part of the range.
|
|
|
|
|
+ // The lowest (i.e. index 0) range wraps around the ring (its preceding range is the one with largest index).
|
|
|
|
|
+ tokens []hostToken
|
|
|
|
|
+
|
|
|
|
|
+ hosts []*HostInfo
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func newTokenRing(partitioner string, hosts []*HostInfo) (*tokenRing, error) {
|
|
func newTokenRing(partitioner string, hosts []*HostInfo) (*tokenRing, error) {
|