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 (
|
2021-03-05 09:21:35 +08:00
|
|
|
"fmt"
|
2020-12-08 14:41:04 +08:00
|
|
|
"os"
|
2021-03-05 09:21:35 +08:00
|
|
|
"path"
|
2020-11-26 16:01:31 +08:00
|
|
|
"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-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-04-23 10:07:45 +08:00
|
|
|
QueryNodeIP string
|
|
|
|
QueryNodePort int64
|
|
|
|
QueryNodeID UniqueID
|
|
|
|
QueryNodeNum int
|
|
|
|
QueryTimeTickChannelName 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
|
|
|
|
retrievePulsarBufSize int64
|
|
|
|
RetrieveResultReceiveBufSize int64
|
|
|
|
|
2020-12-10 16:31:09 +08:00
|
|
|
// stats
|
|
|
|
StatsPublishInterval int
|
|
|
|
StatsChannelName string
|
|
|
|
|
2021-02-03 18:12:48 +08:00
|
|
|
GracefulTime int64
|
|
|
|
MsgChannelSubName string
|
|
|
|
SliceIndex int
|
2021-03-05 09:21:35 +08:00
|
|
|
|
|
|
|
Log log.Config
|
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
|
|
|
|
|
|
|
func (p *ParamTable) Init() {
|
2021-02-06 13:39:15 +08:00
|
|
|
once.Do(func() {
|
|
|
|
p.BaseTable.Init()
|
|
|
|
err := p.LoadYaml("advanced/query_node.yaml")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2020-11-26 16:01:31 +08:00
|
|
|
|
2021-02-06 13:39:15 +08:00
|
|
|
queryNodeIDStr := os.Getenv("QUERY_NODE_ID")
|
|
|
|
if queryNodeIDStr == "" {
|
|
|
|
queryNodeIDList := p.QueryNodeIDList()
|
|
|
|
if len(queryNodeIDList) <= 0 {
|
|
|
|
queryNodeIDStr = "0"
|
|
|
|
} else {
|
|
|
|
queryNodeIDStr = strconv.Itoa(int(queryNodeIDList[0]))
|
|
|
|
}
|
2020-12-08 14:41:04 +08:00
|
|
|
}
|
2020-12-10 16:31:09 +08:00
|
|
|
|
2021-02-06 13:39:15 +08:00
|
|
|
err = p.Save("_queryNodeID", queryNodeIDStr)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2020-12-10 16:31:09 +08:00
|
|
|
|
2021-02-06 13:39:15 +08:00
|
|
|
p.initQueryNodeID()
|
|
|
|
p.initQueryNodeNum()
|
2021-02-18 16:26:02 +08:00
|
|
|
//p.initQueryTimeTickChannelName()
|
2021-02-06 13:39:15 +08:00
|
|
|
|
|
|
|
p.initMinioEndPoint()
|
|
|
|
p.initMinioAccessKeyID()
|
|
|
|
p.initMinioSecretAccessKey()
|
|
|
|
p.initMinioUseSSLStr()
|
|
|
|
p.initMinioBucketName()
|
|
|
|
|
|
|
|
p.initPulsarAddress()
|
2021-06-11 22:04:41 +08:00
|
|
|
p.initEtcdEndpoints()
|
2021-02-06 13:39:15 +08:00
|
|
|
p.initMetaRootPath()
|
|
|
|
|
|
|
|
p.initGracefulTime()
|
|
|
|
p.initMsgChannelSubName()
|
|
|
|
p.initSliceIndex()
|
|
|
|
|
|
|
|
p.initFlowGraphMaxQueueLength()
|
|
|
|
p.initFlowGraphMaxParallelism()
|
|
|
|
|
|
|
|
p.initSearchReceiveBufSize()
|
|
|
|
p.initSearchPulsarBufSize()
|
|
|
|
p.initSearchResultReceiveBufSize()
|
|
|
|
|
|
|
|
p.initStatsPublishInterval()
|
2021-06-15 12:41:40 +08:00
|
|
|
p.initStatsChannelName()
|
2021-03-05 09:21:35 +08:00
|
|
|
|
|
|
|
p.initLogCfg()
|
2021-02-06 13:39:15 +08:00
|
|
|
})
|
2020-12-24 20:55:40 +08:00
|
|
|
}
|
|
|
|
|
2021-01-21 15:20:23 +08:00
|
|
|
// ---------------------------------------------------------- query node
|
|
|
|
func (p *ParamTable) initQueryNodeID() {
|
|
|
|
queryNodeID, err := p.Load("_queryNodeID")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
id, err := strconv.Atoi(queryNodeID)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
p.QueryNodeID = UniqueID(id)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *ParamTable) initQueryNodeNum() {
|
|
|
|
p.QueryNodeNum = len(p.QueryNodeIDList())
|
|
|
|
}
|
|
|
|
|
2021-01-21 10:01:29 +08:00
|
|
|
func (p *ParamTable) initQueryTimeTickChannelName() {
|
|
|
|
ch, err := p.Load("msgChannel.chanNamePrefix.queryTimeTick")
|
2021-01-21 15:20:23 +08:00
|
|
|
if err != nil {
|
2021-03-05 09:21:35 +08:00
|
|
|
log.Error(err.Error())
|
2021-01-21 15:20:23 +08:00
|
|
|
}
|
2021-01-21 10:01:29 +08:00
|
|
|
p.QueryTimeTickChannelName = ch
|
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
|
|
|
}
|
|
|
|
|
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-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
|
|
|
}
|
|
|
|
|
2020-12-10 16:31:09 +08:00
|
|
|
func (p *ParamTable) initMsgChannelSubName() {
|
2020-11-26 16:01:31 +08:00
|
|
|
// TODO: subName = namePrefix + "-" + queryNodeID, queryNodeID is assigned by master
|
|
|
|
name, err := p.Load("msgChannel.subNamePrefix.queryNodeSubNamePrefix")
|
|
|
|
if err != nil {
|
2021-03-05 09:21:35 +08:00
|
|
|
log.Error(err.Error())
|
2020-11-26 16:01:31 +08:00
|
|
|
}
|
2020-12-08 14:41:04 +08:00
|
|
|
queryNodeIDStr, err := p.Load("_QueryNodeID")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2020-12-10 16:31:09 +08:00
|
|
|
p.MsgChannelSubName = name + "-" + queryNodeIDStr
|
2020-11-26 16:01:31 +08:00
|
|
|
}
|
|
|
|
|
2020-12-10 16:31:09 +08:00
|
|
|
func (p *ParamTable) initStatsChannelName() {
|
2020-11-26 16:01:31 +08:00
|
|
|
channels, err := p.Load("msgChannel.chanNamePrefix.queryNodeStats")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2020-12-10 16:31:09 +08:00
|
|
|
p.StatsChannelName = channels
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *ParamTable) initSliceIndex() {
|
|
|
|
queryNodeID := p.QueryNodeID
|
2020-12-08 14:41:04 +08:00
|
|
|
queryNodeIDList := p.QueryNodeIDList()
|
|
|
|
for i := 0; i < len(queryNodeIDList); i++ {
|
|
|
|
if queryNodeID == queryNodeIDList[i] {
|
2020-12-10 16:31:09 +08:00
|
|
|
p.SliceIndex = i
|
|
|
|
return
|
2020-12-08 14:41:04 +08:00
|
|
|
}
|
|
|
|
}
|
2020-12-10 16:31:09 +08:00
|
|
|
p.SliceIndex = -1
|
2020-12-08 14:41:04 +08:00
|
|
|
}
|
2021-03-05 09:21:35 +08:00
|
|
|
|
|
|
|
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
|
|
|
|
devStr, err := p.Load("log.dev")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
dev, err := strconv.ParseBool(devStr)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
p.Log.Development = dev
|
|
|
|
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)
|
|
|
|
}
|
2021-03-08 16:24:55 +08:00
|
|
|
if len(rootPath) != 0 {
|
|
|
|
p.Log.File.Filename = path.Join(rootPath, fmt.Sprintf("querynode-%d.log", p.QueryNodeID))
|
|
|
|
} else {
|
|
|
|
p.Log.File.Filename = ""
|
|
|
|
}
|
2021-03-05 09:21:35 +08:00
|
|
|
}
|