component_param.go 33.0 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
// 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.

package paramtable

import (
15
	"math"
16 17
	"os"
	"path"
18
	"strconv"
19
	"strings"
20
	"sync"
X
Xiaofan 已提交
21
	"sync/atomic"
22
	"time"
23

24
	"go.uber.org/zap"
G
godchen 已提交
25 26

	"github.com/milvus-io/milvus/internal/log"
27 28 29
)

const (
30 31
	// DefaultRetentionDuration defines the default duration for retention which is 5 days in seconds.
	DefaultRetentionDuration = 3600 * 24 * 5
32 33

	// DefaultIndexSliceSize defines the default slice size of index file when serializing.
34
	DefaultIndexSliceSize = 16
35
	DefaultGracefulTime   = 5000 //ms
36 37
)

38
// ComponentParam is used to quickly and easily access all components' configurations.
39 40
type ComponentParam struct {
	ServiceParam
41
	once sync.Once
42

43
	CommonCfg commonConfig
44 45 46 47 48 49 50 51 52 53 54 55

	RootCoordCfg  rootCoordConfig
	ProxyCfg      proxyConfig
	QueryCoordCfg queryCoordConfig
	QueryNodeCfg  queryNodeConfig
	DataCoordCfg  dataCoordConfig
	DataNodeCfg   dataNodeConfig
	IndexCoordCfg indexCoordConfig
	IndexNodeCfg  indexNodeConfig
}

// InitOnce initialize once
56
func (p *ComponentParam) InitOnce() {
57 58 59 60 61
	p.once.Do(func() {
		p.Init()
	})
}

62
// Init initialize the global param table
63 64
func (p *ComponentParam) Init() {
	p.ServiceParam.Init()
65

66
	p.CommonCfg.init(&p.BaseTable)
67

68 69 70 71 72 73 74 75
	p.RootCoordCfg.init(&p.BaseTable)
	p.ProxyCfg.init(&p.BaseTable)
	p.QueryCoordCfg.init(&p.BaseTable)
	p.QueryNodeCfg.init(&p.BaseTable)
	p.DataCoordCfg.init(&p.BaseTable)
	p.DataNodeCfg.init(&p.BaseTable)
	p.IndexCoordCfg.init(&p.BaseTable)
	p.IndexNodeCfg.init(&p.BaseTable)
76 77
}

78
// SetLogConfig set log config with given role
79
func (p *ComponentParam) SetLogConfig(role string) {
80 81
	p.BaseTable.RoleName = role
	p.BaseTable.SetLogConfig()
82 83
}

84 85 86 87 88 89 90 91
func (p *ComponentParam) RocksmqEnable() bool {
	return p.RocksmqCfg.Path != ""
}

func (p *ComponentParam) PulsarEnable() bool {
	return p.PulsarCfg.Address != ""
}

J
jaime 已提交
92 93 94 95
func (p *ComponentParam) KafkaEnable() bool {
	return p.KafkaCfg.Address != ""
}

96
///////////////////////////////////////////////////////////////////////////////
97
// --- common ---
98
type commonConfig struct {
99
	Base *BaseTable
100

101
	ClusterPrefix string
102

103 104
	ProxySubName string

105 106 107 108 109
	RootCoordTimeTick   string
	RootCoordStatistics string
	RootCoordDml        string
	RootCoordDelta      string
	RootCoordSubName    string
110

111 112 113 114
	QueryCoordSearch       string
	QueryCoordSearchResult string
	QueryCoordTimeTick     string
	QueryNodeStats         string
115
	QueryNodeSubName       string
116

117 118 119 120
	DataCoordStatistic   string
	DataCoordTimeTick    string
	DataCoordSegmentInfo string
	DataCoordSubName     string
121
	DataNodeSubName      string
122 123 124 125

	DefaultPartitionName string
	DefaultIndexName     string
	RetentionDuration    int64
X
Xiaofan 已提交
126
	EntityExpirationTTL  time.Duration
127

128
	IndexSliceSize int64
129 130 131 132
	GracefulTime   int64

	StorageType string
	SimdType    string
C
codeman 已提交
133 134

	AuthorizationEnabled bool
135
	MemPurgeRatio        float64
136 137
}

138
func (p *commonConfig) init(base *BaseTable) {
139
	p.Base = base
140

141 142
	// must init cluster prefix first
	p.initClusterPrefix()
143 144
	p.initProxySubName()

145 146 147 148 149 150 151 152 153 154
	p.initRootCoordTimeTick()
	p.initRootCoordStatistics()
	p.initRootCoordDml()
	p.initRootCoordDelta()
	p.initRootCoordSubName()

	p.initQueryCoordSearch()
	p.initQueryCoordSearchResult()
	p.initQueryCoordTimeTick()
	p.initQueryNodeStats()
155
	p.initQueryNodeSubName()
156 157 158 159 160

	p.initDataCoordStatistic()
	p.initDataCoordTimeTick()
	p.initDataCoordSegmentInfo()
	p.initDataCoordSubName()
161
	p.initDataNodeSubName()
162 163 164 165

	p.initDefaultPartitionName()
	p.initDefaultIndexName()
	p.initRetentionDuration()
X
Xiaofan 已提交
166
	p.initEntityExpiration()
167 168

	p.initSimdType()
169
	p.initIndexSliceSize()
170
	p.initGracefulTime()
J
jaime 已提交
171
	p.initStorageType()
C
codeman 已提交
172 173

	p.initEnableAuthorization()
174
	p.initMemoryPurgeRatio()
175 176
}

177 178 179
func (p *commonConfig) initClusterPrefix() {
	keys := []string{
		"msgChannel.chanNamePrefix.cluster",
X
Xiaofan 已提交
180
		"common.chanNamePrefix.cluster",
181
	}
X
Xiaofan 已提交
182
	str, err := p.Base.LoadWithPriority(keys)
183 184 185
	if err != nil {
		panic(err)
	}
186
	p.ClusterPrefix = str
187 188
}

189
func (p *commonConfig) initChanNamePrefix(keys []string) string {
X
Xiaofan 已提交
190
	value, err := p.Base.LoadWithPriority(keys)
191 192 193
	if err != nil {
		panic(err)
	}
194 195
	s := []string{p.ClusterPrefix, value}
	return strings.Join(s, "-")
196 197
}

