mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
refactor(master_grpc_server_cluster): seletedSet
-> selectedSet
(#3693)
Signed-off-by: Ryan Russell <git@ryanrussell.org> Signed-off-by: Ryan Russell <git@ryanrussell.org>
This commit is contained in:
parent
f9e3e7d1c4
commit
c202d4c1b0
|
@ -57,15 +57,15 @@ func limitTo(nodes []*cluster.ClusterNode, limit int32) (selected []*cluster.Clu
|
||||||
if limit <= 0 || len(nodes) < int(limit) {
|
if limit <= 0 || len(nodes) < int(limit) {
|
||||||
return nodes
|
return nodes
|
||||||
}
|
}
|
||||||
seletedSet := make(map[pb.ServerAddress]*cluster.ClusterNode)
|
selectedSet := make(map[pb.ServerAddress]*cluster.ClusterNode)
|
||||||
for i := 0; i < int(limit)*3; i++ {
|
for i := 0; i < int(limit)*3; i++ {
|
||||||
x := rand.Intn(len(nodes))
|
x := rand.Intn(len(nodes))
|
||||||
if _, found := seletedSet[nodes[x].Address]; found {
|
if _, found := selectedSet[nodes[x].Address]; found {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
seletedSet[nodes[x].Address] = nodes[x]
|
selectedSet[nodes[x].Address] = nodes[x]
|
||||||
}
|
}
|
||||||
for _, node := range seletedSet {
|
for _, node := range selectedSet {
|
||||||
selected = append(selected, node)
|
selected = append(selected, node)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue