numberOfKeysOwnedByInstance returns how many of the supplied keys are owned by given instance.
(r *Ring, keys []uint32, op Operation, instanceID string, bufDescs []InstanceDesc, bufHosts, bufZones []string)
| 269 | |
| 270 | // numberOfKeysOwnedByInstance returns how many of the supplied keys are owned by given instance. |
| 271 | func numberOfKeysOwnedByInstance(r *Ring, keys []uint32, op Operation, instanceID string, bufDescs []InstanceDesc, bufHosts, bufZones []string) (int, error) { |
| 272 | owned := 0 |
| 273 | if !r.HasInstance(instanceID) { |
| 274 | return 0, nil |
| 275 | } |
| 276 | |
| 277 | for _, tok := range keys { |
| 278 | s, err := r.Get(tok, op, bufDescs, bufHosts, bufZones) |
| 279 | if err != nil { |
| 280 | return 0, err |
| 281 | } |
| 282 | |
| 283 | for _, inst := range s.Instances { |
| 284 | if inst.Id == instanceID { |
| 285 | owned++ |
| 286 | break |
| 287 | } |
| 288 | } |
| 289 | } |
| 290 | |
| 291 | return owned, nil |
| 292 | } |
| 293 | |
| 294 | type nopReplicationStrategy struct{} |
| 295 |
no test coverage detected