198
// --- proxy ---
199 200 201
func (p *commonConfig) initProxySubName() {
	keys := []string{
		"msgChannel.subNamePrefix.proxySubNamePrefix",
X
Xiaofan 已提交
202
		"common.subNamePrefix.proxySubNamePrefix",
203 204
	}
	p.ProxySubName = p.initChanNamePrefix(keys)
205 206
}

207
// --- rootcoord ---
X
Xiaofan 已提交
208
// Deprecate
209 210 211
func (p *commonConfig) initRootCoordTimeTick() {
	keys := []string{
		"msgChannel.chanNamePrefix.rootCoordTimeTick",
X
Xiaofan 已提交
212
		"common.chanNamePrefix.rootCoordTimeTick",
213 214
	}
	p.RootCoordTimeTick = p.initChanNamePrefix(keys)
215 216
}

217 218 219
func (p *commonConfig) initRootCoordStatistics() {
	keys := []string{
		"msgChannel.chanNamePrefix.rootCoordStatistics",
X
Xiaofan 已提交
220
		"common.chanNamePrefix.rootCoordStatistics",
221 222
	}
	p.RootCoordStatistics = p.initChanNamePrefix(keys)
223 224
}

225 226 227
func (p *commonConfig) initRootCoordDml() {
	keys := []string{
		"msgChannel.chanNamePrefix.rootCoordDml",
X
Xiaofan 已提交
228
		"common.chanNamePrefix.rootCoordDml",
229 230
	}
	p.RootCoordDml = p.initChanNamePrefix(keys)
231 232
}

233 234 235
func (p *commonConfig) initRootCoordDelta() {
	keys := []string{
		"msgChannel.chanNamePrefix.rootCoordDelta",
X
Xiaofan 已提交
236
		"common.chanNamePrefix.rootCoordDelta",
237 238
	}
	p.RootCoordDelta = p.initChanNamePrefix(keys)
239 240
}

241 242 243
func (p *commonConfig) initRootCoordSubName() {
	keys := []string{
		"msgChannel.subNamePrefix.rootCoordSubNamePrefix",
X
Xiaofan 已提交
244
		"common.subNamePrefix.rootCoordSubNamePrefix",
245 246
	}
	p.RootCoordSubName = p.initChanNamePrefix(keys)
247 248 249
}

// --- querycoord ---
250 251 252
func (p *commonConfig) initQueryCoordSearch() {
	keys := []string{
		"msgChannel.chanNamePrefix.search",
X
Xiaofan 已提交
253
		"common.chanNamePrefix.search",
254 255
	}
	p.QueryCoordSearch = p.initChanNamePrefix(keys)
256 257
}

X
Xiaofan 已提交
258
// Deprecated, search result use grpc instead of a result channel
259 260 261
func (p *commonConfig) initQueryCoordSearchResult() {
	keys := []string{
		"msgChannel.chanNamePrefix.searchResult",
X
Xiaofan 已提交
262
		"common.chanNamePrefix.searchResult",
263 264
	}
	p.QueryCoordSearchResult = p.initChanNamePrefix(keys)
265 266
}

X
Xiaofan 已提交
267
// Deprecate
268 269 270
func (p *commonConfig) initQueryCoordTimeTick() {
	keys := []string{
		"msgChannel.chanNamePrefix.queryTimeTick",
X
Xiaofan 已提交
271
		"common.chanNamePrefix.queryTimeTick",
272 273
	}
	p.QueryCoordTimeTick = p.initChanNamePrefix(keys)
274 275 276
}

// --- querynode ---
277 278 279
func (p *commonConfig) initQueryNodeStats() {
	keys := []string{
		"msgChannel.chanNamePrefix.queryNodeStats",
X
Xiaofan 已提交
280
		"common.chanNamePrefix.queryNodeStats",
281 282
	}
	p.QueryNodeStats = p.initChanNamePrefix(keys)
283 284
}

285 286 287
func (p *commonConfig) initQueryNodeSubName() {
	keys := []string{
		"msgChannel.subNamePrefix.queryNodeSubNamePrefix",
X
Xiaofan 已提交
288
		"common.subNamePrefix.queryNodeSubNamePrefix",
289 290
	}
	p.QueryNodeSubName = p.initChanNamePrefix(keys)
291 292
}

293
// --- datacoord ---
294 295 296
func (p *commonConfig) initDataCoordStatistic() {
	keys := []string{
		"msgChannel.chanNamePrefix.dataCoordStatistic",
X
Xiaofan 已提交
297
		"common.chanNamePrefix.dataCoordStatistic",
298 299
	}
	p.DataCoordStatistic = p.initChanNamePrefix(keys)
300 301
}

X
Xiaofan 已提交
302
// Deprecate
303 304 305
func (p *commonConfig) initDataCoordTimeTick() {
	keys := []string{
		"msgChannel.chanNamePrefix.dataCoordTimeTick",
X
Xiaofan 已提交
306
		"common.chanNamePrefix.dataCoordTimeTick",
307 308
	}
	p.DataCoordTimeTick = p.initChanNamePrefix(keys)
309 310
}

311 312 313
func (p *commonConfig) initDataCoordSegmentInfo() {
	keys := []string{
		"msgChannel.chanNamePrefix.dataCoordSegmentInfo",
X
Xiaofan 已提交
314
		"common.chanNamePrefix.dataCoordSegmentInfo",
315 316
	}
	p.DataCoordSegmentInfo = p.initChanNamePrefix(keys)
317 318
}

319 320 321
func (p *commonConfig) initDataCoordSubName() {
	keys := []string{
		"msgChannel.subNamePrefix.dataCoordSubNamePrefix",
X
Xiaofan 已提交
322
		"common.subNamePrefix.dataCoordSubNamePrefix",
323 324
	}
	p.DataCoordSubName = p.initChanNamePrefix(keys)
325 326
}

327 328 329
func (p *commonConfig) initDataNodeSubName() {
	keys := []string{
		"msgChannel.subNamePrefix.dataNodeSubNamePrefix",
X
Xiaofan 已提交
330
		"common.subNamePrefix.dataNodeSubNamePrefix",
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346
	}
	p.DataNodeSubName = p.initChanNamePrefix(keys)
}

