2021-04-19 13:47:10 +08:00
|
|
|
// 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.
|
|
|
|
|
2021-01-16 10:12:14 +08:00
|
|
|
package querynode
|
2020-11-26 16:01:31 +08:00
|
|
|
|
|
|
|
import (
|
|
|
|
"strconv"
|
2021-06-11 22:04:41 +08:00
|
|
|
"strings"
|
2021-02-06 13:39:15 +08:00
|
|
|
"sync"
|
2020-11-26 16:01:31 +08:00
|
|
|
|
2021-04-22 14:45:57 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/log"
|
|
|
|
"github.com/milvus-io/milvus/internal/util/paramtable"
|
2020-11-26 16:01:31 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
type ParamTable struct {
|
|
|
|
paramtable.BaseTable
|
2020-12-10 16:31:09 +08:00
|
|
|
|
2021-04-13 10:04:39 +08:00
|
|
|
PulsarAddress string
|
2021-06-25 19:44:11 +08:00
|
|
|
RocksmqPath string
|
2021-06-11 22:04:41 +08:00
|
|
|
EtcdEndpoints []string
|
2021-04-13 10:04:39 +08:00
|
|
|
MetaRootPath string
|
2020-12-10 16:31:09 +08:00
|
|
|
|
2021-09-23 10:53:53 +08:00
|
|
|
Alias string
|
|
|
|
QueryNodeIP string
|
|
|
|
QueryNodePort int64
|
|
|
|
QueryNodeID UniqueID
|
|
|
|
|
|
|
|
// channel prefix
|
|
|
|
ClusterChannelPrefix string
|
2021-04-23 10:07:45 +08:00
|
|
|
QueryTimeTickChannelName string
|
2021-09-23 10:53:53 +08:00
|
|
|
StatsChannelName string
|
|
|
|
MsgChannelSubName string
|
2020-12-10 16:31:09 +08:00
|
|
|
|
|
|
|
FlowGraphMaxQueueLength int32
|
|
|
|
FlowGraphMaxParallelism int32
|
|
|
|
|
2020-12-24 20:55:40 +08:00
|
|
|
// minio
|
|
|
|
MinioEndPoint string
|
|
|
|
MinioAccessKeyID string
|
|
|
|
MinioSecretAccessKey string
|
|
|
|
MinioUseSSLStr bool
|
2021-01-05 15:58:13 +08:00
|
|
|
MinioBucketName string
|
2020-12-24 20:55:40 +08:00
|
|
|
|
2020-12-10 16:31:09 +08:00
|
|
|
// search
|
2021-04-24 10:44:28 +08:00
|
|
|
SearchChannelNames []string
|
|
|
|
SearchResultChannelNames []string
|
2020-12-10 16:31:09 +08:00
|
|
|
SearchReceiveBufSize int64
|
|
|
|
SearchPulsarBufSize int64
|
|
|
|
SearchResultReceiveBufSize int64
|
|
|
|
|
2021-05-29 11:16:29 +08:00
|
|
|
// Retrieve
|
|
|
|
RetrieveChannelNames []string
|
|
|
|
RetrieveResultChannelNames []string
|
|
|
|
RetrieveReceiveBufSize int64
|
2021-09-23 10:53:53 +08:00
|
|
|
RetrievePulsarBufSize int64
|
2021-05-29 11:16:29 +08:00
|
|
|
RetrieveResultReceiveBufSize int64
|
|
|
|
|
2020-12-10 16:31:09 +08:00
|
|
|
// stats
|
|
|
|
StatsPublishInterval int
|
|
|
|
|
2021-09-23 10:53:53 +08:00
|
|
|
GracefulTime int64
|
|
|
|
SliceIndex int
|
2021-03-05 09:21:35 +08:00
|
|
|
|
2021-09-15 10:35:52 +08:00
|
|
|
// segcore
|
2021-09-15 15:15:52 +08:00
|
|
|
ChunkRows int64
|
2021-09-15 12:57:48 +08:00
|
|
|
SimdType string
|
2020-11-26 16:01:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
var Params ParamTable
|
2021-02-06 13:39:15 +08:00
|
|
|
var once sync.Once
|
2020-11-26 16:01:31 +08:00
|
|
|
|
2021-06-19 12:38:06 +08:00
|
|
|
func (p *ParamTable) InitAlias(alias string) {
|
|
|
|
p.Alias = alias
|
|
|
|
}
|
|
|
|
|
2021-09-23 10:53:53 +08:00
|
|
|
func (p *ParamTable) InitOnce() {
|
2021-02-06 13:39:15 +08:00
|
|
|
once.Do(func() {
|
2021-09-23 10:53:53 +08:00
|
|
|
p.Init()
|
|
|
|
})
|
|
|
|
}
|
2020-11-26 16:01:31 +08:00
|
|
|
|
2021-09-23 10:53:53 +08:00
|
|
|
func (p *ParamTable) Init() {
|
|
|
|
p.BaseTable.Init()
|
|
|
|
if err := p.LoadYaml("advanced/query_node.yaml"); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
if err := p.LoadYaml("advanced/knowhere.yaml"); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2021-02-06 13:39:15 +08:00
|
|
|
|
2021-09-23 10:53:53 +08:00
|
|
|
p.initMinioEndPoint()
|
|
|
|
p.initMinioAccessKeyID()
|
|
|
|
p.initMinioSecretAccessKey()
|
|
|
|
p.initMinioUseSSLStr()
|
|
|
|
p.initMinioBucketName()
|
2021-02-06 13:39:15 +08:00
|
|
|
|
2021-09-23 10:53:53 +08:00
|
|
|
p.initPulsarAddress()
|
|
|
|
p.initRocksmqPath()
|
|
|
|
p.initEtcdEndpoints()
|
|
|
|
p.initMetaRootPath()
|
2021-02-06 13:39:15 +08:00
|
|
|
|
2021-09-23 10:53:53 +08:00
|
|
|
p.initGracefulTime()
|
2021-02-06 13:39:15 +08:00
|
|
|
|
2021-09-23 10:53:53 +08:00
|
|
|
p.initFlowGraphMaxQueueLength()
|
|
|
|
p.initFlowGraphMaxParallelism()
|
2021-02-06 13:39:15 +08:00
|
|
|
|
2021-09-23 10:53:53 +08:00
|
|
|
p.initSearchReceiveBufSize()
|
|
|
|
p.initSearchPulsarBufSize()
|
|
|
|
p.initSearchResultReceiveBufSize()
|
2021-02-06 13:39:15 +08:00
|
|
|
|
2021-09-23 10:53:53 +08:00
|
|
|
// Has to init global msgchannel prefix before other channel names
|
|
|
|
p.initClusterMsgChannelPrefix()
|
|
|
|
p.initQueryTimeTickChannelName()
|
|
|
|
p.initStatsChannelName()
|
|
|
|
p.initMsgChannelSubName()
|
2021-03-05 09:21:35 +08:00
|
|
|
|
2021-09-23 10:53:53 +08:00
|
|
|
p.initStatsPublishInterval()
|
2021-09-15 10:35:52 +08:00
|
|
|
|
2021-09-23 10:53:53 +08:00
|
|
|
p.initSegcoreChunkRows()
|
|
|
|
p.initKnowhereSimdType()
|
2021-09-27 17:37:57 +08:00
|
|
|
|
|
|
|
p.initLogCfg()
|
2021-01-21 15:20:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------- minio
|
2020-12-24 20:55:40 +08:00
|
|
|
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
|
2020-12-04 14:18:17 +08:00
|
|
|
}
|
|
|
|
|
2021-01-05 15:58:13 +08:00
|
|
|
func (p *ParamTable) initMinioBucketName() {
|
|
|
|
bucketName, err := p.Load("minio.bucketName")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
p.MinioBucketName = bucketName
|
|
|
|
}
|
|
|
|
|
2020-12-10 16:31:09 +08:00
|
|
|
func (p *ParamTable) initPulsarAddress() {
|
2020-12-07 15:22:20 +08:00
|
|
|
url, err := p.Load("_PulsarAddress")
|
2020-11-26 16:01:31 +08:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2020-12-10 16:31:09 +08:00
|
|
|
p.PulsarAddress = url
|
2020-12-05 16:12:45 +08:00
|
|
|
}
|
|
|
|
|
2021-06-25 19:44:11 +08:00
|
|
|
func (p *ParamTable) initRocksmqPath() {
|
|
|
|
path, err := p.Load("_RocksmqPath")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
p.RocksmqPath = path
|
|
|
|
}
|
|
|
|
|
2020-11-26 16:01:31 +08:00
|
|
|
// advanced params
|
|
|
|
// stats
|
2020-12-10 16:31:09 +08:00
|
|
|
func (p *ParamTable) initStatsPublishInterval() {
|
|
|
|
p.StatsPublishInterval = p.ParseInt("queryNode.stats.publishInterval")
|
2020-11-26 16:01:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// dataSync:
|
2020-12-10 16:31:09 +08:00
|
|
|
func (p *ParamTable) initFlowGraphMaxQueueLength() {
|
|
|
|
p.FlowGraphMaxQueueLength = p.ParseInt32("queryNode.dataSync.flowGraph.maxQueueLength")
|
2020-11-26 16:01:31 +08:00
|
|
|
}
|
|
|
|
|
2020-12-10 16:31:09 +08:00
|
|
|
func (p *ParamTable) initFlowGraphMaxParallelism() {
|
|
|
|
p.FlowGraphMaxParallelism = p.ParseInt32("queryNode.dataSync.flowGraph.maxParallelism")
|
2020-11-26 16:01:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// msgStream
|
2020-12-10 16:31:09 +08:00
|
|
|
func (p *ParamTable) initSearchReceiveBufSize() {
|
|
|
|
p.SearchReceiveBufSize = p.ParseInt64("queryNode.msgStream.search.recvBufSize")
|
2020-11-26 16:01:31 +08:00
|
|
|
}
|
|
|
|
|
2020-12-10 16:31:09 +08:00
|
|
|
func (p *ParamTable) initSearchPulsarBufSize() {
|
|
|
|
p.SearchPulsarBufSize = p.ParseInt64("queryNode.msgStream.search.pulsarBufSize")
|
2020-11-26 16:01:31 +08:00
|
|
|
}
|
|
|
|
|
2020-12-10 16:31:09 +08:00
|
|
|
func (p *ParamTable) initSearchResultReceiveBufSize() {
|
|
|
|
p.SearchResultReceiveBufSize = p.ParseInt64("queryNode.msgStream.searchResult.recvBufSize")
|
2020-11-26 16:01:31 +08:00
|
|
|
}
|
|
|
|
|
2021-09-23 10:53:53 +08:00
|
|
|
// ------------------------ channel names
|
|
|
|
func (p *ParamTable) initClusterMsgChannelPrefix() {
|
|
|
|
name, err := p.Load("msgChannel.chanNamePrefix.cluster")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
p.ClusterChannelPrefix = name
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *ParamTable) initQueryTimeTickChannelName() {
|
|
|
|
config, err := p.Load("msgChannel.chanNamePrefix.queryTimeTick")
|
|
|
|
if err != nil {
|
|
|
|
log.Warn(err.Error())
|
|
|
|
}
|
|
|
|
s := []string{p.ClusterChannelPrefix, config}
|
|
|
|
p.QueryTimeTickChannelName = strings.Join(s, "-")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *ParamTable) initMsgChannelSubName() {
|
|
|
|
namePrefix, err := p.Load("msgChannel.subNamePrefix.queryNodeSubNamePrefix")
|
|
|
|
if err != nil {
|
|
|
|
log.Warn(err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
s := []string{p.ClusterChannelPrefix, namePrefix, strconv.FormatInt(p.QueryNodeID, 10)}
|
|
|
|
p.MsgChannelSubName = strings.Join(s, "-")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *ParamTable) initStatsChannelName() {
|
|
|
|
config, err := p.Load("msgChannel.chanNamePrefix.queryNodeStats")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
s := []string{p.ClusterChannelPrefix, config}
|
|
|
|
p.StatsChannelName = strings.Join(s, "-")
|
|
|
|
}
|
|
|
|
|
|
|
|
// ETCD configs
|
2021-06-11 22:04:41 +08:00
|
|
|
func (p *ParamTable) initEtcdEndpoints() {
|
|
|
|
endpoints, err := p.Load("_EtcdEndpoints")
|
2020-11-26 16:01:31 +08:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2021-06-11 22:04:41 +08:00
|
|
|
p.EtcdEndpoints = strings.Split(endpoints, ",")
|
2020-11-26 16:01:31 +08:00
|
|
|
}
|
|
|
|
|
2020-12-10 16:31:09 +08:00
|
|
|
func (p *ParamTable) initMetaRootPath() {
|
2020-11-28 19:06:48 +08:00
|
|
|
rootPath, err := p.Load("etcd.rootPath")
|
2020-11-26 16:01:31 +08:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2020-11-28 19:06:48 +08:00
|
|
|
subPath, err := p.Load("etcd.metaSubPath")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2020-12-10 16:31:09 +08:00
|
|
|
p.MetaRootPath = rootPath + "/" + subPath
|
2020-11-26 16:01:31 +08:00
|
|
|
}
|
|
|
|
|
2020-12-10 16:31:09 +08:00
|
|
|
func (p *ParamTable) initGracefulTime() {
|
|
|
|
p.GracefulTime = p.ParseInt64("queryNode.gracefulTime")
|
2020-11-26 16:01:31 +08:00
|
|
|
}
|
|
|
|
|
2021-09-15 15:15:52 +08:00
|
|
|
func (p *ParamTable) initSegcoreChunkRows() {
|
|
|
|
p.ChunkRows = p.ParseInt64("queryNode.segcore.chunkRows")
|
2021-09-15 10:35:52 +08:00
|
|
|
}
|
|
|
|
|
2021-09-18 10:37:51 +08:00
|
|
|
func (p *ParamTable) initKnowhereSimdType() {
|
|
|
|
simdType, err := p.LoadWithDefault("knowhere.simdType", "auto")
|
2021-09-15 12:57:48 +08:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
p.SimdType = simdType
|
|
|
|
}
|
|
|
|
|
2021-03-05 09:21:35 +08:00
|
|
|
func (p *ParamTable) initLogCfg() {
|
2021-09-26 21:18:11 +08:00
|
|
|
p.InitLogCfg("querynode", p.QueryNodeID)
|
2021-03-05 09:21:35 +08:00
|
|
|
}
|