未验证 提交 f0fe8dae 编写于 作者: C congqixia 提交者: GitHub

Close Node/Segment detector when close ShardCluster (#18476)

Signed-off-by: NCongqi Xia <congqi.xia@zilliz.com>
上级 3871758c
......@@ -102,13 +102,20 @@ type shardSegmentInfo struct {
inUse int32
}
// Closable interface for close.
type Closable interface {
Close()
}
// ShardNodeDetector provides method to detect node events
type ShardNodeDetector interface {
Closable
watchNodes(collectionID int64, replicaID int64, vchannelName string) ([]nodeEvent, <-chan nodeEvent)
}
// ShardSegmentDetector provides method to detect segment events
type ShardSegmentDetector interface {
Closable
watchSegments(collectionID int64, replicaID int64, vchannelName string) ([]segmentEvent, <-chan segmentEvent)
}
......@@ -181,6 +188,13 @@ func (sc *ShardCluster) Close() {
log.Info("Close shard cluster")
sc.closeOnce.Do(func() {
sc.updateShardClusterState(unavailable)
if sc.nodeDetector != nil {
sc.nodeDetector.Close()
}
if sc.segmentDetector != nil {
sc.segmentDetector.Close()
}
close(sc.closeCh)
})
}
......
......@@ -38,6 +38,8 @@ func (m *mockNodeDetector) watchNodes(collectionID int64, replicaID int64, vchan
return m.initNodes, m.evtCh
}
func (m *mockNodeDetector) Close() {}
type mockSegmentDetector struct {
initSegments []segmentEvent
evtCh chan segmentEvent
......@@ -47,6 +49,8 @@ func (m *mockSegmentDetector) watchSegments(collectionID int64, replicaID int64,
return m.initSegments, m.evtCh
}
func (m *mockSegmentDetector) Close() {}
type mockShardQueryNode struct {
statisticResponse *internalpb.GetStatisticsResponse
statisticErr error
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册