func (p *commonConfig) initDefaultPartitionName() {
	p.DefaultPartitionName = p.Base.LoadWithDefault("common.defaultPartitionName", "_default")
}

func (p *commonConfig) initDefaultIndexName() {
	p.DefaultIndexName = p.Base.LoadWithDefault("common.defaultIndexName", "_default_idx")
}

func (p *commonConfig) initRetentionDuration() {
	p.RetentionDuration = p.Base.ParseInt64WithDefault("common.retentionDuration", DefaultRetentionDuration)
}

X
Xiaofan 已提交
347 348 349 350 351 352 353 354 355 356 357 358 359 360 361
func (p *commonConfig) initEntityExpiration() {
	ttl := p.Base.ParseInt64WithDefault("common.entityExpiration", -1)
	if ttl < 0 {
		p.EntityExpirationTTL = -1
		return
	}

	// make sure ttl is larger than retention duration to ensure time travel works
	if ttl > p.RetentionDuration {
		p.EntityExpirationTTL = time.Duration(ttl) * time.Second
	} else {
		p.EntityExpirationTTL = time.Duration(p.RetentionDuration) * time.Second
	}
}

362 363 364 365 366 367
func (p *commonConfig) initSimdType() {
	keys := []string{
		"common.simdType",
		"knowhere.simdType",
	}
	p.SimdType = p.Base.LoadWithDefault2(keys, "auto")
368 369
}

370 371 372 373
func (p *commonConfig) initIndexSliceSize() {
	p.IndexSliceSize = p.Base.ParseInt64WithDefault("common.indexSliceSize", DefaultIndexSliceSize)
}

374 375 376 377
func (p *commonConfig) initGracefulTime() {
	p.GracefulTime = p.Base.ParseInt64WithDefault("common.gracefulTime", DefaultGracefulTime)
}

J
jaime 已提交
378
func (p *commonConfig) initStorageType() {
X
Xiaofan 已提交
379
	p.StorageType = p.Base.LoadWithDefault("common.storageType", "minio")
J
jaime 已提交
380 381
}

C
codeman 已提交
382 383 384 385
func (p *commonConfig) initEnableAuthorization() {
	p.AuthorizationEnabled = p.Base.ParseBool("common.security.authorizationEnabled", false)
}

386 387 388 389
func (p *commonConfig) initMemoryPurgeRatio() {
	p.MemPurgeRatio = p.Base.ParseFloatWithDefault("common.mem_purge_ratio", 0.2)
}

390 391 392
///////////////////////////////////////////////////////////////////////////////
// --- rootcoord ---
type rootCoordConfig struct {
393
	Base *BaseTable
394 395 396 397

	Address string
	Port    int

398 399 400 401 402 403 404 405 406
	DmlChannelNum                   int64
	MaxPartitionNum                 int64
	MinSegmentSizeToEnableIndex     int64
	ImportTaskExpiration            float64
	ImportTaskRetention             float64
	ImportSegmentStateCheckInterval float64
	ImportSegmentStateWaitLimit     float64
	ImportIndexCheckInterval        float64
	ImportIndexWaitLimit            float64
407

408 409 410
	// --- ETCD Path ---
	ImportTaskSubPath string

411 412 413 414
	CreatedTime time.Time
	UpdatedTime time.Time
}

415 416 417 418 419
func (p *rootCoordConfig) init(base *BaseTable) {
	p.Base = base
	p.DmlChannelNum = p.Base.ParseInt64WithDefault("rootCoord.dmlChannelNum", 256)
	p.MaxPartitionNum = p.Base.ParseInt64WithDefault("rootCoord.maxPartitionNum", 4096)
	p.MinSegmentSizeToEnableIndex = p.Base.ParseInt64WithDefault("rootCoord.minSegmentSizeToEnableIndex", 1024)
420 421
	p.ImportTaskExpiration = p.Base.ParseFloatWithDefault("rootCoord.importTaskExpiration", 15*60)
	p.ImportTaskRetention = p.Base.ParseFloatWithDefault("rootCoord.importTaskRetention", 24*60*60)
422 423
	p.ImportSegmentStateCheckInterval = p.Base.ParseFloatWithDefault("rootCoord.importSegmentStateCheckInterval", 10)
	p.ImportSegmentStateWaitLimit = p.Base.ParseFloatWithDefault("rootCoord.importSegmentStateWaitLimit", 60)
424 425
	p.ImportIndexCheckInterval = p.Base.ParseFloatWithDefault("rootCoord.importIndexCheckInterval", 10)
	p.ImportIndexWaitLimit = p.Base.ParseFloatWithDefault("rootCoord.importIndexWaitLimit", 10*60)
426
	p.ImportTaskSubPath = "importtask"
427 428 429 430 431
}

///////////////////////////////////////////////////////////////////////////////
// --- proxy ---
type proxyConfig struct {
432
	Base *BaseTable
433 434

	// NetworkPort & IP are not used
435 436
	NetworkPort    int
	IP             string
437 438 439 440
	NetworkAddress string

	Alias string

X
Xiaofan 已提交
441
	NodeID                   atomic.Value
442 443 444
	TimeTickInterval         time.Duration
	MsgStreamTimeTickBufSize int64
	MaxNameLength            int64
445
	MaxUsernameLength        int64
446
	MinPasswordLength        int64
447
	MaxPasswordLength        int64
448 449 450
	MaxFieldNum              int64
	MaxShardNum              int32
	MaxDimension             int64
451
	GinLogging               bool
452

453
	// required from QueryCoord
454 455 456 457 458 459 460 461 462
	SearchResultChannelNames   []string
	RetrieveResultChannelNames []string

	MaxTaskNum int64

	CreatedTime time.Time
	UpdatedTime time.Time
}

463 464
func (p *proxyConfig) init(base *BaseTable) {
	p.Base = base
X
Xiaofan 已提交
465
	p.NodeID.Store(UniqueID(0))
466 467 468 469
	p.initTimeTickInterval()

	p.initMsgStreamTimeTickBufSize()
	p.initMaxNameLength()
470
	p.initMinPasswordLength()
471 472
	p.initMaxUsernameLength()
	p.initMaxPasswordLength()
473 474 475 476 477
	p.initMaxFieldNum()
	p.initMaxShardNum()
	p.initMaxDimension()

	p.initMaxTaskNum()
478
	p.initGinLogging()
479 480 481 482 483 484 485 486
}

