MCPcopy Create free account
hub / github.com/dadgar/onecache / getOwner

Function getOwner

onecache/replicator_test.go:182–211  ·  view source on GitHub ↗

getOwner returns the owner and the original set of nodes without the owner.

(key string, nodes []*Node)

Source from the content-addressed store, hash-verified

180
181// getOwner returns the owner and the original set of nodes without the owner.
182func getOwner(key string, nodes []*Node) (*Node, []*Node) {
183 if len(nodes) == 0 {
184 return nil, nil
185 }
186
187 // Get a copy of the ring and clear it.
188 r := nodes[0].ring.ringCopy()
189 for _, m := range r.(*consistentRing).ring.Members() {
190 r.remove(m)
191 }
192
193 lookup := make(map[string]*Node, len(nodes))
194 for _, n := range nodes {
195 lookup[n.name] = n
196 r.add(n.name)
197 }
198
199 // Get the successor.
200 s := r.successor(key)
201 owner := lookup[s]
202
203 var followers []*Node
204 for name, node := range lookup {
205 if name != s {
206 followers = append(followers, node)
207 }
208 }
209
210 return owner, followers
211}
212
213func TestMarkDirtyValue(t *testing.T) {
214 nodes, err := connectedTestNodes(2, 2)

Callers 4

TestMarkDirtyValueFunction · 0.85
TestMarkDeletedFunction · 0.85
TestMarkTouchedFunction · 0.85

Calls 4

ringCopyMethod · 0.65
removeMethod · 0.65
addMethod · 0.65
successorMethod · 0.65

Tested by

no test coverage detected