2021-05-21 09:52:20 +08:00
|
|
|
package proxynode
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
2021-05-27 17:09:50 +08:00
|
|
|
"math/rand"
|
2021-05-21 09:52:20 +08:00
|
|
|
"runtime"
|
|
|
|
"sort"
|
|
|
|
"sync"
|
|
|
|
|
2021-06-08 19:25:37 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/log"
|
2021-05-21 09:52:20 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/msgstream"
|
2021-06-08 19:25:37 +08:00
|
|
|
"go.uber.org/zap"
|
2021-05-21 09:52:20 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
type vChan = string
|
|
|
|
type pChan = string
|
|
|
|
|
|
|
|
type channelsMgr interface {
|
|
|
|
getChannels(collectionID UniqueID) ([]pChan, error)
|
|
|
|
getVChannels(collectionID UniqueID) ([]vChan, error)
|
2021-05-29 15:09:30 +08:00
|
|
|
createDQLStream(collectionID UniqueID) error
|
|
|
|
getDQLStream(collectionID UniqueID) (msgstream.MsgStream, error)
|
|
|
|
removeDQLStream(collectionID UniqueID) error
|
|
|
|
removeAllDQLStream() error
|
2021-05-21 09:52:20 +08:00
|
|
|
createDMLMsgStream(collectionID UniqueID) error
|
|
|
|
getDMLStream(collectionID UniqueID) (msgstream.MsgStream, error)
|
|
|
|
removeDMLStream(collectionID UniqueID) error
|
|
|
|
removeAllDMLStream() error
|
|
|
|
}
|
|
|
|
|
|
|
|
type (
|
|
|
|
uniqueIntGenerator interface {
|
|
|
|
get() int
|
|
|
|
}
|
|
|
|
naiveUniqueIntGenerator struct {
|
|
|
|
now int
|
|
|
|
mtx sync.Mutex
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
func (generator *naiveUniqueIntGenerator) get() int {
|
|
|
|
generator.mtx.Lock()
|
|
|
|
defer func() {
|
|
|
|
generator.now++
|
|
|
|
generator.mtx.Unlock()
|
|
|
|
}()
|
|
|
|
return generator.now
|
|
|
|
}
|
|
|
|
|
|
|
|
func newNaiveUniqueIntGenerator() *naiveUniqueIntGenerator {
|
|
|
|
return &naiveUniqueIntGenerator{
|
|
|
|
now: 0,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var uniqueIntGeneratorIns uniqueIntGenerator
|
|
|
|
var getUniqueIntGeneratorInsOnce sync.Once
|
|
|
|
|
|
|
|
func getUniqueIntGeneratorIns() uniqueIntGenerator {
|
|
|
|
getUniqueIntGeneratorInsOnce.Do(func() {
|
|
|
|
uniqueIntGeneratorIns = newNaiveUniqueIntGenerator()
|
|
|
|
})
|
|
|
|
return uniqueIntGeneratorIns
|
|
|
|
}
|
|
|
|
|
2021-05-29 15:09:30 +08:00
|
|
|
type getChannelsFuncType = func(collectionID UniqueID) (map[vChan]pChan, error)
|
2021-06-18 10:33:58 +08:00
|
|
|
type repackFuncType = func(tsMsgs []msgstream.TsMsg, hashKeys [][]int32) (map[int32]*msgstream.MsgPack, error)
|
2021-05-29 15:09:30 +08:00
|
|
|
|
2021-05-31 17:28:31 +08:00
|
|
|
type getChannelsService interface {
|
2021-05-21 09:52:20 +08:00
|
|
|
GetChannels(collectionID UniqueID) (map[vChan]pChan, error)
|
|
|
|
}
|
|
|
|
|
2021-05-31 17:28:31 +08:00
|
|
|
type mockGetChannelsService struct {
|
2021-05-27 17:09:50 +08:00
|
|
|
collectionID2Channels map[UniqueID]map[vChan]pChan
|
|
|
|
}
|
|
|
|
|
2021-05-31 17:28:31 +08:00
|
|
|
func newMockGetChannelsService() *mockGetChannelsService {
|
|
|
|
return &mockGetChannelsService{
|
2021-05-27 17:09:50 +08:00
|
|
|
collectionID2Channels: make(map[UniqueID]map[vChan]pChan),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func genUniqueStr() string {
|
|
|
|
l := rand.Uint64()%100 + 1
|
|
|
|
b := make([]byte, l)
|
|
|
|
if _, err := rand.Read(b); err != nil {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
return fmt.Sprintf("%X", b)
|
|
|
|
}
|
|
|
|
|
2021-05-31 17:28:31 +08:00
|
|
|
func (m *mockGetChannelsService) GetChannels(collectionID UniqueID) (map[vChan]pChan, error) {
|
2021-05-29 15:09:30 +08:00
|
|
|
channels, ok := m.collectionID2Channels[collectionID]
|
|
|
|
if ok {
|
|
|
|
return channels, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
channels = make(map[vChan]pChan)
|
|
|
|
l := rand.Uint64()%10 + 1
|
|
|
|
for i := 0; uint64(i) < l; i++ {
|
|
|
|
channels[genUniqueStr()] = genUniqueStr()
|
|
|
|
}
|
|
|
|
|
|
|
|
m.collectionID2Channels[collectionID] = channels
|
|
|
|
return channels, nil
|
|
|
|
}
|
|
|
|
|
2021-06-18 10:33:58 +08:00
|
|
|
type streamType int
|
|
|
|
|
|
|
|
const (
|
|
|
|
dmlStreamType streamType = iota
|
|
|
|
dqlStreamType
|
|
|
|
)
|
|
|
|
|
2021-05-29 15:09:30 +08:00
|
|
|
type singleTypeChannelsMgr struct {
|
2021-05-21 09:52:20 +08:00
|
|
|
collectionID2VIDs map[UniqueID][]int // id are sorted
|
|
|
|
collMtx sync.RWMutex
|
|
|
|
|
|
|
|
id2vchans map[int][]vChan
|
|
|
|
id2vchansMtx sync.RWMutex
|
|
|
|
|
2021-05-29 15:09:30 +08:00
|
|
|
id2Stream map[int]msgstream.MsgStream
|
|
|
|
id2UsageHistogramOfStream map[int]int
|
|
|
|
streamMtx sync.RWMutex
|
2021-05-21 09:52:20 +08:00
|
|
|
|
|
|
|
vchans2pchans map[vChan]pChan
|
|
|
|
vchans2pchansMtx sync.RWMutex
|
|
|
|
|
2021-05-29 15:09:30 +08:00
|
|
|
getChannelsFunc getChannelsFuncType
|
2021-05-21 09:52:20 +08:00
|
|
|
|
2021-06-18 10:33:58 +08:00
|
|
|
repackFunc repackFuncType
|
|
|
|
|
|
|
|
singleStreamType streamType
|
|
|
|
|
2021-05-21 09:52:20 +08:00
|
|
|
msgStreamFactory msgstream.Factory
|
|
|
|
}
|
|
|
|
|
|
|
|
func getAllKeys(m map[vChan]pChan) []vChan {
|
|
|
|
keys := make([]vChan, 0, len(m))
|
|
|
|
for key := range m {
|
|
|
|
keys = append(keys, key)
|
|
|
|
}
|
|
|
|
return keys
|
|
|
|
}
|
|
|
|
|
|
|
|
func getAllValues(m map[vChan]pChan) []pChan {
|
|
|
|
values := make([]pChan, 0, len(m))
|
|
|
|
for _, value := range m {
|
|
|
|
values = append(values, value)
|
|
|
|
}
|
|
|
|
return values
|
|
|
|
}
|
|
|
|
|
2021-05-29 15:09:30 +08:00
|
|
|
func (mgr *singleTypeChannelsMgr) getLatestVID(collectionID UniqueID) (int, error) {
|
2021-05-21 09:52:20 +08:00
|
|
|
mgr.collMtx.RLock()
|
|
|
|
defer mgr.collMtx.RUnlock()
|
|
|
|
|
|
|
|
ids, ok := mgr.collectionID2VIDs[collectionID]
|
|
|
|
if !ok || len(ids) <= 0 {
|
|
|
|
return 0, fmt.Errorf("collection %d not found", collectionID)
|
|
|
|
}
|
|
|
|
|
|
|
|
return ids[len(ids)-1], nil
|
|
|
|
}
|
|
|
|
|
2021-05-29 15:09:30 +08:00
|
|
|
func (mgr *singleTypeChannelsMgr) getAllVIDs(collectionID UniqueID) ([]int, error) {
|
2021-05-21 09:52:20 +08:00
|
|
|
mgr.collMtx.RLock()
|
|
|
|
defer mgr.collMtx.RUnlock()
|
|
|
|
|
2021-06-08 19:25:37 +08:00
|
|
|
return mgr.collectionID2VIDs[collectionID], nil
|
2021-05-21 09:52:20 +08:00
|
|
|
}
|
|
|
|
|
2021-05-29 15:09:30 +08:00
|
|
|
func (mgr *singleTypeChannelsMgr) getVChansByVID(vid int) ([]vChan, error) {
|
2021-05-21 09:52:20 +08:00
|
|
|
mgr.id2vchansMtx.RLock()
|
|
|
|
defer mgr.id2vchansMtx.RUnlock()
|
|
|
|
|
|
|
|
vchans, ok := mgr.id2vchans[vid]
|
|
|
|
if !ok {
|
|
|
|
return nil, fmt.Errorf("vid %d not found", vid)
|
|
|
|
}
|
|
|
|
|
|
|
|
return vchans, nil
|
|
|
|
}
|
|
|
|
|
2021-05-29 15:09:30 +08:00
|
|
|
func (mgr *singleTypeChannelsMgr) getPChansByVChans(vchans []vChan) ([]pChan, error) {
|
2021-05-21 09:52:20 +08:00
|
|
|
mgr.vchans2pchansMtx.RLock()
|
|
|
|
defer mgr.vchans2pchansMtx.RUnlock()
|
|
|
|
|
|
|
|
pchans := make([]pChan, 0)
|
|
|
|
for _, vchan := range vchans {
|
|
|
|
pchan, ok := mgr.vchans2pchans[vchan]
|
|
|
|
if !ok {
|
|
|
|
return nil, fmt.Errorf("vchan %v not found", vchan)
|
|
|
|
}
|
|
|
|
pchans = append(pchans, pchan)
|
|
|
|
}
|
|
|
|
|
|
|
|
return pchans, nil
|
|
|
|
}
|
|
|
|
|
2021-05-29 15:09:30 +08:00
|
|
|
func (mgr *singleTypeChannelsMgr) updateVChans(vid int, vchans []vChan) {
|
2021-05-21 09:52:20 +08:00
|
|
|
mgr.id2vchansMtx.Lock()
|
|
|
|
defer mgr.id2vchansMtx.Unlock()
|
|
|
|
|
|
|
|
mgr.id2vchans[vid] = vchans
|
|
|
|
}
|
|
|
|
|
2021-05-29 15:09:30 +08:00
|
|
|
func (mgr *singleTypeChannelsMgr) deleteVChansByVID(vid int) {
|
2021-05-21 09:52:20 +08:00
|
|
|
mgr.id2vchansMtx.Lock()
|
|
|
|
defer mgr.id2vchansMtx.Unlock()
|
|
|
|
|
|
|
|
delete(mgr.id2vchans, vid)
|
|
|
|
}
|
|
|
|
|
2021-05-29 15:09:30 +08:00
|
|
|
func (mgr *singleTypeChannelsMgr) deleteVChansByVIDs(vids []int) {
|
2021-05-21 09:52:20 +08:00
|
|
|
mgr.id2vchansMtx.Lock()
|
|
|
|
defer mgr.id2vchansMtx.Unlock()
|
|
|
|
|
|
|
|
for _, vid := range vids {
|
|
|
|
delete(mgr.id2vchans, vid)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-29 15:09:30 +08:00
|
|
|
func (mgr *singleTypeChannelsMgr) deleteStreamByVID(vid int) {
|
|
|
|
mgr.streamMtx.Lock()
|
|
|
|
defer mgr.streamMtx.Unlock()
|
2021-05-21 09:52:20 +08:00
|
|
|
|
2021-05-29 15:09:30 +08:00
|
|
|
delete(mgr.id2Stream, vid)
|
2021-05-21 09:52:20 +08:00
|
|
|
}
|
|
|
|
|
2021-05-29 15:09:30 +08:00
|
|
|
func (mgr *singleTypeChannelsMgr) deleteStreamByVIDs(vids []int) {
|
|
|
|
mgr.streamMtx.Lock()
|
|
|
|
defer mgr.streamMtx.Unlock()
|
2021-05-21 09:52:20 +08:00
|
|
|
|
|
|
|
for _, vid := range vids {
|
2021-05-29 15:09:30 +08:00
|
|
|
delete(mgr.id2Stream, vid)
|
2021-05-21 09:52:20 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-29 15:09:30 +08:00
|
|
|
func (mgr *singleTypeChannelsMgr) updateChannels(channels map[vChan]pChan) {
|
2021-05-21 09:52:20 +08:00
|
|
|
mgr.vchans2pchansMtx.Lock()
|
|
|
|
defer mgr.vchans2pchansMtx.Unlock()
|
|
|
|
|
|
|
|
for vchan, pchan := range channels {
|
|
|
|
mgr.vchans2pchans[vchan] = pchan
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-29 15:09:30 +08:00
|
|
|
func (mgr *singleTypeChannelsMgr) deleteAllChannels() {
|
2021-05-21 09:52:20 +08:00
|
|
|
mgr.vchans2pchansMtx.Lock()
|
|
|
|
defer mgr.vchans2pchansMtx.Unlock()
|
|
|
|
|
|
|
|
mgr.vchans2pchans = nil
|
|
|
|
}
|
|
|
|
|
2021-05-29 15:09:30 +08:00
|
|
|
func (mgr *singleTypeChannelsMgr) deleteAllStream() {
|
2021-05-21 09:52:20 +08:00
|
|
|
mgr.id2vchansMtx.Lock()
|
|
|
|
defer mgr.id2vchansMtx.Unlock()
|
|
|
|
|
2021-05-29 15:09:30 +08:00
|
|
|
mgr.id2UsageHistogramOfStream = nil
|
|
|
|
mgr.id2Stream = nil
|
2021-05-21 09:52:20 +08:00
|
|
|
}
|
|
|
|
|
2021-05-29 15:09:30 +08:00
|
|
|
func (mgr *singleTypeChannelsMgr) deleteAllVChans() {
|
2021-05-21 09:52:20 +08:00
|
|
|
mgr.id2vchansMtx.Lock()
|
|
|
|
defer mgr.id2vchansMtx.Unlock()
|
|
|
|
|
|
|
|
mgr.id2vchans = nil
|
|
|
|
}
|
|
|
|
|
2021-05-29 15:09:30 +08:00
|
|
|
func (mgr *singleTypeChannelsMgr) deleteAllCollection() {
|
2021-05-21 09:52:20 +08:00
|
|
|
mgr.collMtx.Lock()
|
|
|
|
defer mgr.collMtx.Unlock()
|
|
|
|
|
|
|
|
mgr.collectionID2VIDs = nil
|
|
|
|
}
|
|
|
|
|
2021-05-29 15:09:30 +08:00
|
|
|
func (mgr *singleTypeChannelsMgr) addStream(vid int, stream msgstream.MsgStream) {
|
|
|
|
mgr.streamMtx.Lock()
|
|
|
|
defer mgr.streamMtx.Unlock()
|
2021-05-21 09:52:20 +08:00
|
|
|
|
2021-05-29 15:09:30 +08:00
|
|
|
mgr.id2Stream[vid] = stream
|
|
|
|
mgr.id2UsageHistogramOfStream[vid] = 0
|
2021-05-21 09:52:20 +08:00
|
|
|
}
|
|
|
|
|
2021-05-29 15:09:30 +08:00
|
|
|
func (mgr *singleTypeChannelsMgr) updateCollection(collectionID UniqueID, id int) {
|
2021-05-21 09:52:20 +08:00
|
|
|
mgr.collMtx.Lock()
|
|
|
|
defer mgr.collMtx.Unlock()
|
|
|
|
|
|
|
|
vids, ok := mgr.collectionID2VIDs[collectionID]
|
|
|
|
if !ok {
|
|
|
|
mgr.collectionID2VIDs[collectionID] = make([]int, 1)
|
|
|
|
mgr.collectionID2VIDs[collectionID][0] = id
|
|
|
|
} else {
|
|
|
|
vids = append(vids, id)
|
|
|
|
sort.Slice(vids, func(i, j int) bool {
|
|
|
|
return vids[i] < vids[j]
|
|
|
|
})
|
|
|
|
mgr.collectionID2VIDs[collectionID] = vids
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-29 15:09:30 +08:00
|
|
|
func (mgr *singleTypeChannelsMgr) getChannels(collectionID UniqueID) ([]pChan, error) {
|
2021-05-21 09:52:20 +08:00
|
|
|
id, err := mgr.getLatestVID(collectionID)
|
|
|
|
if err == nil {
|
|
|
|
vchans, err := mgr.getVChansByVID(id)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return mgr.getPChansByVChans(vchans)
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO(dragondriver): return error or update channel information from master?
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2021-05-29 15:09:30 +08:00
|
|
|
func (mgr *singleTypeChannelsMgr) getVChannels(collectionID UniqueID) ([]vChan, error) {
|
2021-05-21 09:52:20 +08:00
|
|
|
id, err := mgr.getLatestVID(collectionID)
|
|
|
|
if err == nil {
|
|
|
|
return mgr.getVChansByVID(id)
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO(dragondriver): return error or update channel information from master?
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2021-05-29 15:09:30 +08:00
|
|
|
func (mgr *singleTypeChannelsMgr) createMsgStream(collectionID UniqueID) error {
|
|
|
|
channels, err := mgr.getChannelsFunc(collectionID)
|
2021-06-08 19:25:37 +08:00
|
|
|
log.Debug("singleTypeChannelsMgr", zap.Any("createMsgStream.getChannels", channels))
|
2021-05-21 09:52:20 +08:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
mgr.updateChannels(channels)
|
|
|
|
|
|
|
|
id := getUniqueIntGeneratorIns().get()
|
|
|
|
vchans := getAllKeys(channels)
|
|
|
|
mgr.updateVChans(id, vchans)
|
|
|
|
|
2021-06-18 10:33:58 +08:00
|
|
|
var stream msgstream.MsgStream
|
|
|
|
if mgr.singleStreamType == dqlStreamType {
|
|
|
|
stream, err = mgr.msgStreamFactory.NewQueryMsgStream(context.Background())
|
|
|
|
} else {
|
|
|
|
stream, err = mgr.msgStreamFactory.NewMsgStream(context.Background())
|
|
|
|
}
|
2021-05-21 09:52:20 +08:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
pchans := getAllValues(channels)
|
|
|
|
stream.AsProducer(pchans)
|
2021-06-18 10:33:58 +08:00
|
|
|
if mgr.repackFunc != nil {
|
|
|
|
stream.SetRepackFunc(mgr.repackFunc)
|
2021-05-21 09:52:20 +08:00
|
|
|
}
|
|
|
|
runtime.SetFinalizer(stream, func(stream msgstream.MsgStream) {
|
|
|
|
stream.Close()
|
|
|
|
})
|
2021-05-29 15:09:30 +08:00
|
|
|
mgr.addStream(id, stream)
|
2021-05-21 09:52:20 +08:00
|
|
|
|
|
|
|
mgr.updateCollection(collectionID, id)
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-05-29 15:09:30 +08:00
|
|
|
func (mgr *singleTypeChannelsMgr) getStream(collectionID UniqueID) (msgstream.MsgStream, error) {
|
|
|
|
mgr.streamMtx.RLock()
|
|
|
|
defer mgr.streamMtx.RUnlock()
|
2021-05-21 09:52:20 +08:00
|
|
|
|
|
|
|
vid, err := mgr.getLatestVID(collectionID)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2021-05-29 15:09:30 +08:00
|
|
|
stream, ok := mgr.id2Stream[vid]
|
2021-05-21 09:52:20 +08:00
|
|
|
if !ok {
|
|
|
|
return nil, fmt.Errorf("no dml stream for collection %v", collectionID)
|
|
|
|
}
|
|
|
|
|
|
|
|
return stream, nil
|
|
|
|
}
|
|
|
|
|
2021-05-29 15:09:30 +08:00
|
|
|
func (mgr *singleTypeChannelsMgr) removeStream(collectionID UniqueID) error {
|
2021-05-21 09:52:20 +08:00
|
|
|
ids, err := mgr.getAllVIDs(collectionID)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
mgr.deleteVChansByVIDs(ids)
|
2021-05-29 15:09:30 +08:00
|
|
|
mgr.deleteStreamByVIDs(ids)
|
2021-05-21 09:52:20 +08:00
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-05-29 15:09:30 +08:00
|
|
|
func (mgr *singleTypeChannelsMgr) removeAllStream() error {
|
2021-05-21 09:52:20 +08:00
|
|
|
mgr.deleteAllChannels()
|
2021-05-29 15:09:30 +08:00
|
|
|
mgr.deleteAllStream()
|
2021-05-21 09:52:20 +08:00
|
|
|
mgr.deleteAllVChans()
|
|
|
|
mgr.deleteAllCollection()
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-06-18 10:33:58 +08:00
|
|
|
func newSingleTypeChannelsMgr(
|
|
|
|
getChannelsFunc getChannelsFuncType,
|
|
|
|
msgStreamFactory msgstream.Factory,
|
|
|
|
repackFunc repackFuncType,
|
|
|
|
singleStreamType streamType,
|
|
|
|
) *singleTypeChannelsMgr {
|
2021-05-29 15:09:30 +08:00
|
|
|
return &singleTypeChannelsMgr{
|
|
|
|
collectionID2VIDs: make(map[UniqueID][]int),
|
|
|
|
id2vchans: make(map[int][]vChan),
|
|
|
|
id2Stream: make(map[int]msgstream.MsgStream),
|
|
|
|
id2UsageHistogramOfStream: make(map[int]int),
|
|
|
|
vchans2pchans: make(map[vChan]pChan),
|
|
|
|
getChannelsFunc: getChannelsFunc,
|
2021-06-18 10:33:58 +08:00
|
|
|
repackFunc: repackFunc,
|
|
|
|
singleStreamType: singleStreamType,
|
2021-05-29 15:09:30 +08:00
|
|
|
msgStreamFactory: msgStreamFactory,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type channelsMgrImpl struct {
|
|
|
|
dmlChannelsMgr *singleTypeChannelsMgr
|
|
|
|
dqlChannelsMgr *singleTypeChannelsMgr
|
|
|
|
}
|
|
|
|
|
|
|
|
func (mgr *channelsMgrImpl) getChannels(collectionID UniqueID) ([]pChan, error) {
|
|
|
|
return mgr.dmlChannelsMgr.getChannels(collectionID)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (mgr *channelsMgrImpl) getVChannels(collectionID UniqueID) ([]vChan, error) {
|
|
|
|
return mgr.dmlChannelsMgr.getVChannels(collectionID)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (mgr *channelsMgrImpl) createDQLStream(collectionID UniqueID) error {
|
|
|
|
return mgr.dqlChannelsMgr.createMsgStream(collectionID)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (mgr *channelsMgrImpl) getDQLStream(collectionID UniqueID) (msgstream.MsgStream, error) {
|
|
|
|
return mgr.dqlChannelsMgr.getStream(collectionID)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (mgr *channelsMgrImpl) removeDQLStream(collectionID UniqueID) error {
|
|
|
|
return mgr.dqlChannelsMgr.removeStream(collectionID)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (mgr *channelsMgrImpl) removeAllDQLStream() error {
|
|
|
|
return mgr.dqlChannelsMgr.removeAllStream()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (mgr *channelsMgrImpl) createDMLMsgStream(collectionID UniqueID) error {
|
|
|
|
return mgr.dmlChannelsMgr.createMsgStream(collectionID)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (mgr *channelsMgrImpl) getDMLStream(collectionID UniqueID) (msgstream.MsgStream, error) {
|
|
|
|
return mgr.dmlChannelsMgr.getStream(collectionID)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (mgr *channelsMgrImpl) removeDMLStream(collectionID UniqueID) error {
|
|
|
|
return mgr.dmlChannelsMgr.removeStream(collectionID)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (mgr *channelsMgrImpl) removeAllDMLStream() error {
|
|
|
|
return mgr.dmlChannelsMgr.removeAllStream()
|
|
|
|
}
|
|
|
|
|
2021-06-18 10:33:58 +08:00
|
|
|
func newChannelsMgr(
|
|
|
|
getDmlChannelsFunc getChannelsFuncType,
|
|
|
|
dmlRepackFunc repackFuncType,
|
|
|
|
getDqlChannelsFunc getChannelsFuncType,
|
|
|
|
dqlRepackFunc repackFuncType,
|
|
|
|
msgStreamFactory msgstream.Factory,
|
|
|
|
) channelsMgr {
|
2021-05-21 09:52:20 +08:00
|
|
|
return &channelsMgrImpl{
|
2021-06-18 10:33:58 +08:00
|
|
|
dmlChannelsMgr: newSingleTypeChannelsMgr(getDmlChannelsFunc, msgStreamFactory, dmlRepackFunc, dmlStreamType),
|
|
|
|
dqlChannelsMgr: newSingleTypeChannelsMgr(getDqlChannelsFunc, msgStreamFactory, dqlRepackFunc, dqlStreamType),
|
2021-05-21 09:52:20 +08:00
|
|
|
}
|
|
|
|
}
|