mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-03 20:39:36 +08:00
7bbbc14637
Signed-off-by: zhenshan.cao <zhenshan.cao@zilliz.com>
85 lines
1.9 KiB
Go
85 lines
1.9 KiB
Go
package querynode
|
|
|
|
import (
|
|
"context"
|
|
"log"
|
|
|
|
"github.com/zilliztech/milvus-distributed/internal/util/flowgraph"
|
|
)
|
|
|
|
type dataSyncService struct {
|
|
ctx context.Context
|
|
fg *flowgraph.TimeTickedFlowGraph
|
|
|
|
replica *collectionReplica
|
|
}
|
|
|
|
func newDataSyncService(ctx context.Context, replica *collectionReplica) *dataSyncService {
|
|
|
|
return &dataSyncService{
|
|
ctx: ctx,
|
|
fg: nil,
|
|
|
|
replica: replica,
|
|
}
|
|
}
|
|
|
|
func (dsService *dataSyncService) start() {
|
|
dsService.initNodes()
|
|
dsService.fg.Start()
|
|
}
|
|
|
|
func (dsService *dataSyncService) close() {
|
|
if dsService.fg != nil {
|
|
dsService.fg.Close()
|
|
}
|
|
}
|
|
|
|
func (dsService *dataSyncService) initNodes() {
|
|
// TODO: add delete pipeline support
|
|
|
|
dsService.fg = flowgraph.NewTimeTickedFlowGraph(dsService.ctx)
|
|
|
|
var dmStreamNode Node = newDmInputNode(dsService.ctx)
|
|
var filterDmNode Node = newFilteredDmNode()
|
|
var insertNode Node = newInsertNode(dsService.replica)
|
|
var serviceTimeNode Node = newServiceTimeNode(dsService.replica)
|
|
|
|
dsService.fg.AddNode(&dmStreamNode)
|
|
dsService.fg.AddNode(&filterDmNode)
|
|
dsService.fg.AddNode(&insertNode)
|
|
dsService.fg.AddNode(&serviceTimeNode)
|
|
|
|
var err = dsService.fg.SetEdges(dmStreamNode.Name(),
|
|
[]string{},
|
|
[]string{filterDmNode.Name()},
|
|
)
|
|
if err != nil {
|
|
log.Fatal("set edges failed in node:", dmStreamNode.Name())
|
|
}
|
|
|
|
err = dsService.fg.SetEdges(filterDmNode.Name(),
|
|
[]string{dmStreamNode.Name()},
|
|
[]string{insertNode.Name()},
|
|
)
|
|
if err != nil {
|
|
log.Fatal("set edges failed in node:", filterDmNode.Name())
|
|
}
|
|
|
|
err = dsService.fg.SetEdges(insertNode.Name(),
|
|
[]string{filterDmNode.Name()},
|
|
[]string{serviceTimeNode.Name()},
|
|
)
|
|
if err != nil {
|
|
log.Fatal("set edges failed in node:", insertNode.Name())
|
|
}
|
|
|
|
err = dsService.fg.SetEdges(serviceTimeNode.Name(),
|
|
[]string{insertNode.Name()},
|
|
[]string{},
|
|
)
|
|
if err != nil {
|
|
log.Fatal("set edges failed in node:", serviceTimeNode.Name())
|
|
}
|
|
}
|