diff options
Diffstat (limited to 'weed/topology')
| -rw-r--r-- | weed/topology/node.go | 4 | ||||
| -rw-r--r-- | weed/topology/topology.go | 2 | ||||
| -rw-r--r-- | weed/topology/topology_event_handling.go | 2 | ||||
| -rw-r--r-- | weed/topology/volume_growth.go | 6 | ||||
| -rw-r--r-- | weed/topology/volume_layout.go | 4 |
5 files changed, 9 insertions, 9 deletions
diff --git a/weed/topology/node.go b/weed/topology/node.go index 851e71385..7e443533f 100644 --- a/weed/topology/node.go +++ b/weed/topology/node.go @@ -2,7 +2,7 @@ package topology import ( "errors" - "math/rand" + "math/rand/v2" "strings" "sync" "sync/atomic" @@ -83,7 +83,7 @@ func (n *NodeImpl) PickNodesByWeight(numberOfNodes int, option *VolumeGrowOption //pick nodes randomly by weights, the node picked earlier has higher final weights sortedCandidates := make([]Node, 0, len(candidates)) for i := 0; i < len(candidates); i++ { - weightsInterval := rand.Int63n(totalWeights) + weightsInterval := rand.Int64N(totalWeights) lastWeights := int64(0) for k, weights := range candidatesWeights { if (weightsInterval >= lastWeights) && (weightsInterval < lastWeights+weights) { diff --git a/weed/topology/topology.go b/weed/topology/topology.go index 6a149bd56..6bfd912cb 100644 --- a/weed/topology/topology.go +++ b/weed/topology/topology.go @@ -4,7 +4,7 @@ import ( "encoding/json" "errors" "fmt" - "math/rand" + "math/rand/v2" "sync" "time" diff --git a/weed/topology/topology_event_handling.go b/weed/topology/topology_event_handling.go index 60459d7b7..ff1c642a6 100644 --- a/weed/topology/topology_event_handling.go +++ b/weed/topology/topology_event_handling.go @@ -1,7 +1,7 @@ package topology import ( - "math/rand" + "math/rand/v2" "time" "github.com/seaweedfs/seaweedfs/weed/stats" diff --git a/weed/topology/volume_growth.go b/weed/topology/volume_growth.go index ff516599d..7f8684753 100644 --- a/weed/topology/volume_growth.go +++ b/weed/topology/volume_growth.go @@ -4,7 +4,7 @@ import ( "encoding/json" "fmt" "github.com/seaweedfs/seaweedfs/weed/pb/master_pb" - "math/rand" + "math/rand/v2" "sync" "time" @@ -222,7 +222,7 @@ func (vg *VolumeGrowth) findEmptySlotsForOneVolume(topo *Topology, option *Volum servers = append(servers, server.(*DataNode)) } for _, rack := range otherRacks { - r := rand.Int63n(rack.AvailableSpaceFor(option)) + r := rand.Int64N(rack.AvailableSpaceFor(option)) if server, e := rack.ReserveOneVolume(r, option); e == nil { servers = append(servers, server) } else { @@ -230,7 +230,7 @@ func (vg *VolumeGrowth) findEmptySlotsForOneVolume(topo *Topology, option *Volum } } for _, datacenter := range otherDataCenters { - r := rand.Int63n(datacenter.AvailableSpaceFor(option)) + r := rand.Int64N(datacenter.AvailableSpaceFor(option)) if server, e := datacenter.ReserveOneVolume(r, option); e == nil { servers = append(servers, server) } else { diff --git a/weed/topology/volume_layout.go b/weed/topology/volume_layout.go index 3fab74843..89378ba97 100644 --- a/weed/topology/volume_layout.go +++ b/weed/topology/volume_layout.go @@ -3,7 +3,7 @@ package topology import ( "fmt" "github.com/seaweedfs/seaweedfs/weed/stats" - "math/rand" + "math/rand/v2" "sync" "sync/atomic" "time" @@ -296,7 +296,7 @@ func (vl *VolumeLayout) PickForWrite(count uint64, option *VolumeGrowOption) (vi return 0, 0, nil, true, fmt.Errorf("%s in volume layout", noWritableVolumes) } if option.DataCenter == "" && option.Rack == "" && option.DataNode == "" { - vid := vl.writables[rand.Intn(lenWriters)] + vid := vl.writables[rand.IntN(lenWriters)] locationList = vl.vid2location[vid] if locationList == nil || len(locationList.list) == 0 { return 0, 0, nil, false, fmt.Errorf("Strangely vid %s is on no machine!", vid.String()) |