// InitAlias initialize Alias member.
func (p *proxyConfig) InitAlias(alias string) {
	p.Alias = alias
}

func (p *proxyConfig) initTimeTickInterval() {
487
	interval := p.Base.ParseIntWithDefault("proxy.timeTickInterval", 200)
488 489 490 491
	p.TimeTickInterval = time.Duration(interval) * time.Millisecond
}

func (p *proxyConfig) initMsgStreamTimeTickBufSize() {
492
	p.MsgStreamTimeTickBufSize = p.Base.ParseInt64WithDefault("proxy.msgStream.timeTick.bufSize", 512)
493 494 495
}

func (p *proxyConfig) initMaxNameLength() {
496
	str := p.Base.LoadWithDefault("proxy.maxNameLength", "255")
497 498 499 500 501 502 503
	maxNameLength, err := strconv.ParseInt(str, 10, 64)
	if err != nil {
		panic(err)
	}
	p.MaxNameLength = maxNameLength
}

504 505 506 507 508 509 510 511 512
func (p *proxyConfig) initMaxUsernameLength() {
	str := p.Base.LoadWithDefault("proxy.maxUsernameLength", "32")
	maxUsernameLength, err := strconv.ParseInt(str, 10, 64)
	if err != nil {
		panic(err)
	}
	p.MaxUsernameLength = maxUsernameLength
}

513 514 515 516 517 518 519 520 521
func (p *proxyConfig) initMinPasswordLength() {
	str := p.Base.LoadWithDefault("proxy.minPasswordLength", "6")
	minPasswordLength, err := strconv.ParseInt(str, 10, 64)
	if err != nil {
		panic(err)
	}
	p.MinPasswordLength = minPasswordLength
}

522 523 524 525 526 527 528 529 530
func (p *proxyConfig) initMaxPasswordLength() {
	str := p.Base.LoadWithDefault("proxy.maxPasswordLength", "256")
	maxPasswordLength, err := strconv.ParseInt(str, 10, 64)
	if err != nil {
		panic(err)
	}
	p.MaxPasswordLength = maxPasswordLength
}

531
func (p *proxyConfig) initMaxShardNum() {
532
	str := p.Base.LoadWithDefault("proxy.maxShardNum", "256")
533 534 535 536 537 538 539 540
	maxShardNum, err := strconv.ParseInt(str, 10, 64)
	if err != nil {
		panic(err)
	}
	p.MaxShardNum = int32(maxShardNum)
}

func (p *proxyConfig) initMaxFieldNum() {
541
	str := p.Base.LoadWithDefault("proxy.maxFieldNum", "64")
542 543 544 545 546 547 548 549
	maxFieldNum, err := strconv.ParseInt(str, 10, 64)
	if err != nil {
		panic(err)
	}
	p.MaxFieldNum = maxFieldNum
}

func (p *proxyConfig) initMaxDimension() {
550
	str := p.Base.LoadWithDefault("proxy.maxDimension", "32768")
551 552 553 554 555 556 557 558
	maxDimension, err := strconv.ParseInt(str, 10, 64)
	if err != nil {
		panic(err)
	}
	p.MaxDimension = maxDimension
}

func (p *proxyConfig) initMaxTaskNum() {
559
	p.MaxTaskNum = p.Base.ParseInt64WithDefault("proxy.maxTaskNum", 1024)
560 561
}

562 563 564 565 566
func (p *proxyConfig) initGinLogging() {
	// Gin logging is on by default.
	p.GinLogging = p.Base.ParseBool("proxy.ginLogging", true)
}

X
Xiaofan 已提交
567 568 569 570 571 572 573 574 575 576 577 578
func (p *proxyConfig) SetNodeID(id UniqueID) {
	p.NodeID.Store(id)
}

func (p *proxyConfig) GetNodeID() UniqueID {
	val := p.NodeID.Load()
	if val != nil {
		return val.(UniqueID)
	}
	return 0
}

579 580 581
///////////////////////////////////////////////////////////////////////////////
// --- querycoord ---
type queryCoordConfig struct {
582
	Base *BaseTable
583

X
Xiaofan 已提交
584 585 586
	Address string
	Port    int
	NodeID  atomic.Value
587 588 589 590 591 592 593 594 595 596 597 598 599 600

	CreatedTime time.Time
	UpdatedTime time.Time

	//---- Handoff ---
	AutoHandoff bool

	//---- Balance ---
	AutoBalance                         bool
	OverloadedMemoryThresholdPercentage float64
	BalanceIntervalSeconds              int64
	MemoryUsageMaxDifferencePercentage  float64
}

601 602
func (p *queryCoordConfig) init(base *BaseTable) {
	p.Base = base
X
Xiaofan 已提交
603
	p.NodeID.Store(UniqueID(0))
604 605 606 607 608 609 610 611 612 613 614
	//---- Handoff ---
	p.initAutoHandoff()

	//---- Balance ---
	p.initAutoBalance()
	p.initOverloadedMemoryThresholdPercentage()
	p.initBalanceIntervalSeconds()
	p.initMemoryUsageMaxDifferencePercentage()
}

func (p *queryCoordConfig) initAutoHandoff() {
615
	handoff, err := p.Base.Load("queryCoord.autoHandoff")
616 617 618 619 620 621 622 623 624 625
	if err != nil {
		panic(err)
	}
	p.AutoHandoff, err = strconv.ParseBool(handoff)
	if err != nil {
		panic(err)
	}
}

func (p *queryCoordConfig) initAutoBalance() {
626
	balanceStr := p.Base.LoadWithDefault("queryCoord.autoBalance", "false")
627 628 629 630 631 632 633 634
	autoBalance, err := strconv.ParseBool(balanceStr)
	if err != nil {
		panic(err)
	}
	p.AutoBalance = autoBalance
}

