2021-10-25 19:48:23 +08:00
|
|
|
// Licensed to the LF AI & Data foundation under one
|
|
|
|
// or more contributor license agreements. See the NOTICE file
|
|
|
|
// distributed with this work for additional information
|
|
|
|
// regarding copyright ownership. The ASF licenses this file
|
|
|
|
// to you under the Apache License, Version 2.0 (the
|
|
|
|
// "License"); you may not use this file except in compliance
|
2021-04-19 11:35:38 +08:00
|
|
|
// with the License. You may obtain a copy of the License at
|
|
|
|
//
|
2021-10-25 19:48:23 +08:00
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
2021-04-19 11:35:38 +08:00
|
|
|
//
|
2021-10-25 19:48:23 +08:00
|
|
|
// 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-09-22 20:12:08 +08:00
|
|
|
|
2021-06-22 10:42:07 +08:00
|
|
|
package datacoord
|
2021-01-15 17:09:41 +08:00
|
|
|
|
|
|
|
import (
|
2021-06-11 22:04:41 +08:00
|
|
|
"strings"
|
2021-02-06 13:39:15 +08:00
|
|
|
"sync"
|
2021-09-26 17:50:07 +08:00
|
|
|
"time"
|
2021-01-26 09:43:41 +08:00
|
|
|
|
2021-04-22 14:45:57 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/util/paramtable"
|
2021-01-15 17:09:41 +08:00
|
|
|
)
|
|
|
|
|
2021-10-04 13:20:51 +08:00
|
|
|
// ParamTable is a derived struct of paramtable.BaseTable. It achieves Composition by
|
|
|
|
// embedding paramtable.BaseTable. It is used to quickly and easily access the system configuration.
|
2021-01-15 17:09:41 +08:00
|
|
|
type ParamTable struct {
|
|
|
|
paramtable.BaseTable
|
|
|
|
|
2021-02-23 11:40:30 +08:00
|
|
|
NodeID int64
|
2021-01-22 19:43:27 +08:00
|
|
|
|
2021-05-21 19:28:52 +08:00
|
|
|
IP string
|
|
|
|
Port int
|
|
|
|
|
2021-05-20 11:34:45 +08:00
|
|
|
// --- ETCD ---
|
2021-06-11 22:04:41 +08:00
|
|
|
EtcdEndpoints []string
|
2021-05-20 11:34:45 +08:00
|
|
|
MetaRootPath string
|
|
|
|
KvRootPath string
|
|
|
|
SegmentBinlogSubPath string
|
|
|
|
CollectionBinlogSubPath string
|
2021-10-14 15:44:34 +08:00
|
|
|
ChannelWatchSubPath string
|
2021-05-20 11:34:45 +08:00
|
|
|
|
|
|
|
// --- Pulsar ---
|
2021-01-22 11:07:07 +08:00
|
|
|
PulsarAddress string
|
2021-01-15 17:09:41 +08:00
|
|
|
|
2021-06-25 19:44:11 +08:00
|
|
|
// --- Rocksmq ---
|
|
|
|
RocksmqPath string
|
|
|
|
|
2021-05-19 14:13:53 +08:00
|
|
|
FlushStreamPosSubPath string
|
|
|
|
StatsStreamPosSubPath string
|
|
|
|
|
2021-09-23 10:53:53 +08:00
|
|
|
// --- SEGMENTS ---
|
2021-06-22 16:18:21 +08:00
|
|
|
SegmentMaxSize float64
|
|
|
|
SegmentSealProportion float64
|
|
|
|
SegAssignmentExpiration int64
|
2021-01-15 17:09:41 +08:00
|
|
|
|
2021-09-23 10:53:53 +08:00
|
|
|
// --- Channels ---
|
|
|
|
ClusterChannelPrefix string
|
2021-06-21 11:40:15 +08:00
|
|
|
InsertChannelPrefixName string
|
|
|
|
StatisticsChannelName string
|
|
|
|
TimeTickChannelName string
|
|
|
|
SegmentInfoChannelName string
|
|
|
|
DataCoordSubscriptionName string
|
2021-01-26 15:14:49 +08:00
|
|
|
|
2021-09-26 17:50:07 +08:00
|
|
|
CreatedTime time.Time
|
|
|
|
UpdatedTime time.Time
|
2021-11-05 22:25:00 +08:00
|
|
|
|
|
|
|
EnableCompaction bool
|
2021-01-15 17:09:41 +08:00
|
|
|
}
|
|
|
|
|
2021-10-04 13:20:51 +08:00
|
|
|
// Params is a package scoped variable of type ParamTable.
|
2021-01-15 17:09:41 +08:00
|
|
|
var Params ParamTable
|
2021-02-06 13:39:15 +08:00
|
|
|
var once sync.Once
|
2021-01-15 17:09:41 +08:00
|
|
|
|
2021-10-04 13:20:51 +08:00
|
|
|
// Init is an override method of BaseTable's Init. It mainly calls the
|
|
|
|
// Init of BaseTable and do some other initialization.
|
2021-01-15 17:09:41 +08:00
|
|
|
func (p *ParamTable) Init() {
|
2021-09-23 10:53:53 +08:00
|
|
|
// load yaml
|
|
|
|
p.BaseTable.Init()
|
|
|
|
|
|
|
|
if err := p.LoadYaml("advanced/data_coord.yaml"); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// set members
|
|
|
|
p.initEtcdEndpoints()
|
|
|
|
p.initMetaRootPath()
|
|
|
|
p.initKvRootPath()
|
|
|
|
p.initSegmentBinlogSubPath()
|
|
|
|
p.initCollectionBinlogSubPath()
|
2021-10-14 15:44:34 +08:00
|
|
|
p.initChannelWatchPrefix()
|
2021-09-23 10:53:53 +08:00
|
|
|
|
|
|
|
p.initPulsarAddress()
|
|
|
|
p.initRocksmqPath()
|
|
|
|
|
|
|
|
p.initSegmentMaxSize()
|
|
|
|
p.initSegmentSealProportion()
|
|
|
|
p.initSegAssignmentExpiration()
|
|
|
|
|
|
|
|
// Has to init global msgchannel prefix before other channel names
|
|
|
|
p.initClusterMsgChannelPrefix()
|
|
|
|
p.initInsertChannelPrefixName()
|
|
|
|
p.initStatisticsChannelName()
|
|
|
|
p.initTimeTickChannelName()
|
|
|
|
p.initSegmentInfoChannelName()
|
|
|
|
p.initDataCoordSubscriptionName()
|
2021-10-01 08:52:50 +08:00
|
|
|
p.initRoleName()
|
2021-09-23 10:53:53 +08:00
|
|
|
|
|
|
|
p.initFlushStreamPosSubPath()
|
|
|
|
p.initStatsStreamPosSubPath()
|
2021-11-05 22:25:00 +08:00
|
|
|
|
|
|
|
p.initEnableCompaction()
|
2021-09-23 10:53:53 +08:00
|
|
|
}
|
|
|
|
|
2021-10-03 17:38:14 +08:00
|
|
|
// InitOnce ensures param table is a singleton
|
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()
|
2021-02-06 13:39:15 +08:00
|
|
|
})
|
2021-01-15 17:09:41 +08:00
|
|
|
}
|
|
|
|
|
2021-06-11 22:04:41 +08:00
|
|
|
func (p *ParamTable) initEtcdEndpoints() {
|
|
|
|
endpoints, err := p.Load("_EtcdEndpoints")
|
2021-01-15 17:09:41 +08:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2021-06-11 22:04:41 +08:00
|
|
|
p.EtcdEndpoints = strings.Split(endpoints, ",")
|
2021-01-15 17:09:41 +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-01-15 17:09:41 +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
|
|
|
|
}
|
2021-05-20 11:34:45 +08:00
|
|
|
|
|
|
|
func (p *ParamTable) initSegmentBinlogSubPath() {
|
|
|
|
subPath, err := p.Load("etcd.segmentBinlogSubPath")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
p.SegmentBinlogSubPath = subPath
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *ParamTable) initCollectionBinlogSubPath() {
|
|
|
|
subPath, err := p.Load("etcd.collectionBinlogSubPath")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
p.CollectionBinlogSubPath = subPath
|
|
|
|
}
|
|
|
|
|
2021-06-22 16:18:21 +08:00
|
|
|
func (p *ParamTable) initSegmentMaxSize() {
|
2021-10-28 23:16:40 +08:00
|
|
|
p.SegmentMaxSize = p.ParseFloatWithDefault("dataCoord.segment.maxSize", 512.0)
|
2021-01-15 17:09:41 +08:00
|
|
|
}
|
|
|
|
|
2021-06-22 16:18:21 +08:00
|
|
|
func (p *ParamTable) initSegmentSealProportion() {
|
2021-10-28 23:16:40 +08:00
|
|
|
p.SegmentSealProportion = p.ParseFloatWithDefault("dataCoord.segment.sealProportion", 0.75)
|
2021-01-15 17:09:41 +08:00
|
|
|
}
|
|
|
|
|
2021-06-22 16:18:21 +08:00
|
|
|
func (p *ParamTable) initSegAssignmentExpiration() {
|
2021-10-28 23:16:40 +08:00
|
|
|
p.SegAssignmentExpiration = p.ParseInt64WithDefault("dataCoord.segment.assignmentExpiration", 2000)
|
2021-01-22 19:43:27 +08:00
|
|
|
}
|
|
|
|
|
2021-09-23 10:53:53 +08:00
|
|
|
func (p *ParamTable) initClusterMsgChannelPrefix() {
|
|
|
|
config, err := p.Load("msgChannel.chanNamePrefix.cluster")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
p.ClusterChannelPrefix = config
|
|
|
|
}
|
|
|
|
|
2021-01-22 19:43:27 +08:00
|
|
|
func (p *ParamTable) initInsertChannelPrefixName() {
|
2021-09-23 10:53:53 +08:00
|
|
|
config, err := p.Load("msgChannel.chanNamePrefix.dataCoordInsertChannel")
|
2021-01-26 09:43:41 +08:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2021-09-23 10:53:53 +08:00
|
|
|
s := []string{p.ClusterChannelPrefix, config}
|
|
|
|
p.InsertChannelPrefixName = strings.Join(s, "-")
|
2021-01-22 19:43:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (p *ParamTable) initStatisticsChannelName() {
|
2021-09-23 10:53:53 +08:00
|
|
|
config, err := p.Load("msgChannel.chanNamePrefix.dataCoordStatistic")
|
2021-01-26 09:43:41 +08:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2021-09-23 10:53:53 +08:00
|
|
|
s := []string{p.ClusterChannelPrefix, config}
|
|
|
|
p.StatisticsChannelName = strings.Join(s, "-")
|
2021-01-22 19:43:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (p *ParamTable) initTimeTickChannelName() {
|
2021-09-23 10:53:53 +08:00
|
|
|
config, err := p.Load("msgChannel.chanNamePrefix.dataCoordTimeTick")
|
2021-01-26 09:43:41 +08:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2021-09-23 10:53:53 +08:00
|
|
|
s := []string{p.ClusterChannelPrefix, config}
|
|
|
|
p.TimeTickChannelName = strings.Join(s, "-")
|
2021-01-22 19:43:27 +08:00
|
|
|
}
|
|
|
|
|
2021-01-25 15:17:17 +08:00
|
|
|
func (p *ParamTable) initSegmentInfoChannelName() {
|
2021-09-23 10:53:53 +08:00
|
|
|
config, err := p.Load("msgChannel.chanNamePrefix.dataCoordSegmentInfo")
|
2021-01-26 09:43:41 +08:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2021-09-23 10:53:53 +08:00
|
|
|
s := []string{p.ClusterChannelPrefix, config}
|
|
|
|
p.SegmentInfoChannelName = strings.Join(s, "-")
|
2021-01-25 15:17:17 +08:00
|
|
|
}
|
|
|
|
|
2021-06-21 11:40:15 +08:00
|
|
|
func (p *ParamTable) initDataCoordSubscriptionName() {
|
2021-09-23 10:53:53 +08:00
|
|
|
config, err := p.Load("msgChannel.subNamePrefix.dataCoordSubNamePrefix")
|
2021-01-26 09:43:41 +08:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2021-09-23 10:53:53 +08:00
|
|
|
s := []string{p.ClusterChannelPrefix, config}
|
|
|
|
p.DataCoordSubscriptionName = strings.Join(s, "-")
|
2021-01-26 09:43:41 +08:00
|
|
|
}
|
|
|
|
|
2021-10-01 08:52:50 +08:00
|
|
|
func (p *ParamTable) initRoleName() {
|
|
|
|
p.RoleName = "datacoord"
|
2021-02-19 15:37:04 +08:00
|
|
|
}
|
2021-03-27 14:01:52 +08:00
|
|
|
|
2021-05-19 14:13:53 +08:00
|
|
|
func (p *ParamTable) initFlushStreamPosSubPath() {
|
|
|
|
subPath, err := p.Load("etcd.flushStreamPosSubPath")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
p.FlushStreamPosSubPath = subPath
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *ParamTable) initStatsStreamPosSubPath() {
|
|
|
|
subPath, err := p.Load("etcd.statsStreamPosSubPath")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
p.StatsStreamPosSubPath = subPath
|
|
|
|
}
|
2021-10-14 15:44:34 +08:00
|
|
|
|
|
|
|
func (p *ParamTable) initChannelWatchPrefix() {
|
|
|
|
// WARN: this value should not be put to milvus.yaml. It's a default value for channel watch path.
|
|
|
|
// This will be removed after we reconstruct our config module.
|
|
|
|
p.ChannelWatchSubPath = "channelwatch"
|
|
|
|
}
|
2021-11-05 22:25:00 +08:00
|
|
|
|
|
|
|
func (p *ParamTable) initEnableCompaction() {
|
|
|
|
p.EnableCompaction = p.ParseBool("datacoord.enableCompaction", false)
|
|
|
|
}
|