2021-04-19 11:12:56 +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-06-18 21:30:08 +08:00
|
|
|
package rootcoord
|
2021-01-19 14:44:03 +08:00
|
|
|
|
|
|
|
import (
|
2021-02-24 16:25:40 +08:00
|
|
|
"path"
|
2021-06-11 22:04:41 +08:00
|
|
|
"strings"
|
2021-02-06 13:39:15 +08:00
|
|
|
"sync"
|
|
|
|
|
2021-04-22 14:45:57 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/log"
|
|
|
|
"github.com/milvus-io/milvus/internal/util/paramtable"
|
2021-01-19 14:44:03 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
var Params ParamTable
|
2021-02-06 13:39:15 +08:00
|
|
|
var once sync.Once
|
2021-01-19 14:44:03 +08:00
|
|
|
|
|
|
|
type ParamTable struct {
|
|
|
|
paramtable.BaseTable
|
|
|
|
|
2021-05-21 19:28:52 +08:00
|
|
|
Address string
|
|
|
|
Port int
|
|
|
|
|
2021-06-21 18:22:13 +08:00
|
|
|
PulsarAddress string
|
2021-06-25 19:44:11 +08:00
|
|
|
RocksmqPath string
|
2021-06-21 18:22:13 +08:00
|
|
|
EtcdEndpoints []string
|
|
|
|
MetaRootPath string
|
|
|
|
KvRootPath string
|
|
|
|
MsgChannelSubName string
|
|
|
|
TimeTickChannel string
|
|
|
|
StatisticsChannel string
|
|
|
|
DataCoordSegmentChannel string // data service create segment, or data node flush segment
|
2021-01-19 14:44:03 +08:00
|
|
|
|
2021-03-08 15:46:51 +08:00
|
|
|
MaxPartitionNum int64
|
|
|
|
DefaultPartitionName string
|
|
|
|
DefaultIndexName string
|
|
|
|
MinSegmentSizeToEnableIndex int64
|
2021-01-25 18:33:10 +08:00
|
|
|
|
2021-05-20 14:14:14 +08:00
|
|
|
Timeout int
|
|
|
|
TimeTickInterval int
|
2021-02-24 16:25:40 +08:00
|
|
|
|
|
|
|
Log log.Config
|
2021-03-13 11:59:24 +08:00
|
|
|
|
|
|
|
RoleName string
|
2021-01-19 14:44:03 +08:00
|
|
|
}
|
2021-01-23 17:56:57 +08:00
|
|
|
|
|
|
|
func (p *ParamTable) Init() {
|
2021-02-06 13:39:15 +08:00
|
|
|
once.Do(func() {
|
|
|
|
// load yaml
|
|
|
|
p.BaseTable.Init()
|
2021-06-22 19:08:03 +08:00
|
|
|
err := p.LoadYaml("advanced/root_coord.yaml")
|
2021-02-06 13:39:15 +08:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
p.initPulsarAddress()
|
2021-06-25 19:44:11 +08:00
|
|
|
p.initRocksmqPath()
|
2021-06-11 22:04:41 +08:00
|
|
|
p.initEtcdEndpoints()
|
2021-02-06 13:39:15 +08:00
|
|
|
p.initMetaRootPath()
|
|
|
|
p.initKvRootPath()
|
|
|
|
|
|
|
|
p.initMsgChannelSubName()
|
|
|
|
p.initTimeTickChannel()
|
|
|
|
p.initStatisticsChannelName()
|
2021-06-04 16:28:34 +08:00
|
|
|
p.initSegmentInfoChannelName()
|
2021-02-06 13:39:15 +08:00
|
|
|
|
|
|
|
p.initMaxPartitionNum()
|
2021-03-08 15:46:51 +08:00
|
|
|
p.initMinSegmentSizeToEnableIndex()
|
2021-02-06 13:39:15 +08:00
|
|
|
p.initDefaultPartitionName()
|
|
|
|
p.initDefaultIndexName()
|
|
|
|
|
|
|
|
p.initTimeout()
|
2021-05-20 14:14:14 +08:00
|
|
|
p.initTimeTickInterval()
|
2021-02-24 16:25:40 +08:00
|
|
|
|
|
|
|
p.initLogCfg()
|
2021-03-13 11:59:24 +08:00
|
|
|
p.initRoleName()
|
2021-02-06 13:39:15 +08:00
|
|
|
})
|
2021-01-23 17:56:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (p *ParamTable) initPulsarAddress() {
|
|
|
|
addr, err := p.Load("_PulsarAddress")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
p.PulsarAddress = addr
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2021-06-11 22:04:41 +08:00
|
|
|
func (p *ParamTable) initEtcdEndpoints() {
|
|
|
|
endpoints, err := p.Load("_EtcdEndpoints")
|
2021-01-23 17:56:57 +08:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2021-06-11 22:04:41 +08:00
|
|
|
p.EtcdEndpoints = strings.Split(endpoints, ",")
|
2021-01-23 17:56:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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 = 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 = rootPath + "/" + subPath
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *ParamTable) initMsgChannelSubName() {
|
2021-06-23 16:14:08 +08:00
|
|
|
name, err := p.Load("msgChannel.subNamePrefix.rootCoordSubNamePrefix")
|
2021-01-23 17:56:57 +08:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
p.MsgChannelSubName = name
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *ParamTable) initTimeTickChannel() {
|
2021-06-23 16:14:08 +08:00
|
|
|
channel, err := p.Load("msgChannel.chanNamePrefix.rootCoordTimeTick")
|
2021-01-23 17:56:57 +08:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
p.TimeTickChannel = channel
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *ParamTable) initStatisticsChannelName() {
|
2021-06-23 16:14:08 +08:00
|
|
|
channel, err := p.Load("msgChannel.chanNamePrefix.rootCoordStatistics")
|
2021-01-23 17:56:57 +08:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
p.StatisticsChannel = channel
|
|
|
|
}
|
|
|
|
|
2021-06-04 16:28:34 +08:00
|
|
|
func (p *ParamTable) initSegmentInfoChannelName() {
|
2021-06-21 11:40:15 +08:00
|
|
|
channel, err := p.Load("msgChannel.chanNamePrefix.dataCoordSegmentInfo")
|
2021-06-04 16:28:34 +08:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2021-06-21 18:22:13 +08:00
|
|
|
p.DataCoordSegmentChannel = channel
|
2021-06-04 16:28:34 +08:00
|
|
|
}
|
|
|
|
|
2021-01-23 17:56:57 +08:00
|
|
|
func (p *ParamTable) initMaxPartitionNum() {
|
2021-06-23 16:14:08 +08:00
|
|
|
p.MaxPartitionNum = p.ParseInt64("rootcoord.maxPartitionNum")
|
2021-01-23 17:56:57 +08:00
|
|
|
}
|
|
|
|
|
2021-03-08 15:46:51 +08:00
|
|
|
func (p *ParamTable) initMinSegmentSizeToEnableIndex() {
|
2021-06-23 16:14:08 +08:00
|
|
|
p.MinSegmentSizeToEnableIndex = p.ParseInt64("rootcoord.minSegmentSizeToEnableIndex")
|
2021-03-08 15:46:51 +08:00
|
|
|
}
|
|
|
|
|
2021-01-23 17:56:57 +08:00
|
|
|
func (p *ParamTable) initDefaultPartitionName() {
|
|
|
|
name, err := p.Load("common.defaultPartitionName")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
p.DefaultPartitionName = name
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *ParamTable) initDefaultIndexName() {
|
|
|
|
name, err := p.Load("common.defaultIndexName")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
p.DefaultIndexName = name
|
|
|
|
}
|
2021-01-25 18:33:10 +08:00
|
|
|
|
|
|
|
func (p *ParamTable) initTimeout() {
|
2021-06-23 16:14:08 +08:00
|
|
|
p.Timeout = p.ParseInt("rootcoord.timeout")
|
2021-01-25 18:33:10 +08:00
|
|
|
}
|
2021-02-24 16:25:40 +08:00
|
|
|
|
2021-05-20 14:14:14 +08:00
|
|
|
func (p *ParamTable) initTimeTickInterval() {
|
2021-06-23 16:14:08 +08:00
|
|
|
p.TimeTickInterval = p.ParseInt("rootcoord.timeTickInterval")
|
2021-05-20 14:14:14 +08:00
|
|
|
}
|
|
|
|
|
2021-02-24 16:25:40 +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
|
|
|
|
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 {
|
2021-06-23 16:14:08 +08:00
|
|
|
p.Log.File.Filename = path.Join(rootPath, "rootcoord.log")
|
2021-03-08 16:24:55 +08:00
|
|
|
} else {
|
|
|
|
p.Log.File.Filename = ""
|
|
|
|
}
|
2021-02-24 16:25:40 +08:00
|
|
|
}
|
2021-03-13 11:59:24 +08:00
|
|
|
|
|
|
|
func (p *ParamTable) initRoleName() {
|
2021-06-23 15:28:09 +08:00
|
|
|
p.RoleName = "RootCoord"
|
2021-03-13 11:59:24 +08:00
|
|
|
}
|