func (p *queryCoordConfig) initOverloadedMemoryThresholdPercentage() {
635
	overloadedMemoryThresholdPercentage := p.Base.LoadWithDefault("queryCoord.overloadedMemoryThresholdPercentage", "90")
636 637 638 639 640 641 642 643
	thresholdPercentage, err := strconv.ParseInt(overloadedMemoryThresholdPercentage, 10, 64)
	if err != nil {
		panic(err)
	}
	p.OverloadedMemoryThresholdPercentage = float64(thresholdPercentage) / 100
}

func (p *queryCoordConfig) initBalanceIntervalSeconds() {
644
	balanceInterval := p.Base.LoadWithDefault("queryCoord.balanceIntervalSeconds", "60")
645 646 647 648 649 650 651 652
	interval, err := strconv.ParseInt(balanceInterval, 10, 64)
	if err != nil {
		panic(err)
	}
	p.BalanceIntervalSeconds = interval
}

func (p *queryCoordConfig) initMemoryUsageMaxDifferencePercentage() {
653
	maxDiff := p.Base.LoadWithDefault("queryCoord.memoryUsageMaxDifferencePercentage", "30")
654 655 656 657 658 659 660
	diffPercentage, err := strconv.ParseInt(maxDiff, 10, 64)
	if err != nil {
		panic(err)
	}
	p.MemoryUsageMaxDifferencePercentage = float64(diffPercentage) / 100
}

X
Xiaofan 已提交
661 662 663 664 665 666 667 668 669 670 671 672
func (p *queryCoordConfig) SetNodeID(id UniqueID) {
	p.NodeID.Store(id)
}

func (p *queryCoordConfig) GetNodeID() UniqueID {
	val := p.NodeID.Load()
	if val != nil {
		return val.(UniqueID)
	}
	return 0
}

673 674 675
///////////////////////////////////////////////////////////////////////////////
// --- querynode ---
type queryNodeConfig struct {
676
	Base *BaseTable
677 678 679 680

	Alias         string
	QueryNodeIP   string
	QueryNodePort int64
X
Xiaofan 已提交
681
	NodeID        atomic.Value
682 683 684 685 686 687 688 689 690
	// TODO: remove cacheSize
	CacheSize int64 // deprecated

	FlowGraphMaxQueueLength int32
	FlowGraphMaxParallelism int32

	// stats
	StatsPublishInterval int

691
	SliceIndex int
692 693

	// segcore
694 695 696
	ChunkRows        int64
	SmallIndexNlist  int64
	SmallIndexNProbe int64
697 698 699 700 701

	CreatedTime time.Time
	UpdatedTime time.Time

	// memory limit
702
	LoadMemoryUsageFactor               float64
703
	OverloadedMemoryThresholdPercentage float64
G
godchen 已提交
704 705

	// cache limit
G
godchen 已提交
706 707
	CacheEnabled     bool
	CacheMemoryLimit int64
708 709 710 711 712 713

	GroupEnabled         bool
	MaxReceiveChanSize   int32
	MaxUnsolvedQueueSize int32
	MaxGroupNQ           int64
	TopKMergeRatio       float64
714 715
}

716 717
func (p *queryNodeConfig) init(base *BaseTable) {
	p.Base = base
X
Xiaofan 已提交
718
	p.NodeID.Store(UniqueID(0))
719 720 721 722 723 724 725
	p.initCacheSize()

	p.initFlowGraphMaxQueueLength()
	p.initFlowGraphMaxParallelism()

	p.initStatsPublishInterval()

726
	p.initSmallIndexParams()
727

728
	p.initLoadMemoryUsageFactor()
729
	p.initOverloadedMemoryThresholdPercentage()
G
godchen 已提交
730

G
godchen 已提交
731 732
	p.initCacheMemoryLimit()
	p.initCacheEnabled()
733 734 735 736 737 738

	p.initGroupEnabled()
	p.initMaxReceiveChanSize()
	p.initMaxUnsolvedQueueSize()
	p.initMaxGroupNQ()
	p.initTopKMergeRatio()
739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754
}

// InitAlias initializes an alias for the QueryNode role.
func (p *queryNodeConfig) InitAlias(alias string) {
	p.Alias = alias
}

func (p *queryNodeConfig) initCacheSize() {
	defer log.Debug("init cacheSize", zap.Any("cacheSize (GB)", p.CacheSize))

	const defaultCacheSize = 32 // GB
	p.CacheSize = defaultCacheSize

	var err error
	cacheSize := os.Getenv("CACHE_SIZE")
	if cacheSize == "" {
755
		cacheSize, err = p.Base.Load("queryNode.cacheSize")
756 757 758 759 760 761 762 763 764 765 766 767 768 769
		if err != nil {
			return
		}
	}
	value, err := strconv.ParseInt(cacheSize, 10, 64)
	if err != nil {
		return
	}
	p.CacheSize = value
}

// advanced params
// stats
func (p *queryNodeConfig) initStatsPublishInterval() {
770
	p.StatsPublishInterval = p.Base.ParseIntWithDefault("queryNode.stats.publishInterval", 1000)
771 772 773 774
}

// dataSync:
func (p *queryNodeConfig) initFlowGraphMaxQueueLength() {
775
	p.FlowGraphMaxQueueLength = p.Base.ParseInt32WithDefault("queryNode.dataSync.flowGraph.maxQueueLength", 1024)
776 777 778
}

func (p *queryNodeConfig) initFlowGraphMaxParallelism() {
779
	p.FlowGraphMaxParallelism = p.Base.ParseInt32WithDefault("queryNode.dataSync.flowGraph.maxParallelism", 1024)
780 781
}

