2021-01-16 10:12:14 +08:00
|
|
|
package querynode
|
2020-11-05 10:52:50 +08:00
|
|
|
|
2020-11-17 10:07:42 +08:00
|
|
|
import (
|
2020-12-05 17:39:58 +08:00
|
|
|
"context"
|
2020-11-17 10:07:42 +08:00
|
|
|
"encoding/binary"
|
|
|
|
"log"
|
|
|
|
"math"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/golang/protobuf/proto"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
|
|
|
"github.com/zilliztech/milvus-distributed/internal/msgstream"
|
2021-01-20 10:02:59 +08:00
|
|
|
"github.com/zilliztech/milvus-distributed/internal/msgstream/pulsarms"
|
2020-11-17 10:07:42 +08:00
|
|
|
"github.com/zilliztech/milvus-distributed/internal/proto/commonpb"
|
2021-01-18 19:32:08 +08:00
|
|
|
"github.com/zilliztech/milvus-distributed/internal/proto/internalpb2"
|
2021-01-22 09:36:18 +08:00
|
|
|
"github.com/zilliztech/milvus-distributed/internal/proto/milvuspb"
|
2020-11-17 10:07:42 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestSearch_Search(t *testing.T) {
|
2021-01-15 15:28:54 +08:00
|
|
|
node := newQueryNodeMock()
|
2021-02-03 11:52:19 +08:00
|
|
|
initTestMeta(t, node, 0, 0)
|
2020-11-17 10:07:42 +08:00
|
|
|
|
2020-12-10 16:31:09 +08:00
|
|
|
pulsarURL := Params.PulsarAddress
|
2020-11-17 10:07:42 +08:00
|
|
|
|
|
|
|
// test data generate
|
|
|
|
const msgLength = 10
|
2020-11-26 16:01:31 +08:00
|
|
|
const receiveBufSize = 1024
|
2020-11-17 10:07:42 +08:00
|
|
|
const DIM = 16
|
2020-12-10 16:31:09 +08:00
|
|
|
searchProducerChannels := Params.SearchChannelNames
|
2020-11-26 15:18:36 +08:00
|
|
|
var vec = [DIM]float32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}
|
|
|
|
|
2020-11-26 16:01:31 +08:00
|
|
|
// start search service
|
2020-11-26 15:18:36 +08:00
|
|
|
dslString := "{\"bool\": { \n\"vector\": {\n \"vec\": {\n \"metric_type\": \"L2\", \n \"params\": {\n \"nprobe\": 10 \n},\n \"query\": \"$0\",\"topk\": 10 \n } \n } \n } \n }"
|
2020-11-26 16:01:31 +08:00
|
|
|
var searchRawData1 []byte
|
|
|
|
var searchRawData2 []byte
|
|
|
|
for i, ele := range vec {
|
|
|
|
buf := make([]byte, 4)
|
|
|
|
binary.LittleEndian.PutUint32(buf, math.Float32bits(ele+float32(i*2)))
|
|
|
|
searchRawData1 = append(searchRawData1, buf...)
|
|
|
|
}
|
|
|
|
for i, ele := range vec {
|
2020-11-17 10:07:42 +08:00
|
|
|
buf := make([]byte, 4)
|
2020-11-26 16:01:31 +08:00
|
|
|
binary.LittleEndian.PutUint32(buf, math.Float32bits(ele+float32(i*4)))
|
|
|
|
searchRawData2 = append(searchRawData2, buf...)
|
2020-11-17 10:07:42 +08:00
|
|
|
}
|
2021-01-22 09:36:18 +08:00
|
|
|
placeholderValue := milvuspb.PlaceholderValue{
|
2020-11-17 10:07:42 +08:00
|
|
|
Tag: "$0",
|
2021-01-22 09:36:18 +08:00
|
|
|
Type: milvuspb.PlaceholderType_VECTOR_FLOAT,
|
2020-11-26 16:01:31 +08:00
|
|
|
Values: [][]byte{searchRawData1, searchRawData2},
|
2020-11-17 10:07:42 +08:00
|
|
|
}
|
|
|
|
|
2021-01-22 09:36:18 +08:00
|
|
|
placeholderGroup := milvuspb.PlaceholderGroup{
|
|
|
|
Placeholders: []*milvuspb.PlaceholderValue{&placeholderValue},
|
2020-11-17 10:07:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
placeGroupByte, err := proto.Marshal(&placeholderGroup)
|
|
|
|
if err != nil {
|
|
|
|
log.Print("marshal placeholderGroup failed")
|
|
|
|
}
|
|
|
|
|
2021-01-22 09:36:18 +08:00
|
|
|
query := milvuspb.SearchRequest{
|
2021-02-03 17:30:10 +08:00
|
|
|
CollectionName: "collection0",
|
|
|
|
PartitionNames: []string{"default"},
|
2020-11-17 10:07:42 +08:00
|
|
|
Dsl: dslString,
|
|
|
|
PlaceholderGroup: placeGroupByte,
|
|
|
|
}
|
|
|
|
|
|
|
|
queryByte, err := proto.Marshal(&query)
|
|
|
|
if err != nil {
|
|
|
|
log.Print("marshal query failed")
|
|
|
|
}
|
|
|
|
|
|
|
|
blob := commonpb.Blob{
|
|
|
|
Value: queryByte,
|
|
|
|
}
|
|
|
|
|
2020-11-17 14:10:07 +08:00
|
|
|
searchMsg := &msgstream.SearchMsg{
|
2020-11-17 10:07:42 +08:00
|
|
|
BaseMsg: msgstream.BaseMsg{
|
2020-11-30 19:38:23 +08:00
|
|
|
HashValues: []uint32{0},
|
2020-11-17 10:07:42 +08:00
|
|
|
},
|
2021-01-18 19:32:08 +08:00
|
|
|
SearchRequest: internalpb2.SearchRequest{
|
|
|
|
Base: &commonpb.MsgBase{
|
|
|
|
MsgType: commonpb.MsgType_kSearch,
|
|
|
|
MsgID: 1,
|
|
|
|
Timestamp: uint64(10 + 1000),
|
|
|
|
SourceID: 1,
|
|
|
|
},
|
|
|
|
ResultChannelID: "0",
|
2020-11-17 10:07:42 +08:00
|
|
|
Query: &blob,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
msgPackSearch := msgstream.MsgPack{}
|
2020-11-17 14:10:07 +08:00
|
|
|
msgPackSearch.Msgs = append(msgPackSearch.Msgs, searchMsg)
|
2020-11-17 10:07:42 +08:00
|
|
|
|
2021-02-03 17:30:10 +08:00
|
|
|
factory := msgstream.ProtoUDFactory{}
|
|
|
|
searchStream := pulsarms.NewPulsarMsgStream(node.queryNodeLoopCtx, receiveBufSize, 1024, factory.NewUnmarshalDispatcher())
|
2020-11-26 16:01:31 +08:00
|
|
|
searchStream.SetPulsarClient(pulsarURL)
|
|
|
|
searchStream.CreatePulsarProducers(searchProducerChannels)
|
|
|
|
searchStream.Start()
|
|
|
|
err = searchStream.Produce(&msgPackSearch)
|
2020-11-17 10:07:42 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
|
2020-12-08 14:41:04 +08:00
|
|
|
node.searchService = newSearchService(node.queryNodeLoopCtx, node.replica)
|
2020-11-17 10:07:42 +08:00
|
|
|
go node.searchService.start()
|
|
|
|
|
2020-11-26 16:01:31 +08:00
|
|
|
// start insert
|
|
|
|
timeRange := TimeRange{
|
|
|
|
timestampMin: 0,
|
|
|
|
timestampMax: math.MaxUint64,
|
|
|
|
}
|
|
|
|
|
|
|
|
insertMessages := make([]msgstream.TsMsg, 0)
|
|
|
|
for i := 0; i < msgLength; i++ {
|
|
|
|
var rawData []byte
|
|
|
|
for _, ele := range vec {
|
|
|
|
buf := make([]byte, 4)
|
|
|
|
binary.LittleEndian.PutUint32(buf, math.Float32bits(ele+float32(i*2)))
|
|
|
|
rawData = append(rawData, buf...)
|
|
|
|
}
|
|
|
|
bs := make([]byte, 4)
|
|
|
|
binary.LittleEndian.PutUint32(bs, 1)
|
|
|
|
rawData = append(rawData, bs...)
|
|
|
|
|
|
|
|
var msg msgstream.TsMsg = &msgstream.InsertMsg{
|
|
|
|
BaseMsg: msgstream.BaseMsg{
|
2020-11-30 19:38:23 +08:00
|
|
|
HashValues: []uint32{
|
|
|
|
uint32(i),
|
2020-11-26 16:01:31 +08:00
|
|
|
},
|
|
|
|
},
|
2021-01-18 19:32:08 +08:00
|
|
|
InsertRequest: internalpb2.InsertRequest{
|
|
|
|
Base: &commonpb.MsgBase{
|
|
|
|
MsgType: commonpb.MsgType_kInsert,
|
|
|
|
MsgID: int64(i),
|
|
|
|
Timestamp: uint64(10 + 1000),
|
|
|
|
SourceID: 0,
|
|
|
|
},
|
2021-02-03 17:30:10 +08:00
|
|
|
CollectionID: UniqueID(0),
|
|
|
|
PartitionName: "default",
|
|
|
|
SegmentID: int64(0),
|
|
|
|
ChannelID: "0",
|
|
|
|
Timestamps: []uint64{uint64(i + 1000)},
|
|
|
|
RowIDs: []int64{int64(i)},
|
2020-11-26 16:01:31 +08:00
|
|
|
RowData: []*commonpb.Blob{
|
|
|
|
{Value: rawData},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
insertMessages = append(insertMessages, msg)
|
|
|
|
}
|
|
|
|
|
|
|
|
msgPack := msgstream.MsgPack{
|
|
|
|
BeginTs: timeRange.timestampMin,
|
|
|
|
EndTs: timeRange.timestampMax,
|
2020-12-03 19:00:11 +08:00
|
|
|
Msgs: insertMessages,
|
|
|
|
}
|
|
|
|
|
|
|
|
// generate timeTick
|
|
|
|
timeTickMsgPack := msgstream.MsgPack{}
|
|
|
|
baseMsg := msgstream.BaseMsg{
|
|
|
|
BeginTimestamp: 0,
|
|
|
|
EndTimestamp: 0,
|
|
|
|
HashValues: []uint32{0},
|
|
|
|
}
|
2021-01-18 19:32:08 +08:00
|
|
|
timeTickResult := internalpb2.TimeTickMsg{
|
|
|
|
Base: &commonpb.MsgBase{
|
|
|
|
MsgType: commonpb.MsgType_kTimeTick,
|
|
|
|
MsgID: 0,
|
|
|
|
Timestamp: math.MaxUint64,
|
|
|
|
SourceID: 0,
|
|
|
|
},
|
2020-12-03 19:00:11 +08:00
|
|
|
}
|
|
|
|
timeTickMsg := &msgstream.TimeTickMsg{
|
|
|
|
BaseMsg: baseMsg,
|
|
|
|
TimeTickMsg: timeTickResult,
|
|
|
|
}
|
|
|
|
timeTickMsgPack.Msgs = append(timeTickMsgPack.Msgs, timeTickMsg)
|
|
|
|
|
|
|
|
// pulsar produce
|
2020-12-10 16:31:09 +08:00
|
|
|
insertChannels := Params.InsertChannelNames
|
|
|
|
ddChannels := Params.DDChannelNames
|
|
|
|
|
2021-02-03 17:30:10 +08:00
|
|
|
insertStream := pulsarms.NewPulsarMsgStream(node.queryNodeLoopCtx, receiveBufSize, 1024, factory.NewUnmarshalDispatcher())
|
2020-12-03 19:00:11 +08:00
|
|
|
insertStream.SetPulsarClient(pulsarURL)
|
2020-12-10 16:31:09 +08:00
|
|
|
insertStream.CreatePulsarProducers(insertChannels)
|
|
|
|
|
2021-02-03 17:30:10 +08:00
|
|
|
ddStream := pulsarms.NewPulsarMsgStream(node.queryNodeLoopCtx, receiveBufSize, 1024, factory.NewUnmarshalDispatcher())
|
2020-12-10 16:31:09 +08:00
|
|
|
ddStream.SetPulsarClient(pulsarURL)
|
|
|
|
ddStream.CreatePulsarProducers(ddChannels)
|
|
|
|
|
|
|
|
var insertMsgStream msgstream.MsgStream = insertStream
|
|
|
|
insertMsgStream.Start()
|
|
|
|
|
|
|
|
var ddMsgStream msgstream.MsgStream = ddStream
|
|
|
|
ddMsgStream.Start()
|
|
|
|
|
|
|
|
err = insertMsgStream.Produce(&msgPack)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
err = insertMsgStream.Broadcast(&timeTickMsgPack)
|
2020-12-03 19:00:11 +08:00
|
|
|
assert.NoError(t, err)
|
2020-12-10 16:31:09 +08:00
|
|
|
err = ddMsgStream.Broadcast(&timeTickMsgPack)
|
2020-12-03 19:00:11 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
// dataSync
|
2020-12-08 14:41:04 +08:00
|
|
|
node.dataSyncService = newDataSyncService(node.queryNodeLoopCtx, node.replica)
|
2020-12-03 19:00:11 +08:00
|
|
|
go node.dataSyncService.start()
|
|
|
|
|
|
|
|
time.Sleep(1 * time.Second)
|
|
|
|
|
2021-01-21 15:20:23 +08:00
|
|
|
node.Stop()
|
2020-12-03 19:00:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestSearch_SearchMultiSegments(t *testing.T) {
|
2021-01-22 11:17:18 +08:00
|
|
|
node := NewQueryNode(context.Background(), 0)
|
2021-02-03 11:52:19 +08:00
|
|
|
initTestMeta(t, node, 0, 0)
|
2020-12-03 19:00:11 +08:00
|
|
|
|
2020-12-10 16:31:09 +08:00
|
|
|
pulsarURL := Params.PulsarAddress
|
2020-12-03 19:00:11 +08:00
|
|
|
|
|
|
|
// test data generate
|
2020-12-10 16:31:09 +08:00
|
|
|
const msgLength = 10
|
2020-12-03 19:00:11 +08:00
|
|
|
const receiveBufSize = 1024
|
|
|
|
const DIM = 16
|
2020-12-10 16:31:09 +08:00
|
|
|
searchProducerChannels := Params.SearchChannelNames
|
2020-12-03 19:00:11 +08:00
|
|
|
var vec = [DIM]float32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}
|
|
|
|
|
|
|
|
// start search service
|
|
|
|
dslString := "{\"bool\": { \n\"vector\": {\n \"vec\": {\n \"metric_type\": \"L2\", \n \"params\": {\n \"nprobe\": 10 \n},\n \"query\": \"$0\",\"topk\": 10 \n } \n } \n } \n }"
|
|
|
|
var searchRawData1 []byte
|
|
|
|
var searchRawData2 []byte
|
|
|
|
for i, ele := range vec {
|
|
|
|
buf := make([]byte, 4)
|
|
|
|
binary.LittleEndian.PutUint32(buf, math.Float32bits(ele+float32(i*2)))
|
|
|
|
searchRawData1 = append(searchRawData1, buf...)
|
|
|
|
}
|
|
|
|
for i, ele := range vec {
|
|
|
|
buf := make([]byte, 4)
|
|
|
|
binary.LittleEndian.PutUint32(buf, math.Float32bits(ele+float32(i*4)))
|
|
|
|
searchRawData2 = append(searchRawData2, buf...)
|
|
|
|
}
|
2021-01-22 09:36:18 +08:00
|
|
|
placeholderValue := milvuspb.PlaceholderValue{
|
2020-12-03 19:00:11 +08:00
|
|
|
Tag: "$0",
|
2021-01-22 09:36:18 +08:00
|
|
|
Type: milvuspb.PlaceholderType_VECTOR_FLOAT,
|
2020-12-03 19:00:11 +08:00
|
|
|
Values: [][]byte{searchRawData1, searchRawData2},
|
|
|
|
}
|
|
|
|
|
2021-01-22 09:36:18 +08:00
|
|
|
placeholderGroup := milvuspb.PlaceholderGroup{
|
|
|
|
Placeholders: []*milvuspb.PlaceholderValue{&placeholderValue},
|
2020-12-03 19:00:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
placeGroupByte, err := proto.Marshal(&placeholderGroup)
|
|
|
|
if err != nil {
|
|
|
|
log.Print("marshal placeholderGroup failed")
|
|
|
|
}
|
|
|
|
|
2021-01-22 09:36:18 +08:00
|
|
|
query := milvuspb.SearchRequest{
|
2021-02-03 17:30:10 +08:00
|
|
|
CollectionName: "collection0",
|
|
|
|
PartitionNames: []string{"default"},
|
2020-12-03 19:00:11 +08:00
|
|
|
Dsl: dslString,
|
|
|
|
PlaceholderGroup: placeGroupByte,
|
|
|
|
}
|
|
|
|
|
|
|
|
queryByte, err := proto.Marshal(&query)
|
|
|
|
if err != nil {
|
|
|
|
log.Print("marshal query failed")
|
|
|
|
}
|
|
|
|
|
|
|
|
blob := commonpb.Blob{
|
|
|
|
Value: queryByte,
|
|
|
|
}
|
|
|
|
|
|
|
|
searchMsg := &msgstream.SearchMsg{
|
|
|
|
BaseMsg: msgstream.BaseMsg{
|
|
|
|
HashValues: []uint32{0},
|
|
|
|
},
|
2021-01-18 19:32:08 +08:00
|
|
|
SearchRequest: internalpb2.SearchRequest{
|
|
|
|
Base: &commonpb.MsgBase{
|
|
|
|
MsgType: commonpb.MsgType_kSearch,
|
|
|
|
MsgID: 1,
|
|
|
|
Timestamp: uint64(10 + 1000),
|
|
|
|
SourceID: 1,
|
|
|
|
},
|
|
|
|
ResultChannelID: "0",
|
2020-12-03 19:00:11 +08:00
|
|
|
Query: &blob,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
msgPackSearch := msgstream.MsgPack{}
|
|
|
|
msgPackSearch.Msgs = append(msgPackSearch.Msgs, searchMsg)
|
|
|
|
|
2021-02-03 17:30:10 +08:00
|
|
|
factory := msgstream.ProtoUDFactory{}
|
|
|
|
searchStream := pulsarms.NewPulsarMsgStream(node.queryNodeLoopCtx, receiveBufSize, 1024, factory.NewUnmarshalDispatcher())
|
2020-12-03 19:00:11 +08:00
|
|
|
searchStream.SetPulsarClient(pulsarURL)
|
|
|
|
searchStream.CreatePulsarProducers(searchProducerChannels)
|
|
|
|
searchStream.Start()
|
|
|
|
err = searchStream.Produce(&msgPackSearch)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
2020-12-08 14:41:04 +08:00
|
|
|
node.searchService = newSearchService(node.queryNodeLoopCtx, node.replica)
|
2020-12-03 19:00:11 +08:00
|
|
|
go node.searchService.start()
|
|
|
|
|
|
|
|
// start insert
|
|
|
|
timeRange := TimeRange{
|
|
|
|
timestampMin: 0,
|
|
|
|
timestampMax: math.MaxUint64,
|
|
|
|
}
|
|
|
|
|
|
|
|
insertMessages := make([]msgstream.TsMsg, 0)
|
|
|
|
for i := 0; i < msgLength; i++ {
|
|
|
|
segmentID := 0
|
|
|
|
if i >= msgLength/2 {
|
|
|
|
segmentID = 1
|
|
|
|
}
|
|
|
|
var rawData []byte
|
|
|
|
for _, ele := range vec {
|
|
|
|
buf := make([]byte, 4)
|
|
|
|
binary.LittleEndian.PutUint32(buf, math.Float32bits(ele+float32(i*2)))
|
|
|
|
rawData = append(rawData, buf...)
|
|
|
|
}
|
|
|
|
bs := make([]byte, 4)
|
|
|
|
binary.LittleEndian.PutUint32(bs, 1)
|
|
|
|
rawData = append(rawData, bs...)
|
|
|
|
|
|
|
|
var msg msgstream.TsMsg = &msgstream.InsertMsg{
|
|
|
|
BaseMsg: msgstream.BaseMsg{
|
|
|
|
HashValues: []uint32{
|
|
|
|
uint32(i),
|
|
|
|
},
|
|
|
|
},
|
2021-01-18 19:32:08 +08:00
|
|
|
InsertRequest: internalpb2.InsertRequest{
|
|
|
|
Base: &commonpb.MsgBase{
|
|
|
|
MsgType: commonpb.MsgType_kInsert,
|
|
|
|
MsgID: int64(i),
|
|
|
|
Timestamp: uint64(i + 1000),
|
|
|
|
SourceID: 0,
|
|
|
|
},
|
2021-02-03 17:30:10 +08:00
|
|
|
CollectionID: UniqueID(0),
|
|
|
|
PartitionName: "default",
|
|
|
|
SegmentID: int64(segmentID),
|
|
|
|
ChannelID: "0",
|
|
|
|
Timestamps: []uint64{uint64(i + 1000)},
|
|
|
|
RowIDs: []int64{int64(i)},
|
2020-12-03 19:00:11 +08:00
|
|
|
RowData: []*commonpb.Blob{
|
|
|
|
{Value: rawData},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
insertMessages = append(insertMessages, msg)
|
|
|
|
}
|
|
|
|
|
|
|
|
msgPack := msgstream.MsgPack{
|
|
|
|
BeginTs: timeRange.timestampMin,
|
|
|
|
EndTs: timeRange.timestampMax,
|
2020-11-26 16:01:31 +08:00
|
|
|
Msgs: insertMessages,
|
|
|
|
}
|
|
|
|
|
|
|
|
// generate timeTick
|
|
|
|
timeTickMsgPack := msgstream.MsgPack{}
|
|
|
|
baseMsg := msgstream.BaseMsg{
|
|
|
|
BeginTimestamp: 0,
|
|
|
|
EndTimestamp: 0,
|
2020-11-30 19:38:23 +08:00
|
|
|
HashValues: []uint32{0},
|
2020-11-26 16:01:31 +08:00
|
|
|
}
|
2021-01-18 19:32:08 +08:00
|
|
|
timeTickResult := internalpb2.TimeTickMsg{
|
|
|
|
Base: &commonpb.MsgBase{
|
|
|
|
MsgType: commonpb.MsgType_kTimeTick,
|
|
|
|
MsgID: 0,
|
|
|
|
Timestamp: math.MaxUint64,
|
|
|
|
SourceID: 0,
|
|
|
|
},
|
2020-11-26 16:01:31 +08:00
|
|
|
}
|
|
|
|
timeTickMsg := &msgstream.TimeTickMsg{
|
|
|
|
BaseMsg: baseMsg,
|
|
|
|
TimeTickMsg: timeTickResult,
|
|
|
|
}
|
|
|
|
timeTickMsgPack.Msgs = append(timeTickMsgPack.Msgs, timeTickMsg)
|
|
|
|
|
|
|
|
// pulsar produce
|
2020-12-10 16:31:09 +08:00
|
|
|
insertChannels := Params.InsertChannelNames
|
|
|
|
ddChannels := Params.DDChannelNames
|
|
|
|
|
2021-02-03 17:30:10 +08:00
|
|
|
insertStream := pulsarms.NewPulsarMsgStream(node.queryNodeLoopCtx, receiveBufSize, 1024, factory.NewUnmarshalDispatcher())
|
2020-11-26 16:01:31 +08:00
|
|
|
insertStream.SetPulsarClient(pulsarURL)
|
2020-12-10 16:31:09 +08:00
|
|
|
insertStream.CreatePulsarProducers(insertChannels)
|
|
|
|
|
2021-02-03 17:30:10 +08:00
|
|
|
ddStream := pulsarms.NewPulsarMsgStream(node.queryNodeLoopCtx, receiveBufSize, 1024, factory.NewUnmarshalDispatcher())
|
2020-12-10 16:31:09 +08:00
|
|
|
ddStream.SetPulsarClient(pulsarURL)
|
|
|
|
ddStream.CreatePulsarProducers(ddChannels)
|
|
|
|
|
|
|
|
var insertMsgStream msgstream.MsgStream = insertStream
|
|
|
|
insertMsgStream.Start()
|
|
|
|
|
|
|
|
var ddMsgStream msgstream.MsgStream = ddStream
|
|
|
|
ddMsgStream.Start()
|
|
|
|
|
|
|
|
err = insertMsgStream.Produce(&msgPack)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
err = insertMsgStream.Broadcast(&timeTickMsgPack)
|
2020-11-26 16:01:31 +08:00
|
|
|
assert.NoError(t, err)
|
2020-12-10 16:31:09 +08:00
|
|
|
err = ddMsgStream.Broadcast(&timeTickMsgPack)
|
2020-11-26 16:01:31 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
// dataSync
|
2020-12-08 14:41:04 +08:00
|
|
|
node.dataSyncService = newDataSyncService(node.queryNodeLoopCtx, node.replica)
|
2020-11-26 16:01:31 +08:00
|
|
|
go node.dataSyncService.start()
|
|
|
|
|
|
|
|
time.Sleep(1 * time.Second)
|
2020-11-17 10:07:42 +08:00
|
|
|
|
2021-01-21 15:20:23 +08:00
|
|
|
node.Stop()
|
2020-11-17 10:07:42 +08:00
|
|
|
}
|