mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-05 05:18:52 +08:00
2b720fd2f7
* fix load hang when restart querynode many time in short time Signed-off-by: xige-16 <xi.ge@zilliz.com> * add multi queryNode ut Signed-off-by: xige-16 <xi.ge@zilliz.com> * add ut for restart querynode Signed-off-by: xige-16 <xi.ge@zilliz.com> * set queryCoord contex to load collection Signed-off-by: xige-16 <xi.ge@zilliz.com>
250 lines
5.2 KiB
Go
250 lines
5.2 KiB
Go
// Copyright (C) 2019-2020 Zilliz. All rights reserved.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
|
|
// with the License. You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software distributed under the License
|
|
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
|
// or implied. See the License for the specific language governing permissions and limitations under the License.
|
|
|
|
package querycoord
|
|
|
|
import (
|
|
"fmt"
|
|
"path"
|
|
"strconv"
|
|
"strings"
|
|
"sync"
|
|
|
|
"github.com/milvus-io/milvus/internal/log"
|
|
"github.com/milvus-io/milvus/internal/util/paramtable"
|
|
"github.com/milvus-io/milvus/internal/util/typeutil"
|
|
)
|
|
|
|
type UniqueID = typeutil.UniqueID
|
|
|
|
type ParamTable struct {
|
|
paramtable.BaseTable
|
|
|
|
NodeID uint64
|
|
|
|
Address string
|
|
Port int
|
|
QueryCoordID UniqueID
|
|
|
|
// stats
|
|
StatsChannelName string
|
|
|
|
// timetick
|
|
TimeTickChannelName string
|
|
|
|
Log log.Config
|
|
RoleName string
|
|
|
|
// search
|
|
SearchChannelPrefix string
|
|
SearchResultChannelPrefix string
|
|
|
|
// --- ETCD ---
|
|
EtcdEndpoints []string
|
|
MetaRootPath string
|
|
KvRootPath string
|
|
|
|
//--- Minio ---
|
|
MinioEndPoint string
|
|
MinioAccessKeyID string
|
|
MinioSecretAccessKey string
|
|
MinioUseSSLStr bool
|
|
MinioBucketName string
|
|
}
|
|
|
|
var Params ParamTable
|
|
var once sync.Once
|
|
|
|
func (p *ParamTable) Init() {
|
|
once.Do(func() {
|
|
p.BaseTable.Init()
|
|
err := p.LoadYaml("advanced/query_node.yaml")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
err = p.LoadYaml("milvus.yaml")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
p.initLogCfg()
|
|
|
|
p.initStatsChannelName()
|
|
p.initTimeTickChannelName()
|
|
p.initQueryCoordAddress()
|
|
p.initRoleName()
|
|
p.initSearchChannelPrefix()
|
|
p.initSearchResultChannelPrefix()
|
|
|
|
// --- ETCD ---
|
|
p.initEtcdEndpoints()
|
|
p.initMetaRootPath()
|
|
p.initKvRootPath()
|
|
|
|
//--- Minio ----
|
|
p.initMinioEndPoint()
|
|
p.initMinioAccessKeyID()
|
|
p.initMinioSecretAccessKey()
|
|
p.initMinioUseSSLStr()
|
|
p.initMinioBucketName()
|
|
})
|
|
}
|
|
|
|
func (p *ParamTable) initLogCfg() {
|
|
p.Log = log.Config{}
|
|
format, err := p.Load("log.format")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
p.Log.Format = format
|
|
level, err := p.Load("log.level")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
p.Log.Level = level
|
|
p.Log.File.MaxSize = p.ParseInt("log.file.maxSize")
|
|
p.Log.File.MaxBackups = p.ParseInt("log.file.maxBackups")
|
|
p.Log.File.MaxDays = p.ParseInt("log.file.maxAge")
|
|
rootPath, err := p.Load("log.file.rootPath")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
if len(rootPath) != 0 {
|
|
p.Log.File.Filename = path.Join(rootPath, fmt.Sprintf("queryCoord-%d.log", p.NodeID))
|
|
} else {
|
|
p.Log.File.Filename = ""
|
|
}
|
|
}
|
|
|
|
func (p *ParamTable) initStatsChannelName() {
|
|
channels, err := p.Load("msgChannel.chanNamePrefix.queryNodeStats")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
p.StatsChannelName = channels
|
|
}
|
|
|
|
func (p *ParamTable) initTimeTickChannelName() {
|
|
timeTickChannelName, err := p.Load("msgChannel.chanNamePrefix.queryTimeTick")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
p.TimeTickChannelName = timeTickChannelName
|
|
|
|
}
|
|
|
|
func (p *ParamTable) initQueryCoordAddress() {
|
|
url, err := p.Load("_QueryCoordAddress")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
p.Address = url
|
|
}
|
|
|
|
func (p *ParamTable) initRoleName() {
|
|
p.RoleName = fmt.Sprintf("%s-%d", "QueryCoord", p.NodeID)
|
|
}
|
|
|
|
func (p *ParamTable) initSearchChannelPrefix() {
|
|
channelName, err := p.Load("msgChannel.chanNamePrefix.search")
|
|
if err != nil {
|
|
log.Error(err.Error())
|
|
}
|
|
|
|
p.SearchChannelPrefix = channelName
|
|
}
|
|
|
|
func (p *ParamTable) initSearchResultChannelPrefix() {
|
|
channelName, err := p.Load("msgChannel.chanNamePrefix.searchResult")
|
|
if err != nil {
|
|
log.Error(err.Error())
|
|
}
|
|
|
|
p.SearchResultChannelPrefix = channelName
|
|
}
|
|
|
|
func (p *ParamTable) initEtcdEndpoints() {
|
|
endpoints, err := p.Load("_EtcdEndpoints")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
p.EtcdEndpoints = strings.Split(endpoints, ",")
|
|
}
|
|
|
|
func (p *ParamTable) initMetaRootPath() {
|
|
rootPath, err := p.Load("etcd.rootPath")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
subPath, err := p.Load("etcd.metaSubPath")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
p.MetaRootPath = path.Join(rootPath, subPath)
|
|
}
|
|
|
|
func (p *ParamTable) initKvRootPath() {
|
|
rootPath, err := p.Load("etcd.rootPath")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
subPath, err := p.Load("etcd.kvSubPath")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
p.KvRootPath = path.Join(rootPath, subPath)
|
|
}
|
|
|
|
func (p *ParamTable) initMinioEndPoint() {
|
|
url, err := p.Load("_MinioAddress")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
p.MinioEndPoint = url
|
|
}
|
|
|
|
func (p *ParamTable) initMinioAccessKeyID() {
|
|
id, err := p.Load("minio.accessKeyID")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
p.MinioAccessKeyID = id
|
|
}
|
|
|
|
func (p *ParamTable) initMinioSecretAccessKey() {
|
|
key, err := p.Load("minio.secretAccessKey")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
p.MinioSecretAccessKey = key
|
|
}
|
|
|
|
func (p *ParamTable) initMinioUseSSLStr() {
|
|
ssl, err := p.Load("minio.useSSL")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
sslBoolean, err := strconv.ParseBool(ssl)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
p.MinioUseSSLStr = sslBoolean
|
|
}
|
|
|
|
func (p *ParamTable) initMinioBucketName() {
|
|
bucketName, err := p.Load("minio.bucketName")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
p.MinioBucketName = bucketName
|
|
}
|