mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-02-09 09:17:28 +08:00
change math/rand => math/rand/v2 in volume_layout.go where is a perfo… (#6006)
This commit is contained in:
@@ -2,12 +2,13 @@ package topology
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/seaweedfs/seaweedfs/weed/pb/master_pb"
|
"math/rand/v2"
|
||||||
"math/rand"
|
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/seaweedfs/seaweedfs/weed/pb/master_pb"
|
||||||
|
|
||||||
"github.com/seaweedfs/seaweedfs/weed/storage/types"
|
"github.com/seaweedfs/seaweedfs/weed/storage/types"
|
||||||
|
|
||||||
"github.com/seaweedfs/seaweedfs/weed/glog"
|
"github.com/seaweedfs/seaweedfs/weed/glog"
|
||||||
@@ -304,7 +305,7 @@ func (vl *VolumeLayout) PickForWrite(count uint64, option *VolumeGrowOption) (vi
|
|||||||
return 0, 0, nil, true, fmt.Errorf("%s", noWritableVolumes)
|
return 0, 0, nil, true, fmt.Errorf("%s", noWritableVolumes)
|
||||||
}
|
}
|
||||||
if option.DataCenter == "" && option.Rack == "" && option.DataNode == "" {
|
if option.DataCenter == "" && option.Rack == "" && option.DataNode == "" {
|
||||||
vid := vl.writables[rand.Intn(lenWriters)]
|
vid := vl.writables[rand.IntN(lenWriters)]
|
||||||
locationList = vl.vid2location[vid]
|
locationList = vl.vid2location[vid]
|
||||||
if locationList == nil || len(locationList.list) == 0 {
|
if locationList == nil || len(locationList.list) == 0 {
|
||||||
return 0, 0, nil, false, fmt.Errorf("Strangely vid %s is on no machine!", vid.String())
|
return 0, 0, nil, false, fmt.Errorf("Strangely vid %s is on no machine!", vid.String())
|
||||||
|
|||||||
Reference in New Issue
Block a user