mirror of https://github.com/milvus-io/milvus.git
parent
f2da1e3269
commit
1d16930a03
|
@ -28,6 +28,7 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
@ -73,6 +74,8 @@ type IndexNode struct {
|
||||||
finishedTasks map[UniqueID]commonpb.IndexState
|
finishedTasks map[UniqueID]commonpb.IndexState
|
||||||
|
|
||||||
closer io.Closer
|
closer io.Closer
|
||||||
|
|
||||||
|
initOnce sync.Once
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewIndexNode(ctx context.Context) (*IndexNode, error) {
|
func NewIndexNode(ctx context.Context) (*IndexNode, error) {
|
||||||
|
@ -114,39 +117,47 @@ func (i *IndexNode) initKnowhere() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *IndexNode) Init() error {
|
func (i *IndexNode) Init() error {
|
||||||
i.UpdateStateCode(internalpb.StateCode_Initializing)
|
var initErr error = nil
|
||||||
log.Debug("IndexNode", zap.Any("State", internalpb.StateCode_Initializing))
|
i.initOnce.Do(func() {
|
||||||
connectEtcdFn := func() error {
|
Params.Init()
|
||||||
etcdKV, err := etcdkv.NewEtcdKV(Params.EtcdEndpoints, Params.MetaRootPath)
|
i.UpdateStateCode(internalpb.StateCode_Initializing)
|
||||||
i.etcdKV = etcdKV
|
log.Debug("IndexNode", zap.Any("State", internalpb.StateCode_Initializing))
|
||||||
return err
|
connectEtcdFn := func() error {
|
||||||
}
|
etcdKV, err := etcdkv.NewEtcdKV(Params.EtcdEndpoints, Params.MetaRootPath)
|
||||||
err := retry.Do(i.loopCtx, connectEtcdFn, retry.Attempts(300))
|
i.etcdKV = etcdKV
|
||||||
if err != nil {
|
return err
|
||||||
log.Debug("IndexNode try connect etcd failed", zap.Error(err))
|
}
|
||||||
return err
|
err := retry.Do(i.loopCtx, connectEtcdFn, retry.Attempts(300))
|
||||||
}
|
if err != nil {
|
||||||
log.Debug("IndexNode try connect etcd success")
|
log.Debug("IndexNode try connect etcd failed", zap.Error(err))
|
||||||
|
initErr = err
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log.Debug("IndexNode try connect etcd success")
|
||||||
|
|
||||||
option := &miniokv.Option{
|
option := &miniokv.Option{
|
||||||
Address: Params.MinIOAddress,
|
Address: Params.MinIOAddress,
|
||||||
AccessKeyID: Params.MinIOAccessKeyID,
|
AccessKeyID: Params.MinIOAccessKeyID,
|
||||||
SecretAccessKeyID: Params.MinIOSecretAccessKey,
|
SecretAccessKeyID: Params.MinIOSecretAccessKey,
|
||||||
UseSSL: Params.MinIOUseSSL,
|
UseSSL: Params.MinIOUseSSL,
|
||||||
BucketName: Params.MinioBucketName,
|
BucketName: Params.MinioBucketName,
|
||||||
CreateBucket: true,
|
CreateBucket: true,
|
||||||
}
|
}
|
||||||
i.kv, err = miniokv.NewMinIOKV(i.loopCtx, option)
|
i.kv, err = miniokv.NewMinIOKV(i.loopCtx, option)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Debug("IndexNode NewMinIOKV failed", zap.Error(err))
|
log.Debug("IndexNode NewMinIOKV failed", zap.Error(err))
|
||||||
return err
|
initErr = err
|
||||||
}
|
return
|
||||||
log.Debug("IndexNode NewMinIOKV success")
|
}
|
||||||
i.closer = trace.InitTracing("index_node")
|
log.Debug("IndexNode NewMinIOKV success")
|
||||||
|
i.closer = trace.InitTracing("index_node")
|
||||||
|
|
||||||
i.initKnowhere()
|
i.initKnowhere()
|
||||||
|
})
|
||||||
|
|
||||||
return nil
|
log.Debug("Init IndexNode finished", zap.Error(initErr))
|
||||||
|
|
||||||
|
return initErr
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *IndexNode) Start() error {
|
func (i *IndexNode) Start() error {
|
||||||
|
|
Loading…
Reference in New Issue