Init rand.Seed

Signed-off-by: sunby <bingyi.sun@zilliz.com>
This commit is contained in:
sunby 2021-03-08 15:25:55 +08:00 committed by yefu.chen
parent 403212c5fa
commit ab21115d54
7 changed files with 13 additions and 3 deletions

View File

@ -4,6 +4,7 @@ import (
"context"
"fmt"
"io"
"math/rand"
"sync/atomic"
"time"
@ -49,7 +50,7 @@ type DataNode struct {
}
func NewDataNode(ctx context.Context, factory msgstream.Factory) *DataNode {
rand.Seed(time.Now().UnixNano())
ctx2, cancel2 := context.WithCancel(ctx)
node := &DataNode{
ctx: ctx2,

View File

@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"math/rand"
"path"
"strconv"
"strings"
@ -63,6 +64,7 @@ type Server struct {
}
func CreateServer(ctx context.Context, factory msgstream.Factory) (*Server, error) {
rand.Seed(time.Now().UnixNano())
ch := make(chan struct{})
s := &Server{
ctx: ctx,

View File

@ -6,6 +6,7 @@ import (
"fmt"
"io"
"log"
"math/rand"
"time"
"github.com/opentracing/opentracing-go"
@ -49,6 +50,7 @@ type IndexNode struct {
}
func NewIndexNode(ctx context.Context) (*IndexNode, error) {
rand.Seed(time.Now().UnixNano())
ctx1, cancel := context.WithCancel(ctx)
b := &IndexNode{
loopCtx: ctx1,

View File

@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"log"
"math/rand"
"sync"
"time"
@ -58,6 +59,7 @@ type UniqueID = typeutil.UniqueID
type Timestamp = typeutil.Timestamp
func NewIndexService(ctx context.Context) (*IndexService, error) {
rand.Seed(time.Now().UnixNano())
ctx1, cancel := context.WithCancel(ctx)
i := &IndexService{
loopCtx: ctx1,

View File

@ -7,7 +7,6 @@ import (
"math/rand"
"strconv"
"sync"
"time"
grpcproxynodeclient "github.com/zilliztech/milvus-distributed/internal/distributed/proxynode/client"
"github.com/zilliztech/milvus-distributed/internal/types"
@ -28,7 +27,6 @@ type GlobalNodeInfoTable struct {
}
func (table *GlobalNodeInfoTable) randomPick() UniqueID {
rand.Seed(time.Now().UnixNano())
l := len(table.nodeIDs)
choice := rand.Intn(l)
return table.nodeIDs[choice]

View File

@ -15,8 +15,10 @@ import "C"
import (
"context"
"fmt"
"math/rand"
"strings"
"sync/atomic"
"time"
"github.com/zilliztech/milvus-distributed/internal/types"
@ -62,6 +64,7 @@ type QueryNode struct {
}
func NewQueryNode(ctx context.Context, queryNodeID UniqueID, factory msgstream.Factory) *QueryNode {
rand.Seed(time.Now().UnixNano())
ctx1, cancel := context.WithCancel(ctx)
node := &QueryNode{
queryNodeLoopCtx: ctx1,

View File

@ -4,6 +4,7 @@ import (
"context"
"fmt"
"io"
"math/rand"
"sort"
"strconv"
"sync"
@ -642,6 +643,7 @@ func (qs *QueryService) GetSegmentInfo(ctx context.Context, req *querypb.Segment
}
func NewQueryService(ctx context.Context, factory msgstream.Factory) (*QueryService, error) {
rand.Seed(time.Now().UnixNano())
nodes := make(map[int64]*queryNodeInfo)
queryChannels := make([]*queryChannelInfo, 0)
ctx1, cancel := context.WithCancel(ctx)