mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-11 09:46:26 +08:00
626854cf0c
Signed-off-by: sunby <bingyi.sun@zilliz.com> Co-authored-by: yah01 <yang.cen@zilliz.com> Co-authored-by: Wei Liu <wei.liu@zilliz.com> Co-authored-by: Congqi Xia <congqi.xia@zilliz.com> Signed-off-by: sunby <bingyi.sun@zilliz.com> Co-authored-by: sunby <bingyi.sun@zilliz.com> Co-authored-by: yah01 <yang.cen@zilliz.com> Co-authored-by: Wei Liu <wei.liu@zilliz.com> Co-authored-by: Congqi Xia <congqi.xia@zilliz.com>
36 lines
977 B
Go
36 lines
977 B
Go
package job
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/milvus-io/milvus/internal/querycoordv2/meta"
|
|
"github.com/milvus-io/milvus/internal/util/typeutil"
|
|
"github.com/samber/lo"
|
|
)
|
|
|
|
// waitCollectionReleased blocks until
|
|
// all channels and segments of given collection(partitions) are released,
|
|
// empty partition list means wait for collection released
|
|
func waitCollectionReleased(dist *meta.DistributionManager, collection int64, partitions ...int64) {
|
|
partitionSet := typeutil.NewUniqueSet(partitions...)
|
|
for {
|
|
var (
|
|
channels []*meta.DmChannel
|
|
segments []*meta.Segment = dist.SegmentDistManager.GetByCollection(collection)
|
|
)
|
|
if partitionSet.Len() > 0 {
|
|
segments = lo.Filter(segments, func(segment *meta.Segment, _ int) bool {
|
|
return partitionSet.Contain(segment.GetPartitionID())
|
|
})
|
|
} else {
|
|
channels = dist.ChannelDistManager.GetByCollection(collection)
|
|
}
|
|
|
|
if len(channels)+len(segments) == 0 {
|
|
break
|
|
}
|
|
|
|
time.Sleep(200 * time.Millisecond)
|
|
}
|
|
}
|