mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-09-22 20:53:32 +08:00
math/rand => math/rand/v2
This commit is contained in:
@@ -3,11 +3,11 @@ package weed_server
|
||||
import (
|
||||
"github.com/seaweedfs/seaweedfs/weed/glog"
|
||||
"github.com/seaweedfs/seaweedfs/weed/security"
|
||||
util_http "github.com/seaweedfs/seaweedfs/weed/util/http"
|
||||
"github.com/seaweedfs/seaweedfs/weed/util/mem"
|
||||
"io"
|
||||
"math/rand"
|
||||
"math/rand/v2"
|
||||
"net/http"
|
||||
util_http "github.com/seaweedfs/seaweedfs/weed/util/http"
|
||||
)
|
||||
|
||||
func (fs *FilerServer) maybeAddVolumeJwtAuthorization(r *http.Request, fileId string, isWrite bool) {
|
||||
@@ -44,7 +44,7 @@ func (fs *FilerServer) proxyToVolumeServer(w http.ResponseWriter, r *http.Reques
|
||||
return
|
||||
}
|
||||
|
||||
proxyReq, err := http.NewRequest(r.Method, urlStrings[rand.Intn(len(urlStrings))], r.Body)
|
||||
proxyReq, err := http.NewRequest(r.Method, urlStrings[rand.IntN(len(urlStrings))], r.Body)
|
||||
if err != nil {
|
||||
glog.Errorf("NewRequest %s: %v", urlStrings[0], err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
|
@@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/seaweedfs/seaweedfs/weed/stats"
|
||||
"math/rand"
|
||||
"math/rand/v2"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@@ -108,7 +108,7 @@ func (locks *AdminLocks) generateToken(lockName string, clientName string) (ts t
|
||||
locks.Lock()
|
||||
defer locks.Unlock()
|
||||
lock := &AdminLock{
|
||||
accessSecret: rand.Int63(),
|
||||
accessSecret: rand.Int64(),
|
||||
accessLockTime: time.Now(),
|
||||
lastClient: clientName,
|
||||
}
|
||||
|
@@ -5,7 +5,7 @@ import (
|
||||
"github.com/seaweedfs/seaweedfs/weed/cluster"
|
||||
"github.com/seaweedfs/seaweedfs/weed/pb"
|
||||
"github.com/seaweedfs/seaweedfs/weed/pb/master_pb"
|
||||
"math/rand"
|
||||
"math/rand/v2"
|
||||
)
|
||||
|
||||
func (ms *MasterServer) ListClusterNodes(ctx context.Context, req *master_pb.ListClusterNodesRequest) (*master_pb.ListClusterNodesResponse, error) {
|
||||
@@ -31,7 +31,7 @@ func (ms *MasterServer) GetOneFiler(filerGroup cluster.FilerGroupName) pb.Server
|
||||
filers := ms.Cluster.ListClusterNode(filerGroup, cluster.FilerType)
|
||||
|
||||
if len(filers) > 0 {
|
||||
return filers[rand.Intn(len(filers))].Address
|
||||
return filers[rand.IntN(len(filers))].Address
|
||||
}
|
||||
return "localhost:8888"
|
||||
}
|
||||
@@ -42,7 +42,7 @@ func limitTo(nodes []*cluster.ClusterNode, limit int32) (selected []*cluster.Clu
|
||||
}
|
||||
selectedSet := make(map[pb.ServerAddress]*cluster.ClusterNode)
|
||||
for i := 0; i < int(limit)*3; i++ {
|
||||
x := rand.Intn(len(nodes))
|
||||
x := rand.IntN(len(nodes))
|
||||
if _, found := selectedSet[nodes[x].Address]; found {
|
||||
continue
|
||||
}
|
||||
|
@@ -3,7 +3,7 @@ package weed_server
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"math/rand/v2"
|
||||
"reflect"
|
||||
"strings"
|
||||
"sync"
|
||||
|
@@ -5,7 +5,7 @@ import (
|
||||
"fmt"
|
||||
"github.com/seaweedfs/seaweedfs/weed/pb"
|
||||
"github.com/seaweedfs/seaweedfs/weed/pb/master_pb"
|
||||
"math/rand"
|
||||
"math/rand/v2"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -113,7 +113,7 @@ func (ms *MasterServer) redirectHandler(w http.ResponseWriter, r *http.Request)
|
||||
collection := r.FormValue("collection")
|
||||
location := ms.findVolumeLocation(collection, vid)
|
||||
if location.Error == "" {
|
||||
loc := location.Locations[rand.Intn(len(location.Locations))]
|
||||
loc := location.Locations[rand.IntN(len(location.Locations))]
|
||||
url, _ := util_http.NormalizeUrl(loc.PublicUrl)
|
||||
if r.URL.RawQuery != "" {
|
||||
url = url + r.URL.Path + "?" + r.URL.RawQuery
|
||||
|
@@ -5,7 +5,7 @@ package weed_server
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"math/rand/v2"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
|
@@ -3,7 +3,7 @@ package weed_server
|
||||
import (
|
||||
"encoding/json"
|
||||
"io"
|
||||
"math/rand"
|
||||
"math/rand/v2"
|
||||
"os"
|
||||
"path"
|
||||
"time"
|
||||
|
Reference in New Issue
Block a user