2021-04-19 10:09:43 +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-22 14:40:07 +08:00
|
|
|
package proxy
|
2021-01-22 09:36:18 +08:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2021-03-08 10:09:48 +08:00
|
|
|
"errors"
|
2021-01-22 09:36:18 +08:00
|
|
|
"math/rand"
|
|
|
|
"sync"
|
2021-03-04 22:27:12 +08:00
|
|
|
"sync/atomic"
|
2021-01-22 09:36:18 +08:00
|
|
|
"time"
|
|
|
|
|
2021-09-03 17:15:26 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/util/metricsinfo"
|
|
|
|
|
2021-07-21 11:26:11 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/metrics"
|
|
|
|
|
2021-03-08 19:39:36 +08:00
|
|
|
"go.uber.org/zap"
|
|
|
|
|
2021-04-22 14:45:57 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/allocator"
|
|
|
|
"github.com/milvus-io/milvus/internal/log"
|
|
|
|
"github.com/milvus-io/milvus/internal/msgstream"
|
|
|
|
"github.com/milvus-io/milvus/internal/proto/commonpb"
|
|
|
|
"github.com/milvus-io/milvus/internal/proto/internalpb"
|
2021-06-15 12:41:40 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/proto/querypb"
|
2021-04-22 14:45:57 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/types"
|
|
|
|
"github.com/milvus-io/milvus/internal/util/funcutil"
|
2021-05-21 19:28:52 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/util/sessionutil"
|
2021-04-22 14:45:57 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/util/typeutil"
|
2021-01-22 09:36:18 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
type UniqueID = typeutil.UniqueID
|
|
|
|
type Timestamp = typeutil.Timestamp
|
|
|
|
|
2021-06-15 10:19:38 +08:00
|
|
|
const sendTimeTickMsgInterval = 200 * time.Millisecond
|
|
|
|
const channelMgrTickerInterval = 100 * time.Millisecond
|
|
|
|
|
2021-10-04 17:28:30 +08:00
|
|
|
// make sure Proxy implements types.Proxy
|
|
|
|
var _ types.Proxy = (*Proxy)(nil)
|
|
|
|
|
2021-06-22 14:40:07 +08:00
|
|
|
type Proxy struct {
|
2021-01-22 09:36:18 +08:00
|
|
|
ctx context.Context
|
|
|
|
cancel func()
|
|
|
|
wg sync.WaitGroup
|
|
|
|
|
2021-03-12 14:22:09 +08:00
|
|
|
initParams *internalpb.InitParams
|
2021-01-28 20:51:44 +08:00
|
|
|
ip string
|
|
|
|
port int
|
2021-01-22 09:36:18 +08:00
|
|
|
|
2021-03-04 22:27:12 +08:00
|
|
|
stateCode atomic.Value
|
2021-01-29 09:27:26 +08:00
|
|
|
|
2021-06-22 16:44:09 +08:00
|
|
|
rootCoord types.RootCoord
|
|
|
|
indexCoord types.IndexCoord
|
|
|
|
dataCoord types.DataCoord
|
|
|
|
queryCoord types.QueryCoord
|
2021-01-28 20:51:44 +08:00
|
|
|
|
2021-05-27 17:09:50 +08:00
|
|
|
chMgr channelsMgr
|
|
|
|
|
2021-09-06 20:49:04 +08:00
|
|
|
sched *taskScheduler
|
2021-01-22 09:36:18 +08:00
|
|
|
|
2021-05-29 09:55:29 +08:00
|
|
|
chTicker channelsTimeTicker
|
|
|
|
|
2021-01-22 09:36:18 +08:00
|
|
|
idAllocator *allocator.IDAllocator
|
2021-10-13 21:44:37 +08:00
|
|
|
tsoAllocator *timestampAllocator
|
2021-10-02 18:43:56 +08:00
|
|
|
segAssigner *segIDAssigner
|
2021-01-22 09:36:18 +08:00
|
|
|
|
2021-09-03 17:15:26 +08:00
|
|
|
metricsCacheManager *metricsinfo.MetricsCacheManager
|
|
|
|
|
2021-05-21 19:28:52 +08:00
|
|
|
session *sessionutil.Session
|
|
|
|
|
2021-06-18 10:33:58 +08:00
|
|
|
msFactory msgstream.Factory
|
2021-01-22 09:36:18 +08:00
|
|
|
|
|
|
|
// Add callback functions at different stages
|
|
|
|
startCallbacks []func()
|
|
|
|
closeCallbacks []func()
|
|
|
|
}
|
|
|
|
|
2021-10-07 20:24:40 +08:00
|
|
|
// NewProxy returns a Proxy struct.
|
2021-06-22 14:40:07 +08:00
|
|
|
func NewProxy(ctx context.Context, factory msgstream.Factory) (*Proxy, error) {
|
2021-01-22 09:36:18 +08:00
|
|
|
rand.Seed(time.Now().UnixNano())
|
|
|
|
ctx1, cancel := context.WithCancel(ctx)
|
2021-06-22 14:40:07 +08:00
|
|
|
node := &Proxy{
|
2021-02-08 14:30:54 +08:00
|
|
|
ctx: ctx1,
|
|
|
|
cancel: cancel,
|
|
|
|
msFactory: factory,
|
2021-01-22 09:36:18 +08:00
|
|
|
}
|
2021-03-12 14:22:09 +08:00
|
|
|
node.UpdateStateCode(internalpb.StateCode_Abnormal)
|
2021-06-22 14:40:07 +08:00
|
|
|
log.Debug("Proxy", zap.Any("State", node.stateCode.Load()))
|
2021-01-22 09:36:18 +08:00
|
|
|
return node, nil
|
2021-01-29 09:27:26 +08:00
|
|
|
|
2021-01-22 09:36:18 +08:00
|
|
|
}
|
|
|
|
|
2021-06-22 14:40:07 +08:00
|
|
|
// Register register proxy at etcd
|
|
|
|
func (node *Proxy) Register() error {
|
2021-06-11 22:04:41 +08:00
|
|
|
node.session = sessionutil.NewSession(node.ctx, Params.MetaRootPath, Params.EtcdEndpoints)
|
2021-06-22 14:40:07 +08:00
|
|
|
node.session.Init(typeutil.ProxyRole, Params.NetworkAddress, false)
|
2021-05-25 15:06:05 +08:00
|
|
|
Params.ProxyID = node.session.ServerID
|
2021-10-01 08:52:50 +08:00
|
|
|
Params.SetLogger(Params.ProxyID)
|
2021-07-08 19:52:39 +08:00
|
|
|
Params.initProxySubName()
|
2021-10-27 21:58:33 +08:00
|
|
|
go node.session.LivenessCheck(node.ctx, func() {
|
|
|
|
log.Fatal("Proxy disconnected from etcd, process will exit", zap.Int64("Server Id", node.session.ServerID))
|
|
|
|
})
|
2021-09-27 17:37:57 +08:00
|
|
|
// TODO Reset the logger
|
|
|
|
//Params.initLogCfg()
|
2021-05-25 15:06:05 +08:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-10-14 19:14:35 +08:00
|
|
|
// Init initialize proxy.
|
2021-06-22 14:40:07 +08:00
|
|
|
func (node *Proxy) Init() error {
|
2021-06-21 18:22:13 +08:00
|
|
|
// wait for datacoord state changed to Healthy
|
|
|
|
if node.dataCoord != nil {
|
2021-06-22 14:40:07 +08:00
|
|
|
log.Debug("Proxy wait for dataCoord ready")
|
2021-06-21 18:22:13 +08:00
|
|
|
err := funcutil.WaitForComponentHealthy(node.ctx, node.dataCoord, "DataCoord", 1000000, time.Millisecond*200)
|
2021-01-29 09:27:26 +08:00
|
|
|
if err != nil {
|
2021-06-22 14:40:07 +08:00
|
|
|
log.Debug("Proxy wait for dataCoord ready failed", zap.Error(err))
|
2021-01-29 09:27:26 +08:00
|
|
|
return err
|
|
|
|
}
|
2021-06-22 14:40:07 +08:00
|
|
|
log.Debug("Proxy dataCoord is ready")
|
2021-01-29 09:27:26 +08:00
|
|
|
}
|
|
|
|
|
2021-06-23 16:14:08 +08:00
|
|
|
// wait for queryCoord state changed to Healthy
|
2021-06-22 16:44:09 +08:00
|
|
|
if node.queryCoord != nil {
|
|
|
|
log.Debug("Proxy wait for queryCoord ready")
|
|
|
|
err := funcutil.WaitForComponentHealthy(node.ctx, node.queryCoord, "QueryCoord", 1000000, time.Millisecond*200)
|
2021-01-29 09:27:26 +08:00
|
|
|
if err != nil {
|
2021-06-22 16:44:09 +08:00
|
|
|
log.Debug("Proxy wait for queryCoord ready failed", zap.Error(err))
|
2021-01-29 09:27:26 +08:00
|
|
|
return err
|
|
|
|
}
|
2021-06-22 16:44:09 +08:00
|
|
|
log.Debug("Proxy queryCoord is ready")
|
2021-01-29 09:27:26 +08:00
|
|
|
}
|
|
|
|
|
2021-06-21 17:28:03 +08:00
|
|
|
// wait for indexcoord state changed to Healthy
|
|
|
|
if node.indexCoord != nil {
|
2021-06-22 14:40:07 +08:00
|
|
|
log.Debug("Proxy wait for indexCoord ready")
|
2021-06-21 17:28:03 +08:00
|
|
|
err := funcutil.WaitForComponentHealthy(node.ctx, node.indexCoord, "IndexCoord", 1000000, time.Millisecond*200)
|
2021-01-29 09:27:26 +08:00
|
|
|
if err != nil {
|
2021-06-22 14:40:07 +08:00
|
|
|
log.Debug("Proxy wait for indexCoord ready failed", zap.Error(err))
|
2021-01-29 09:27:26 +08:00
|
|
|
return err
|
|
|
|
}
|
2021-06-22 14:40:07 +08:00
|
|
|
log.Debug("Proxy indexCoord is ready")
|
2021-01-29 09:27:26 +08:00
|
|
|
}
|
|
|
|
|
2021-06-22 16:44:09 +08:00
|
|
|
if node.queryCoord != nil {
|
|
|
|
resp, err := node.queryCoord.CreateQueryChannel(node.ctx, &querypb.CreateQueryChannelRequest{})
|
2021-01-29 09:27:26 +08:00
|
|
|
if err != nil {
|
2021-06-22 14:40:07 +08:00
|
|
|
log.Debug("Proxy CreateQueryChannel failed", zap.Error(err))
|
2021-01-29 09:27:26 +08:00
|
|
|
return err
|
|
|
|
}
|
2021-03-10 22:06:22 +08:00
|
|
|
if resp.Status.ErrorCode != commonpb.ErrorCode_Success {
|
2021-06-22 14:40:07 +08:00
|
|
|
log.Debug("Proxy CreateQueryChannel failed", zap.String("reason", resp.Status.Reason))
|
2021-06-03 14:58:34 +08:00
|
|
|
|
2021-01-29 09:27:26 +08:00
|
|
|
return errors.New(resp.Status.Reason)
|
|
|
|
}
|
2021-06-22 14:40:07 +08:00
|
|
|
log.Debug("Proxy CreateQueryChannel success")
|
2021-01-29 09:27:26 +08:00
|
|
|
|
2021-09-23 10:53:53 +08:00
|
|
|
// TODO SearchResultChannelNames and RetrieveResultChannelNames should not be part in the Param table
|
|
|
|
// we should maintain a separate map for search result
|
2021-01-29 09:27:26 +08:00
|
|
|
Params.SearchResultChannelNames = []string{resp.ResultChannel}
|
2021-05-29 11:19:30 +08:00
|
|
|
Params.RetrieveResultChannelNames = []string{resp.ResultChannel}
|
2021-06-22 14:40:07 +08:00
|
|
|
log.Debug("Proxy CreateQueryChannel success", zap.Any("SearchResultChannelNames", Params.SearchResultChannelNames))
|
|
|
|
log.Debug("Proxy CreateQueryChannel success", zap.Any("RetrieveResultChannelNames", Params.RetrieveResultChannelNames))
|
2021-01-29 09:27:26 +08:00
|
|
|
}
|
|
|
|
|
2021-02-08 14:30:54 +08:00
|
|
|
m := map[string]interface{}{
|
2021-04-23 10:10:46 +08:00
|
|
|
"PulsarAddress": Params.PulsarAddress,
|
|
|
|
"PulsarBufSize": 1024}
|
2021-06-11 13:24:11 +08:00
|
|
|
err := node.msFactory.SetParams(m)
|
2021-02-08 14:30:54 +08:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2021-09-03 09:44:10 +08:00
|
|
|
idAllocator, err := allocator.NewIDAllocator(node.ctx, node.rootCoord, Params.ProxyID)
|
2021-01-22 09:36:18 +08:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2021-09-03 09:44:10 +08:00
|
|
|
|
2021-01-22 09:36:18 +08:00
|
|
|
node.idAllocator = idAllocator
|
|
|
|
|
2021-10-13 21:44:37 +08:00
|
|
|
tsoAllocator, err := newTimestampAllocator(node.ctx, node.rootCoord, Params.ProxyID)
|
2021-01-22 09:36:18 +08:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
node.tsoAllocator = tsoAllocator
|
|
|
|
|
2021-09-28 23:06:15 +08:00
|
|
|
segAssigner, err := newSegIDAssigner(node.ctx, node.dataCoord, node.lastTick)
|
2021-01-22 09:36:18 +08:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
node.segAssigner = segAssigner
|
2021-01-28 20:51:44 +08:00
|
|
|
node.segAssigner.PeerID = Params.ProxyID
|
2021-01-22 09:36:18 +08:00
|
|
|
|
2021-09-13 17:12:19 +08:00
|
|
|
dmlChannelsFunc := getDmlChannelsFunc(node.ctx, node.rootCoord)
|
|
|
|
dqlChannelsFunc := getDqlChannelsFunc(node.ctx, node.session.ServerID, node.queryCoord)
|
|
|
|
chMgr := newChannelsMgrImpl(dmlChannelsFunc, defaultInsertRepackFunc, dqlChannelsFunc, nil, node.msFactory)
|
2021-05-27 17:09:50 +08:00
|
|
|
node.chMgr = chMgr
|
|
|
|
|
2021-09-06 20:49:04 +08:00
|
|
|
node.sched, err = newTaskScheduler(node.ctx, node.idAllocator, node.tsoAllocator, node.msFactory)
|
2021-01-22 09:36:18 +08:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2021-06-15 10:19:38 +08:00
|
|
|
node.chTicker = newChannelsTimeTicker(node.ctx, channelMgrTickerInterval, []string{}, node.sched.getPChanStatistics, tsoAllocator)
|
2021-05-29 09:55:29 +08:00
|
|
|
|
2021-09-03 17:15:26 +08:00
|
|
|
node.metricsCacheManager = metricsinfo.NewMetricsCacheManager()
|
|
|
|
|
2021-01-22 09:36:18 +08:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-10-19 14:16:58 +08:00
|
|
|
// sendChannelsTimeTickLoop starts a goroutine that synchronize the time tick information.
|
2021-06-22 14:40:07 +08:00
|
|
|
func (node *Proxy) sendChannelsTimeTickLoop() {
|
2021-05-31 17:28:31 +08:00
|
|
|
node.wg.Add(1)
|
|
|
|
go func() {
|
|
|
|
defer node.wg.Done()
|
|
|
|
|
|
|
|
// TODO(dragondriver): read this from config
|
2021-06-15 10:19:38 +08:00
|
|
|
timer := time.NewTicker(sendTimeTickMsgInterval)
|
2021-05-31 17:28:31 +08:00
|
|
|
|
|
|
|
for {
|
|
|
|
select {
|
|
|
|
case <-node.ctx.Done():
|
|
|
|
return
|
|
|
|
case <-timer.C:
|
2021-06-18 15:14:08 +08:00
|
|
|
ts, err := node.tsoAllocator.AllocOne()
|
|
|
|
if err != nil {
|
|
|
|
log.Warn("Failed to get timestamp from tso", zap.Error(err))
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2021-05-31 17:28:31 +08:00
|
|
|
stats, err := node.chTicker.getMinTsStatistics()
|
|
|
|
if err != nil {
|
|
|
|
log.Warn("sendChannelsTimeTickLoop.getMinTsStatistics", zap.Error(err))
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2021-06-08 19:25:37 +08:00
|
|
|
channels := make([]pChan, 0, len(stats))
|
|
|
|
tss := make([]Timestamp, 0, len(stats))
|
|
|
|
|
2021-06-18 15:14:08 +08:00
|
|
|
maxTs := ts
|
2021-06-08 19:25:37 +08:00
|
|
|
for channel, ts := range stats {
|
|
|
|
channels = append(channels, channel)
|
|
|
|
tss = append(tss, ts)
|
2021-06-18 15:14:08 +08:00
|
|
|
if ts > maxTs {
|
|
|
|
maxTs = ts
|
|
|
|
}
|
2021-06-08 19:25:37 +08:00
|
|
|
}
|
2021-06-18 15:14:08 +08:00
|
|
|
|
2021-05-31 17:28:31 +08:00
|
|
|
req := &internalpb.ChannelTimeTickMsg{
|
|
|
|
Base: &commonpb.MsgBase{
|
2021-06-08 19:25:37 +08:00
|
|
|
MsgType: commonpb.MsgType_TimeTick, // todo
|
|
|
|
MsgID: 0, // todo
|
|
|
|
Timestamp: 0, // todo
|
2021-05-31 17:28:31 +08:00
|
|
|
SourceID: node.session.ServerID,
|
|
|
|
},
|
2021-06-18 15:14:08 +08:00
|
|
|
ChannelNames: channels,
|
|
|
|
Timestamps: tss,
|
|
|
|
DefaultTimestamp: maxTs,
|
2021-05-31 17:28:31 +08:00
|
|
|
}
|
|
|
|
|
2021-07-21 11:26:11 +08:00
|
|
|
for idx, channel := range channels {
|
|
|
|
ts := tss[idx]
|
|
|
|
metrics.ProxyDmlChannelTimeTick.WithLabelValues(channel).Set(float64(ts))
|
|
|
|
}
|
|
|
|
metrics.ProxyDmlChannelTimeTick.WithLabelValues("DefaultTimestamp").Set(float64(maxTs))
|
|
|
|
|
2021-06-21 17:28:03 +08:00
|
|
|
status, err := node.rootCoord.UpdateChannelTimeTick(node.ctx, req)
|
2021-05-31 17:28:31 +08:00
|
|
|
if err != nil {
|
|
|
|
log.Warn("sendChannelsTimeTickLoop.UpdateChannelTimeTick", zap.Error(err))
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if status.ErrorCode != 0 {
|
|
|
|
log.Warn("sendChannelsTimeTickLoop.UpdateChannelTimeTick",
|
|
|
|
zap.Any("ErrorCode", status.ErrorCode),
|
|
|
|
zap.Any("Reason", status.Reason))
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
}
|
|
|
|
|
2021-10-16 22:06:57 +08:00
|
|
|
// Start starts a proxy node.
|
2021-06-22 14:40:07 +08:00
|
|
|
func (node *Proxy) Start() error {
|
2021-06-21 17:28:03 +08:00
|
|
|
err := InitMetaCache(node.rootCoord)
|
2021-01-31 14:55:36 +08:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2021-03-08 19:39:36 +08:00
|
|
|
log.Debug("init global meta cache ...")
|
2021-01-31 14:55:36 +08:00
|
|
|
|
2021-09-09 10:06:29 +08:00
|
|
|
if err := node.sched.Start(); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2021-03-08 19:39:36 +08:00
|
|
|
log.Debug("start scheduler ...")
|
2021-01-29 17:29:31 +08:00
|
|
|
|
2021-09-09 10:06:29 +08:00
|
|
|
if err := node.idAllocator.Start(); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2021-03-08 19:39:36 +08:00
|
|
|
log.Debug("start id allocator ...")
|
2021-01-29 17:29:31 +08:00
|
|
|
|
2021-09-09 10:06:29 +08:00
|
|
|
if err := node.segAssigner.Start(); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2021-03-08 19:39:36 +08:00
|
|
|
log.Debug("start seg assigner ...")
|
2021-01-29 17:29:31 +08:00
|
|
|
|
2021-05-29 09:55:29 +08:00
|
|
|
err = node.chTicker.start()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
log.Debug("start channelsTimeTicker")
|
|
|
|
|
2021-05-31 17:28:31 +08:00
|
|
|
node.sendChannelsTimeTickLoop()
|
|
|
|
|
2021-01-22 09:36:18 +08:00
|
|
|
// Start callbacks
|
|
|
|
for _, cb := range node.startCallbacks {
|
|
|
|
cb()
|
|
|
|
}
|
|
|
|
|
2021-10-12 19:31:25 +08:00
|
|
|
Params.CreatedTime = time.Now()
|
|
|
|
Params.UpdatedTime = time.Now()
|
|
|
|
|
2021-03-12 14:22:09 +08:00
|
|
|
node.UpdateStateCode(internalpb.StateCode_Healthy)
|
2021-06-22 14:40:07 +08:00
|
|
|
log.Debug("Proxy", zap.Any("State", node.stateCode.Load()))
|
2021-03-04 22:27:12 +08:00
|
|
|
|
2021-01-22 09:36:18 +08:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-10-16 22:08:52 +08:00
|
|
|
// Stop stops a proxy node.
|
2021-06-22 14:40:07 +08:00
|
|
|
func (node *Proxy) Stop() error {
|
2021-01-22 09:36:18 +08:00
|
|
|
node.cancel()
|
|
|
|
|
2021-06-22 17:40:07 +08:00
|
|
|
if node.idAllocator != nil {
|
|
|
|
node.idAllocator.Close()
|
|
|
|
}
|
|
|
|
if node.segAssigner != nil {
|
|
|
|
node.segAssigner.Close()
|
|
|
|
}
|
|
|
|
if node.sched != nil {
|
|
|
|
node.sched.Close()
|
|
|
|
}
|
|
|
|
if node.chTicker != nil {
|
|
|
|
err := node.chTicker.close()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2021-05-29 09:55:29 +08:00
|
|
|
}
|
2021-01-22 09:36:18 +08:00
|
|
|
|
|
|
|
node.wg.Wait()
|
|
|
|
|
|
|
|
for _, cb := range node.closeCallbacks {
|
|
|
|
cb()
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddStartCallback adds a callback in the startServer phase.
|
2021-06-22 14:40:07 +08:00
|
|
|
func (node *Proxy) AddStartCallback(callbacks ...func()) {
|
2021-01-22 09:36:18 +08:00
|
|
|
node.startCallbacks = append(node.startCallbacks, callbacks...)
|
|
|
|
}
|
|
|
|
|
2021-06-22 14:40:07 +08:00
|
|
|
func (node *Proxy) lastTick() Timestamp {
|
2021-09-26 19:23:56 +08:00
|
|
|
return node.chTicker.getMinTick()
|
2021-01-22 09:36:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// AddCloseCallback adds a callback in the Close phase.
|
2021-06-22 14:40:07 +08:00
|
|
|
func (node *Proxy) AddCloseCallback(callbacks ...func()) {
|
2021-01-22 09:36:18 +08:00
|
|
|
node.closeCallbacks = append(node.closeCallbacks, callbacks...)
|
|
|
|
}
|
2021-01-29 09:27:26 +08:00
|
|
|
|
2021-10-16 21:40:53 +08:00
|
|
|
// SetRootCoordClient set rootcoord client for proxy.
|
2021-06-22 14:40:07 +08:00
|
|
|
func (node *Proxy) SetRootCoordClient(cli types.RootCoord) {
|
2021-06-21 17:28:03 +08:00
|
|
|
node.rootCoord = cli
|
2021-01-29 09:27:26 +08:00
|
|
|
}
|
|
|
|
|
2021-06-22 14:40:07 +08:00
|
|
|
func (node *Proxy) SetIndexCoordClient(cli types.IndexCoord) {
|
2021-06-21 17:28:03 +08:00
|
|
|
node.indexCoord = cli
|
2021-01-29 09:27:26 +08:00
|
|
|
}
|
|
|
|
|
2021-06-22 14:40:07 +08:00
|
|
|
func (node *Proxy) SetDataCoordClient(cli types.DataCoord) {
|
2021-06-21 18:22:13 +08:00
|
|
|
node.dataCoord = cli
|
2021-01-29 09:27:26 +08:00
|
|
|
}
|
|
|
|
|
2021-06-22 16:44:09 +08:00
|
|
|
func (node *Proxy) SetQueryCoordClient(cli types.QueryCoord) {
|
|
|
|
node.queryCoord = cli
|
2021-01-29 09:27:26 +08:00
|
|
|
}
|