782
func (p *queryNodeConfig) initSmallIndexParams() {
783
	p.ChunkRows = p.Base.ParseInt64WithDefault("queryNode.segcore.chunkRows", 32768)
784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809
	if p.ChunkRows < 1024 {
		log.Warn("chunk rows can not be less than 1024, force set to 1024", zap.Any("current", p.ChunkRows))
		p.ChunkRows = 1024
	}

	// default NList is the first nlist
	var defaultNList int64
	for i := int64(0); i < p.ChunkRows; i++ {
		if math.Pow(2.0, float64(i)) > math.Sqrt(float64(p.ChunkRows)) {
			defaultNList = int64(math.Pow(2, float64(i)))
			break
		}
	}

	p.SmallIndexNlist = p.Base.ParseInt64WithDefault("queryNode.segcore.smallIndex.nlist", defaultNList)
	if p.SmallIndexNlist > p.ChunkRows/8 {
		log.Warn("small index nlist must smaller than chunkRows/8, force set to", zap.Any("nliit", p.ChunkRows/8))
		p.SmallIndexNlist = p.ChunkRows / 8
	}

	defaultNprobe := p.SmallIndexNlist / 16
	p.SmallIndexNProbe = p.Base.ParseInt64WithDefault("queryNode.segcore.smallIndex.nprobe", defaultNprobe)
	if p.SmallIndexNProbe > p.SmallIndexNlist {
		log.Warn("small index nprobe must smaller than nlist, force set to", zap.Any("nprobe", p.SmallIndexNlist))
		p.SmallIndexNProbe = p.SmallIndexNlist
	}
810 811
}

812 813 814 815 816 817 818 819 820
func (p *queryNodeConfig) initLoadMemoryUsageFactor() {
	loadMemoryUsageFactor := p.Base.LoadWithDefault("queryNode.loadMemoryUsageFactor", "3")
	factor, err := strconv.ParseFloat(loadMemoryUsageFactor, 64)
	if err != nil {
		panic(err)
	}
	p.LoadMemoryUsageFactor = factor
}

821
func (p *queryNodeConfig) initOverloadedMemoryThresholdPercentage() {
822
	overloadedMemoryThresholdPercentage := p.Base.LoadWithDefault("queryCoord.overloadedMemoryThresholdPercentage", "90")
823 824 825 826 827 828 829
	thresholdPercentage, err := strconv.ParseInt(overloadedMemoryThresholdPercentage, 10, 64)
	if err != nil {
		panic(err)
	}
	p.OverloadedMemoryThresholdPercentage = float64(thresholdPercentage) / 100
}

G
godchen 已提交
830 831 832 833 834 835 836 837
func (p *queryNodeConfig) initCacheMemoryLimit() {
	overloadedMemoryThresholdPercentage := p.Base.LoadWithDefault("queryNode.cache.memoryLimit", "2147483648")
	cacheMemoryLimit, err := strconv.ParseInt(overloadedMemoryThresholdPercentage, 10, 64)
	if err != nil {
		panic(err)
	}
	p.CacheMemoryLimit = cacheMemoryLimit
}
X
Xiaofan 已提交
838

G
godchen 已提交
839 840 841 842
func (p *queryNodeConfig) initCacheEnabled() {
	var err error
	cacheEnabled := p.Base.LoadWithDefault("queryNode.cache.enabled", "true")
	p.CacheEnabled, err = strconv.ParseBool(cacheEnabled)
G
godchen 已提交
843 844 845 846 847
	if err != nil {
		panic(err)
	}
}

848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867
func (p *queryNodeConfig) initGroupEnabled() {
	p.GroupEnabled = p.Base.ParseBool("queryNode.grouping.enabled", true)
}

func (p *queryNodeConfig) initMaxReceiveChanSize() {
	p.MaxReceiveChanSize = p.Base.ParseInt32WithDefault("queryNode.grouping.receiveChanSize", 10240)
}

func (p *queryNodeConfig) initMaxUnsolvedQueueSize() {
	p.MaxUnsolvedQueueSize = p.Base.ParseInt32WithDefault("queryNode.grouping.unsolvedQueueSize", 10240)
}

func (p *queryNodeConfig) initMaxGroupNQ() {
	p.MaxGroupNQ = p.Base.ParseInt64WithDefault("queryNode.grouping.maxNQ", 1000)
}

func (p *queryNodeConfig) initTopKMergeRatio() {
	p.TopKMergeRatio = p.Base.ParseFloatWithDefault("queryNode.grouping.topKMergeRatio", 10.0)
}

X
Xiaofan 已提交
868 869 870 871 872 873 874 875 876 877 878 879
func (p *queryNodeConfig) SetNodeID(id UniqueID) {
	p.NodeID.Store(id)
}

func (p *queryNodeConfig) GetNodeID() UniqueID {
	val := p.NodeID.Load()
	if val != nil {
		return val.(UniqueID)
	}
	return 0
}

880 881 882
///////////////////////////////////////////////////////////////////////////////
// --- datacoord ---
type dataCoordConfig struct {
883
	Base *BaseTable
884

X
Xiaofan 已提交
885
	NodeID atomic.Value
886 887 888 889 890 891

	IP      string
	Port    int
	Address string

	// --- ETCD ---
X
XuanYang-cn 已提交
892
	ChannelWatchSubPath string
893 894 895 896 897

	// --- SEGMENTS ---
	SegmentMaxSize          float64
	SegmentSealProportion   float64
	SegAssignmentExpiration int64
898
	SegmentMaxLifetime      time.Duration
899 900 901 902

	CreatedTime time.Time
	UpdatedTime time.Time

903 904 905 906 907 908 909 910 911 912 913 914 915
	// compaction
	EnableCompaction     bool
	EnableAutoCompaction atomic.Value

	MinSegmentToMerge                 int
	MaxSegmentToMerge                 int
	SegmentSmallProportion            float64
	CompactionTimeoutInSeconds        int32
	SingleCompactionRatioThreshold    float32
	SingleCompactionDeltaLogMaxSize   int64
	SingleCompactionExpiredLogMaxSize int64
	SingleCompactionBinlogMaxNum      int64
	GlobalCompactionInterval          time.Duration
916 917

	// Garbage Collection
918 919 920 921
	EnableGarbageCollection bool
	GCInterval              time.Duration
	GCMissingTolerance      time.Duration
	GCDropTolerance         time.Duration
922 923
}

