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