mirror of https://github.com/milvus-io/milvus.git
Add host & enable_disk to session (#27507)
Signed-off-by: longjiquan <jiquan.long@zilliz.com>pull/27540/head
parent
8d3069b1db
commit
e4f73cc805
|
@ -189,7 +189,7 @@ func (i *IndexNode) CloseSegcore() {
|
|||
}
|
||||
|
||||
func (i *IndexNode) initSession() error {
|
||||
i.session = sessionutil.NewSession(i.loopCtx, Params.EtcdCfg.MetaRootPath.GetValue(), i.etcdCli)
|
||||
i.session = sessionutil.NewSession(i.loopCtx, Params.EtcdCfg.MetaRootPath.GetValue(), i.etcdCli, sessionutil.WithEnableDisk(Params.IndexNodeCfg.EnableDisk.GetAsBool()))
|
||||
if i.session == nil {
|
||||
return errors.New("failed to initialize session")
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import (
|
|||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"strconv"
|
||||
"sync"
|
||||
|
@ -94,6 +95,9 @@ type SessionRaw struct {
|
|||
Version string `json:"Version"`
|
||||
IndexEngineVersion IndexEngineVersion `json:"IndexEngineVersion,omitempty"`
|
||||
LeaseID *clientv3.LeaseID `json:"LeaseID,omitempty"`
|
||||
|
||||
HostName string `json:"HostName,omitempty"`
|
||||
EnableDisk bool `json:"EnableDisk,omitempty"`
|
||||
}
|
||||
|
||||
// Session is a struct to store service's session, including ServerID, ServerName,
|
||||
|
@ -155,6 +159,12 @@ func WithIndexEngineVersion(minimal, current int32) SessionOption {
|
|||
}
|
||||
}
|
||||
|
||||
func WithEnableDisk(enableDisk bool) SessionOption {
|
||||
return func(s *Session) {
|
||||
s.EnableDisk = enableDisk
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Session) apply(opts ...SessionOption) {
|
||||
for _, opt := range opts {
|
||||
opt(s)
|
||||
|
@ -189,11 +199,20 @@ func (s *Session) MarshalJSON() ([]byte, error) {
|
|||
// metaRoot is a path in etcd to save session information.
|
||||
// etcdEndpoints is to init etcdCli when NewSession
|
||||
func NewSession(ctx context.Context, metaRoot string, client *clientv3.Client, opts ...SessionOption) *Session {
|
||||
hostName, hostNameErr := os.Hostname()
|
||||
if hostNameErr != nil {
|
||||
log.Error("get host name fail", zap.Error(hostNameErr))
|
||||
}
|
||||
|
||||
session := &Session{
|
||||
ctx: ctx,
|
||||
metaRoot: metaRoot,
|
||||
Version: common.Version,
|
||||
|
||||
SessionRaw: SessionRaw{
|
||||
HostName: hostName,
|
||||
},
|
||||
|
||||
// options
|
||||
sessionTTL: paramtable.Get().CommonCfg.SessionTTL.GetAsInt64(),
|
||||
sessionRetryTimes: paramtable.Get().CommonCfg.SessionRetryTimes.GetAsInt64(),
|
||||
|
|
Loading…
Reference in New Issue