924 925
func (p *dataCoordConfig) init(base *BaseTable) {
	p.Base = base
926 927 928 929 930
	p.initChannelWatchPrefix()

	p.initSegmentMaxSize()
	p.initSegmentSealProportion()
	p.initSegAssignmentExpiration()
931
	p.initSegmentMaxLifetime()
932 933 934 935

	p.initEnableCompaction()
	p.initEnableAutoCompaction()

936 937 938 939 940 941 942 943 944 945
	p.initCompactionMinSegment()
	p.initCompactionMaxSegment()
	p.initSegmentSmallProportion()
	p.initCompactionTimeoutInSeconds()
	p.initSingleCompactionRatioThreshold()
	p.initSingleCompactionDeltaLogMaxSize()
	p.initSingleCompactionExpiredLogMaxSize()
	p.initSingleCompactionBinlogMaxNum()
	p.initGlobalCompactionInterval()

946 947 948 949 950 951 952
	p.initEnableGarbageCollection()
	p.initGCInterval()
	p.initGCMissingTolerance()
	p.initGCDropTolerance()
}

func (p *dataCoordConfig) initSegmentMaxSize() {
953
	p.SegmentMaxSize = p.Base.ParseFloatWithDefault("dataCoord.segment.maxSize", 512.0)
954 955 956
}

func (p *dataCoordConfig) initSegmentSealProportion() {
957
	p.SegmentSealProportion = p.Base.ParseFloatWithDefault("dataCoord.segment.sealProportion", 0.25)
958 959 960
}

func (p *dataCoordConfig) initSegAssignmentExpiration() {
961
	p.SegAssignmentExpiration = p.Base.ParseInt64WithDefault("dataCoord.segment.assignmentExpiration", 2000)
962 963
}

964 965 966 967
func (p *dataCoordConfig) initSegmentMaxLifetime() {
	p.SegmentMaxLifetime = time.Duration(p.Base.ParseInt64WithDefault("dataCoord.segment.maxLife", 24*60*60)) * time.Second
}

968 969 970 971 972 973 974
func (p *dataCoordConfig) 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"
}

func (p *dataCoordConfig) initEnableCompaction() {
975
	p.EnableCompaction = p.Base.ParseBool("dataCoord.enableCompaction", false)
976 977
}

978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023
func (p *dataCoordConfig) initEnableAutoCompaction() {
	p.EnableAutoCompaction.Store(p.Base.ParseBool("dataCoord.compaction.enableAutoCompaction", false))
}

func (p *dataCoordConfig) initCompactionMinSegment() {
	p.MinSegmentToMerge = p.Base.ParseIntWithDefault("dataCoord.compaction.min.segment", 4)
}

func (p *dataCoordConfig) initCompactionMaxSegment() {
	p.MaxSegmentToMerge = p.Base.ParseIntWithDefault("dataCoord.compaction.max.segment", 30)
}

func (p *dataCoordConfig) initSegmentSmallProportion() {
	p.SegmentSmallProportion = p.Base.ParseFloatWithDefault("dataCoord.segment.smallProportion", 0.5)
}

// compaction execution timeout
func (p *dataCoordConfig) initCompactionTimeoutInSeconds() {
	p.CompactionTimeoutInSeconds = p.Base.ParseInt32WithDefault("dataCoord.compaction.timeout", 60*3)
}

// if total delete entities is large than a ratio of total entities, trigger single compaction.
func (p *dataCoordConfig) initSingleCompactionRatioThreshold() {
	p.SingleCompactionRatioThreshold = float32(p.Base.ParseFloatWithDefault("dataCoord.compaction.single.ratio.threshold", 0.2))
}

// if total delta file size > SingleCompactionDeltaLogMaxSize, trigger single compaction
func (p *dataCoordConfig) initSingleCompactionDeltaLogMaxSize() {
	p.SingleCompactionDeltaLogMaxSize = p.Base.ParseInt64WithDefault("dataCoord.compaction.single.deltalog.maxsize", 2*1024*1024)
}

// if total expired file size > SingleCompactionExpiredLogMaxSize, trigger single compaction
func (p *dataCoordConfig) initSingleCompactionExpiredLogMaxSize() {
	p.SingleCompactionExpiredLogMaxSize = p.Base.ParseInt64WithDefault("dataCoord.compaction.single.expiredlog.maxsize", 10*1024*1024)
}

// if total binlog number > SingleCompactionBinlogMaxNum, trigger single compaction to ensure binlog number per segment is limited
func (p *dataCoordConfig) initSingleCompactionBinlogMaxNum() {
	p.SingleCompactionBinlogMaxNum = p.Base.ParseInt64WithDefault("dataCoord.compaction.single.binlog.maxnum", 1000)
}

// interval we check and trigger global compaction
func (p *dataCoordConfig) initGlobalCompactionInterval() {
	p.GlobalCompactionInterval = time.Duration(p.Base.ParseInt64WithDefault("dataCoord.compaction.global.interval", int64(60*time.Second)))
}

1024 1025
// -- GC --
func (p *dataCoordConfig) initEnableGarbageCollection() {
1026
	p.EnableGarbageCollection = p.Base.ParseBool("dataCoord.enableGarbageCollection", false)
1027 1028 1029
}

func (p *dataCoordConfig) initGCInterval() {
1030
	p.GCInterval = time.Duration(p.Base.ParseInt64WithDefault("dataCoord.gc.interval", 60*60)) * time.Second
1031 1032 1033
}

func (p *dataCoordConfig) initGCMissingTolerance() {
1034
	p.GCMissingTolerance = time.Duration(p.Base.ParseInt64WithDefault("dataCoord.gc.missingTolerance", 24*60*60)) * time.Second
1035 1036 1037
}

func (p *dataCoordConfig) initGCDropTolerance() {
1038
	p.GCDropTolerance = time.Duration(p.Base.ParseInt64WithDefault("dataCoord.gc.dropTolerance", 24*60*60)) * time.Second
1039 1040
}

1041 1042 1043 1044 1045 1046 1047 1048 1049 1050
func (p *dataCoordConfig) SetEnableAutoCompaction(enable bool) {
	p.EnableAutoCompaction.Store(enable)
}

func (p *dataCoordConfig) GetEnableAutoCompaction() bool {
	enable := p.EnableAutoCompaction.Load()
	if enable != nil {
		return enable.(bool)
	}
	return false
1051 1052
}

X
Xiaofan 已提交
1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064
func (p *dataCoordConfig) SetNodeID(id UniqueID) {
	p.NodeID.Store(id)
}

func (p *dataCoordConfig) GetNodeID() UniqueID {
	val := p.NodeID.Load()
	if val != nil {
		return val.(UniqueID)
	}
	return 0
}

