Exemple #1
0
func (t *RingBackend) InitRing(replicas int) {
	var tmp_ring *consistent.Consistent = consistent.New()
	tmp_ring.NumberOfReplicas = replicas

	t.RLock()
	for name, _ := range t.Addrs {
		tmp_ring.Add(name)
	}
	t.RUnlock()

	t.Lock()
	defer t.Unlock()

	t.Ring = tmp_ring
}
Exemple #2
0
func NewConsistentHashNodesRing(numberOfReplicas int32, nodes []string) *ConsistentHashNodeRing {
	ret := &ConsistentHashNodeRing{ring: consistent.New()}
	ret.SetNumberOfReplicas(numberOfReplicas)
	ret.SetNodes(nodes)
	return ret
}