Exemplo n.º 1
0
func buildHashRing(rings []*JSONRingType) *hashing.HashRing {
	hr := hashing.NewHashRing()
	for _, n := range rings[0].Nodes {
		// ports are already removed
		fields := strings.Split(n, ":")
		if len(fields) < 2 {
			hr.AddNode(hashing.NewNode(fields[0], ""))
		} else {
			hr.AddNode(hashing.NewNode(fields[0], fields[1]))
		}
	}

	return hr
}
Exemplo n.º 2
0
func makeRing(config []string) *hashing.HashRing {
	hr := hashing.NewHashRing()
	for _, n := range config {
		fields := strings.Split(n, ":")
		if len(fields) < 2 {
			fields = append(fields, uuid.New())
		} else if fields[1] == "" {
			fields[1] = uuid.New()
		}
		hr.AddNode(hashing.NewNode(fields[0], fields[1]))
	}

	return hr
}