1065 1066 1067
///////////////////////////////////////////////////////////////////////////////
// --- datanode ---
type dataNodeConfig struct {
1068
	Base *BaseTable
1069

X
Xiaofan 已提交
1070 1071 1072
	// ID of the current node
	//NodeID atomic.Value
	NodeID atomic.Value
1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092
	// IP of the current DataNode
	IP string

	// Port of the current DataNode
	Port                    int
	FlowGraphMaxQueueLength int32
	FlowGraphMaxParallelism int32
	FlushInsertBufferSize   int64
	InsertBinlogRootPath    string
	StatsBinlogRootPath     string
	DeleteBinlogRootPath    string
	Alias                   string // Different datanode in one machine

	// etcd
	ChannelWatchSubPath string

	CreatedTime time.Time
	UpdatedTime time.Time
}

1093 1094
func (p *dataNodeConfig) init(base *BaseTable) {
	p.Base = base
X
Xiaofan 已提交
1095
	p.NodeID.Store(UniqueID(0))
1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111
	p.initFlowGraphMaxQueueLength()
	p.initFlowGraphMaxParallelism()
	p.initFlushInsertBufferSize()
	p.initInsertBinlogRootPath()
	p.initStatsBinlogRootPath()
	p.initDeleteBinlogRootPath()

	p.initChannelWatchPath()
}

// InitAlias init this DataNode alias
func (p *dataNodeConfig) InitAlias(alias string) {
	p.Alias = alias
}

func (p *dataNodeConfig) initFlowGraphMaxQueueLength() {
1112
	p.FlowGraphMaxQueueLength = p.Base.ParseInt32WithDefault("dataNode.dataSync.flowGraph.maxQueueLength", 1024)
1113 1114 1115
}

func (p *dataNodeConfig) initFlowGraphMaxParallelism() {
1116
	p.FlowGraphMaxParallelism = p.Base.ParseInt32WithDefault("dataNode.dataSync.flowGraph.maxParallelism", 1024)
1117 1118 1119
}

func (p *dataNodeConfig) initFlushInsertBufferSize() {
1120
	p.FlushInsertBufferSize = p.Base.ParseInt64("_DATANODE_INSERTBUFSIZE")
1121 1122 1123
}

func (p *dataNodeConfig) initInsertBinlogRootPath() {
1124
	// GOOSE TODO: rootPath change to TenentID
1125
	rootPath, err := p.Base.Load("minio.rootPath")
1126 1127 1128 1129 1130 1131 1132
	if err != nil {
		panic(err)
	}
	p.InsertBinlogRootPath = path.Join(rootPath, "insert_log")
}

func (p *dataNodeConfig) initStatsBinlogRootPath() {
1133
	rootPath, err := p.Base.Load("minio.rootPath")
1134 1135 1136 1137 1138 1139 1140
	if err != nil {
		panic(err)
	}
	p.StatsBinlogRootPath = path.Join(rootPath, "stats_log")
}

func (p *dataNodeConfig) initDeleteBinlogRootPath() {
1141
	rootPath, err := p.Base.Load("minio.rootPath")
1142 1143 1144 1145 1146 1147 1148 1149 1150 1151
	if err != nil {
		panic(err)
	}
	p.DeleteBinlogRootPath = path.Join(rootPath, "delta_log")
}

func (p *dataNodeConfig) initChannelWatchPath() {
	p.ChannelWatchSubPath = "channelwatch"
}

X
Xiaofan 已提交
1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163
func (p *dataNodeConfig) SetNodeID(id UniqueID) {
	p.NodeID.Store(id)
}

func (p *dataNodeConfig) GetNodeID() UniqueID {
	val := p.NodeID.Load()
	if val != nil {
		return val.(UniqueID)
	}
	return 0
}

1164 1165 1166
///////////////////////////////////////////////////////////////////////////////
// --- indexcoord ---
type indexCoordConfig struct {
1167
	Base *BaseTable
1168 1169 1170 1171 1172 1173 1174 1175 1176 1177

	Address string
	Port    int

	IndexStorageRootPath string

	CreatedTime time.Time
	UpdatedTime time.Time
}

1178 1179
func (p *indexCoordConfig) init(base *BaseTable) {
	p.Base = base
1180 1181 1182 1183 1184 1185

	p.initIndexStorageRootPath()
}

// initIndexStorageRootPath initializes the root path of index files.
func (p *indexCoordConfig) initIndexStorageRootPath() {
1186
	rootPath, err := p.Base.Load("minio.rootPath")
1187 1188 1189 1190 1191 1192 1193 1194 1195
	if err != nil {
		panic(err)
	}
	p.IndexStorageRootPath = path.Join(rootPath, "index_files")
}

///////////////////////////////////////////////////////////////////////////////
// --- indexnode ---
type indexNodeConfig struct {
1196
	Base *BaseTable
1197 1198 1199 1200 1201

	IP      string
	Address string
	Port    int

X
Xiaofan 已提交
1202 1203 1204
	NodeID atomic.Value

	Alias string
1205 1206 1207 1208 1209 1210 1211

	IndexStorageRootPath string

	CreatedTime time.Time
	UpdatedTime time.Time
}

1212 1213
func (p *indexNodeConfig) init(base *BaseTable) {
	p.Base = base
X
Xiaofan 已提交
1214
	p.NodeID.Store(UniqueID(0))
1215 1216 1217 1218 1219 1220 1221 1222 1223
	p.initIndexStorageRootPath()
}

// InitAlias initializes an alias for the IndexNode role.
func (p *indexNodeConfig) InitAlias(alias string) {
	p.Alias = alias
}

func (p *indexNodeConfig) initIndexStorageRootPath() {
1224
	rootPath, err := p.Base.Load("minio.rootPath")
1225 1226 1227 1228 1229
	if err != nil {
		panic(err)
	}
	p.IndexStorageRootPath = path.Join(rootPath, "index_files")
}
X
Xiaofan 已提交
1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241

func (p *indexNodeConfig) SetNodeID(id UniqueID) {
	p.NodeID.Store(id)
}

func (p *indexNodeConfig) GetNodeID() UniqueID {
	val := p.NodeID.Load()
	if val != nil {
		return val.(UniqueID)
	}
	return 0
}