2021-04-19 07:16:33 +00: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-19 03:37:16 +00:00
|
|
|
package datanode
|
|
|
|
|
|
|
|
import (
|
|
|
|
"path"
|
|
|
|
"strconv"
|
2021-06-11 14:04:41 +00:00
|
|
|
"strings"
|
2021-02-06 05:39:15 +00:00
|
|
|
"sync"
|
2021-09-17 13:32:47 +00:00
|
|
|
"time"
|
2021-01-19 03:37:16 +00:00
|
|
|
|
2021-04-22 06:45:57 +00:00
|
|
|
"github.com/milvus-io/milvus/internal/util/paramtable"
|
2021-01-19 03:37:16 +00:00
|
|
|
)
|
|
|
|
|
2021-09-26 12:57:59 +00:00
|
|
|
// ParamTable in DataNode contains all configs for DataNode
|
2021-01-19 03:37:16 +00:00
|
|
|
type ParamTable struct {
|
|
|
|
paramtable.BaseTable
|
|
|
|
|
|
|
|
// === DataNode Internal Components Configs ===
|
2021-01-24 13:20:11 +00:00
|
|
|
NodeID UniqueID
|
2021-02-23 03:40:30 +00:00
|
|
|
IP string
|
|
|
|
Port int
|
2021-01-19 03:37:16 +00:00
|
|
|
FlowGraphMaxQueueLength int32
|
|
|
|
FlowGraphMaxParallelism int32
|
2021-07-24 01:25:22 +00:00
|
|
|
FlushInsertBufferSize int64
|
2021-01-19 03:37:16 +00:00
|
|
|
InsertBinlogRootPath string
|
2021-05-20 10:38:45 +00:00
|
|
|
StatsBinlogRootPath string
|
2021-06-19 04:38:06 +00:00
|
|
|
Alias string // Different datanode in one machine
|
2021-01-19 03:37:16 +00:00
|
|
|
|
|
|
|
// === DataNode External Components Configs ===
|
|
|
|
// --- Pulsar ---
|
|
|
|
PulsarAddress string
|
|
|
|
|
2021-06-25 11:44:11 +00:00
|
|
|
// --- Rocksmq ---
|
|
|
|
RocksmqPath string
|
|
|
|
|
2021-09-23 02:53:53 +00:00
|
|
|
// --- Cluster channels ---
|
|
|
|
ClusterChannelPrefix string
|
|
|
|
|
2021-01-19 03:37:16 +00:00
|
|
|
// - seg statistics channel -
|
2021-01-26 06:46:54 +00:00
|
|
|
SegmentStatisticsChannelName string
|
2021-01-19 03:37:16 +00:00
|
|
|
|
|
|
|
// - timetick channel -
|
2021-01-26 06:46:54 +00:00
|
|
|
TimeTickChannelName string
|
2021-01-19 03:37:16 +00:00
|
|
|
|
|
|
|
// - channel subname -
|
|
|
|
MsgChannelSubName string
|
|
|
|
|
|
|
|
// --- ETCD ---
|
2021-06-11 14:04:41 +00:00
|
|
|
EtcdEndpoints []string
|
|
|
|
MetaRootPath string
|
2021-01-19 03:37:16 +00:00
|
|
|
|
|
|
|
// --- MinIO ---
|
|
|
|
MinioAddress string
|
|
|
|
MinioAccessKeyID string
|
|
|
|
MinioSecretAccessKey string
|
|
|
|
MinioUseSSL bool
|
|
|
|
MinioBucketName string
|
2021-09-17 13:32:47 +00:00
|
|
|
|
|
|
|
CreatedTime time.Time
|
|
|
|
UpdatedTime time.Time
|
2021-01-19 03:37:16 +00:00
|
|
|
}
|
|
|
|
|
2021-09-26 12:57:59 +00:00
|
|
|
// Params is global var in DataNode
|
2021-01-19 03:37:16 +00:00
|
|
|
var Params ParamTable
|
2021-02-06 05:39:15 +00:00
|
|
|
var once sync.Once
|
2021-01-19 03:37:16 +00:00
|
|
|
|
2021-09-26 12:57:59 +00:00
|
|
|
// InitAlias init this DataNode alias
|
2021-06-19 04:38:06 +00:00
|
|
|
func (p *ParamTable) InitAlias(alias string) {
|
|
|
|
p.Alias = alias
|
|
|
|
}
|
|
|
|
|
2021-09-26 12:57:59 +00:00
|
|
|
// InitOnce call params Init only once
|
2021-09-23 02:53:53 +00:00
|
|
|
func (p *ParamTable) InitOnce() {
|
2021-02-06 05:39:15 +00:00
|
|
|
once.Do(func() {
|
2021-09-23 02:53:53 +00:00
|
|
|
p.Init()
|
2021-02-06 05:39:15 +00:00
|
|
|
})
|
2021-01-19 03:37:16 +00:00
|
|
|
}
|
|
|
|
|
2021-09-26 12:57:59 +00:00
|
|
|
// Init initializes DataNode configs
|
2021-09-23 02:53:53 +00:00
|
|
|
func (p *ParamTable) Init() {
|
|
|
|
p.BaseTable.Init()
|
|
|
|
err := p.LoadYaml("advanced/data_node.yaml")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// === DataNode Internal Components Configs ===
|
|
|
|
p.initFlowGraphMaxQueueLength()
|
|
|
|
p.initFlowGraphMaxParallelism()
|
|
|
|
p.initFlushInsertBufferSize()
|
|
|
|
p.initInsertBinlogRootPath()
|
|
|
|
p.initStatsBinlogRootPath()
|
|
|
|
|
|
|
|
// === DataNode External Components Configs ===
|
|
|
|
// --- Pulsar ---
|
|
|
|
p.initPulsarAddress()
|
|
|
|
|
|
|
|
p.initRocksmqPath()
|
|
|
|
|
|
|
|
// Has to init global msgchannel prefix before other channel names
|
|
|
|
p.initClusterMsgChannelPrefix()
|
|
|
|
|
|
|
|
// - seg statistics channel -
|
|
|
|
p.initSegmentStatisticsChannelName()
|
|
|
|
|
|
|
|
// - timetick channel -
|
|
|
|
p.initTimeTickChannelName()
|
|
|
|
|
|
|
|
// --- ETCD ---
|
|
|
|
p.initEtcdEndpoints()
|
|
|
|
p.initMetaRootPath()
|
|
|
|
|
|
|
|
// --- MinIO ---
|
|
|
|
p.initMinioAddress()
|
|
|
|
p.initMinioAccessKeyID()
|
|
|
|
p.initMinioSecretAccessKey()
|
|
|
|
p.initMinioUseSSL()
|
|
|
|
p.initMinioBucketName()
|
2021-09-27 09:37:57 +00:00
|
|
|
|
2021-10-01 00:52:50 +00:00
|
|
|
p.initRoleName()
|
2021-09-23 02:53:53 +00:00
|
|
|
}
|
|
|
|
|
2021-01-19 03:37:16 +00:00
|
|
|
// ==== DataNode internal components configs ====
|
|
|
|
// ---- flowgraph configs ----
|
|
|
|
func (p *ParamTable) initFlowGraphMaxQueueLength() {
|
|
|
|
p.FlowGraphMaxQueueLength = p.ParseInt32("dataNode.dataSync.flowGraph.maxQueueLength")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *ParamTable) initFlowGraphMaxParallelism() {
|
|
|
|
p.FlowGraphMaxParallelism = p.ParseInt32("dataNode.dataSync.flowGraph.maxParallelism")
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---- flush configs ----
|
|
|
|
func (p *ParamTable) initFlushInsertBufferSize() {
|
2021-09-30 09:45:07 +00:00
|
|
|
p.FlushInsertBufferSize = p.ParseInt64("_DATANODE_INSERTBUFSIZE")
|
2021-01-19 03:37:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (p *ParamTable) initInsertBinlogRootPath() {
|
|
|
|
// GOOSE TODO: rootPath change to TenentID
|
2021-09-24 12:50:23 +00:00
|
|
|
rootPath, err := p.Load("minio.rootPath")
|
2021-01-19 03:37:16 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
p.InsertBinlogRootPath = path.Join(rootPath, "insert_log")
|
|
|
|
}
|
|
|
|
|
2021-05-20 10:38:45 +00:00
|
|
|
func (p *ParamTable) initStatsBinlogRootPath() {
|
2021-09-24 12:50:23 +00:00
|
|
|
rootPath, err := p.Load("minio.rootPath")
|
2021-05-20 10:38:45 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
p.StatsBinlogRootPath = path.Join(rootPath, "stats_log")
|
|
|
|
}
|
|
|
|
|
2021-01-19 03:37:16 +00:00
|
|
|
// ---- Pulsar ----
|
|
|
|
func (p *ParamTable) initPulsarAddress() {
|
|
|
|
url, err := p.Load("_PulsarAddress")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
p.PulsarAddress = url
|
|
|
|
}
|
|
|
|
|
2021-06-25 11:44:11 +00:00
|
|
|
func (p *ParamTable) initRocksmqPath() {
|
|
|
|
path, err := p.Load("_RocksmqPath")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
p.RocksmqPath = path
|
|
|
|
}
|
|
|
|
|
2021-09-23 02:53:53 +00:00
|
|
|
func (p *ParamTable) initClusterMsgChannelPrefix() {
|
|
|
|
name, err := p.Load("msgChannel.chanNamePrefix.cluster")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
p.ClusterChannelPrefix = name
|
|
|
|
}
|
2021-06-08 11:25:37 +00:00
|
|
|
|
2021-09-23 02:53:53 +00:00
|
|
|
func (p *ParamTable) initSegmentStatisticsChannelName() {
|
|
|
|
config, err := p.Load("msgChannel.chanNamePrefix.dataCoordStatistic")
|
2021-06-08 11:25:37 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2021-09-23 02:53:53 +00:00
|
|
|
s := []string{p.ClusterChannelPrefix, config}
|
|
|
|
p.SegmentStatisticsChannelName = strings.Join(s, "-")
|
2021-01-19 03:37:16 +00:00
|
|
|
}
|
|
|
|
|
2021-06-08 11:25:37 +00:00
|
|
|
func (p *ParamTable) initTimeTickChannelName() {
|
2021-09-23 02:53:53 +00:00
|
|
|
config, err := p.Load("msgChannel.chanNamePrefix.dataCoordTimeTick")
|
2021-06-08 11:25:37 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2021-09-23 02:53:53 +00:00
|
|
|
s := []string{p.ClusterChannelPrefix, config}
|
|
|
|
p.TimeTickChannelName = strings.Join(s, "-")
|
2021-01-19 03:37:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// - msg channel subname -
|
|
|
|
func (p *ParamTable) initMsgChannelSubName() {
|
2021-09-23 02:53:53 +00:00
|
|
|
config, err := p.Load("msgChannel.subNamePrefix.dataNodeSubNamePrefix")
|
2021-01-19 03:37:16 +00:00
|
|
|
if err != nil {
|
2021-02-26 02:13:36 +00:00
|
|
|
panic(err)
|
2021-01-19 03:37:16 +00:00
|
|
|
}
|
2021-09-23 02:53:53 +00:00
|
|
|
s := []string{p.ClusterChannelPrefix, config, strconv.FormatInt(p.NodeID, 10)}
|
|
|
|
p.MsgChannelSubName = strings.Join(s, "-")
|
2021-01-19 03:37:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// --- ETCD ---
|
2021-06-11 14:04:41 +00:00
|
|
|
func (p *ParamTable) initEtcdEndpoints() {
|
|
|
|
endpoints, err := p.Load("_EtcdEndpoints")
|
2021-01-19 03:37:16 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2021-06-11 14:04:41 +00:00
|
|
|
p.EtcdEndpoints = strings.Split(endpoints, ",")
|
2021-01-19 03:37:16 +00: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 = path.Join(rootPath, subPath)
|
|
|
|
}
|
|
|
|
|
2021-06-08 11:25:37 +00:00
|
|
|
// --- MinIO ---
|
2021-01-19 03:37:16 +00:00
|
|
|
func (p *ParamTable) initMinioAddress() {
|
|
|
|
endpoint, err := p.Load("_MinioAddress")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
p.MinioAddress = endpoint
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *ParamTable) initMinioAccessKeyID() {
|
|
|
|
keyID, err := p.Load("minio.accessKeyID")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
p.MinioAccessKeyID = keyID
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *ParamTable) initMinioSecretAccessKey() {
|
|
|
|
key, err := p.Load("minio.secretAccessKey")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
p.MinioSecretAccessKey = key
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *ParamTable) initMinioUseSSL() {
|
|
|
|
usessl, err := p.Load("minio.useSSL")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
p.MinioUseSSL, _ = strconv.ParseBool(usessl)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *ParamTable) initMinioBucketName() {
|
|
|
|
bucketName, err := p.Load("minio.bucketName")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
p.MinioBucketName = bucketName
|
|
|
|
}
|
|
|
|
|
2021-10-01 00:52:50 +00:00
|
|
|
func (p *ParamTable) initRoleName() {
|
|
|
|
p.RoleName = "datanode"
|
2021-02-26 02:13:36 +00:00
|
|
|
}
|