2021-01-15 17:09:41 +08:00
|
|
|
package dataservice
|
|
|
|
|
|
|
|
import (
|
2021-01-26 09:43:41 +08:00
|
|
|
"strconv"
|
|
|
|
|
2021-01-15 17:09:41 +08:00
|
|
|
"github.com/zilliztech/milvus-distributed/internal/util/paramtable"
|
|
|
|
)
|
|
|
|
|
|
|
|
type ParamTable struct {
|
|
|
|
paramtable.BaseTable
|
|
|
|
|
|
|
|
Address string
|
|
|
|
Port int
|
2021-01-22 19:43:27 +08:00
|
|
|
NodeID int64
|
|
|
|
|
2021-01-22 11:07:07 +08:00
|
|
|
EtcdAddress string
|
|
|
|
MetaRootPath string
|
|
|
|
KvRootPath string
|
|
|
|
PulsarAddress string
|
2021-01-15 17:09:41 +08:00
|
|
|
|
|
|
|
// segment
|
|
|
|
SegmentSize float64
|
|
|
|
SegmentSizeFactor float64
|
|
|
|
DefaultRecordSize int64
|
|
|
|
SegIDAssignExpiration int64
|
|
|
|
|
2021-01-22 11:07:07 +08:00
|
|
|
InsertChannelPrefixName string
|
|
|
|
InsertChannelNumPerCollection int64
|
|
|
|
StatisticsChannelName string
|
|
|
|
TimeTickChannelName string
|
2021-01-22 19:43:27 +08:00
|
|
|
DataNodeNum int
|
2021-01-25 15:17:17 +08:00
|
|
|
SegmentInfoChannelName string
|
|
|
|
DataServiceSubscriptionName string
|
2021-01-26 09:43:41 +08:00
|
|
|
K2SChannelNames []string
|
2021-01-26 15:14:49 +08:00
|
|
|
|
|
|
|
SegmentFlushMetaPath string
|
2021-01-15 17:09:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
var Params ParamTable
|
|
|
|
|
|
|
|
func (p *ParamTable) Init() {
|
|
|
|
// load yaml
|
|
|
|
p.BaseTable.Init()
|
|
|
|
|
2021-01-26 09:43:41 +08:00
|
|
|
if err := p.LoadYaml("advanced/data_service.yaml"); err != nil {
|
2021-01-15 17:09:41 +08:00
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// set members
|
|
|
|
p.initAddress()
|
|
|
|
p.initPort()
|
2021-01-26 09:43:41 +08:00
|
|
|
p.initNodeID()
|
2021-01-15 17:09:41 +08:00
|
|
|
|
|
|
|
p.initEtcdAddress()
|
|
|
|
p.initMetaRootPath()
|
|
|
|
p.initKvRootPath()
|
|
|
|
p.initPulsarAddress()
|
|
|
|
|
|
|
|
p.initSegmentSize()
|
|
|
|
p.initSegmentSizeFactor()
|
|
|
|
p.initDefaultRecordSize()
|
2021-01-22 19:43:27 +08:00
|
|
|
p.initSegIDAssignExpiration()
|
|
|
|
p.initInsertChannelPrefixName()
|
|
|
|
p.initInsertChannelNumPerCollection()
|
|
|
|
p.initStatisticsChannelName()
|
|
|
|
p.initTimeTickChannelName()
|
|
|
|
p.initDataNodeNum()
|
2021-01-25 15:17:17 +08:00
|
|
|
p.initSegmentInfoChannelName()
|
|
|
|
p.initDataServiceSubscriptionName()
|
2021-01-15 17:09:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (p *ParamTable) initAddress() {
|
2021-01-26 09:43:41 +08:00
|
|
|
dataserviceAddress, err := p.Load("dataservice.address")
|
2021-01-15 17:09:41 +08:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2021-01-26 09:43:41 +08:00
|
|
|
p.Address = dataserviceAddress
|
2021-01-15 17:09:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (p *ParamTable) initPort() {
|
2021-01-26 09:43:41 +08:00
|
|
|
p.Port = p.ParseInt("dataservice.port")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *ParamTable) initNodeID() {
|
|
|
|
p.NodeID = p.ParseInt64("dataservice.nodeID")
|
2021-01-15 17:09:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (p *ParamTable) initEtcdAddress() {
|
|
|
|
addr, err := p.Load("_EtcdAddress")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
p.EtcdAddress = addr
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *ParamTable) initPulsarAddress() {
|
|
|
|
addr, err := p.Load("_PulsarAddress")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
p.PulsarAddress = addr
|
|
|
|
}
|
|
|
|
|
|
|
|
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) initSegmentSize() {
|
2021-01-26 09:43:41 +08:00
|
|
|
p.SegmentSize = p.ParseFloat("dataservice.segment.size")
|
2021-01-15 17:09:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (p *ParamTable) initSegmentSizeFactor() {
|
2021-01-26 09:43:41 +08:00
|
|
|
p.SegmentSizeFactor = p.ParseFloat("dataservice.segment.sizeFactor")
|
2021-01-15 17:09:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (p *ParamTable) initDefaultRecordSize() {
|
2021-01-26 09:43:41 +08:00
|
|
|
p.DefaultRecordSize = p.ParseInt64("dataservice.segment.defaultSizePerRecord")
|
2021-01-15 17:09:41 +08:00
|
|
|
}
|
2021-01-22 19:43:27 +08:00
|
|
|
|
|
|
|
func (p *ParamTable) initSegIDAssignExpiration() {
|
2021-01-26 09:43:41 +08:00
|
|
|
p.SegIDAssignExpiration = p.ParseInt64("dataservice.segment.IDAssignExpiration") //ms
|
2021-01-22 19:43:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (p *ParamTable) initInsertChannelPrefixName() {
|
2021-01-26 09:43:41 +08:00
|
|
|
var err error
|
|
|
|
p.InsertChannelPrefixName, err = p.Load("msgChannel.chanNamePrefix.dataServiceInsertChannel")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2021-01-22 19:43:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (p *ParamTable) initInsertChannelNumPerCollection() {
|
2021-01-26 09:43:41 +08:00
|
|
|
p.InsertChannelNumPerCollection = p.ParseInt64("dataservice.insertChannelNumPerCollection")
|
2021-01-22 19:43:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (p *ParamTable) initStatisticsChannelName() {
|
2021-01-26 09:43:41 +08:00
|
|
|
var err error
|
|
|
|
p.StatisticsChannelName, err = p.Load("msgChannel.chanNamePrefix.dataServiceStatistic")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2021-01-22 19:43:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (p *ParamTable) initTimeTickChannelName() {
|
2021-01-26 09:43:41 +08:00
|
|
|
var err error
|
|
|
|
p.TimeTickChannelName, err = p.Load("msgChannel.chanNamePrefix.dataServiceTimeTick")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2021-01-22 19:43:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (p *ParamTable) initDataNodeNum() {
|
2021-01-26 09:43:41 +08:00
|
|
|
p.DataNodeNum = p.ParseInt("dataservice.dataNodeNum")
|
2021-01-22 19:43:27 +08:00
|
|
|
}
|
2021-01-25 15:17:17 +08:00
|
|
|
|
|
|
|
func (p *ParamTable) initSegmentInfoChannelName() {
|
2021-01-26 09:43:41 +08:00
|
|
|
var err error
|
|
|
|
p.SegmentInfoChannelName, err = p.Load("msgChannel.chanNamePrefix.dataServiceSegmentInfo")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2021-01-25 15:17:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (p *ParamTable) initDataServiceSubscriptionName() {
|
2021-01-26 09:43:41 +08:00
|
|
|
var err error
|
2021-01-27 10:33:17 +08:00
|
|
|
p.DataServiceSubscriptionName, err = p.Load("msgChannel.chanNamePrefix.dataServiceSubNamePrefix")
|
2021-01-26 09:43:41 +08:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *ParamTable) initK2SChannelNames() {
|
|
|
|
prefix, err := p.Load("msgChannel.chanNamePrefix.k2s")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
prefix += "-"
|
|
|
|
iRangeStr, err := p.Load("msgChannel.channelRange.k2s")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
channelIDs := paramtable.ConvertRangeToIntSlice(iRangeStr, ",")
|
|
|
|
var ret []string
|
|
|
|
for _, ID := range channelIDs {
|
|
|
|
ret = append(ret, prefix+strconv.Itoa(ID))
|
|
|
|
}
|
|
|
|
p.K2SChannelNames = ret
|
2021-01-25 15:17:17 +08:00
|
|
|
}
|
2021-01-26 15:14:49 +08:00
|
|
|
|
|
|
|
func (p *ParamTable) initSegmentFlushMetaPath() {
|
|
|
|
subPath, err := p.Load("etcd.segFlushMetaSubPath")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
p.SegmentFlushMetaPath = subPath
|
|
|
|
}
|