2021-01-19 11:37:16 +08:00
|
|
|
package datanode
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
)
|
|
|
|
|
|
|
|
type gcNode struct {
|
|
|
|
BaseNode
|
2021-02-04 20:31:23 +08:00
|
|
|
replica Replica
|
2021-01-19 11:37:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (gcNode *gcNode) Name() string {
|
|
|
|
return "gcNode"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (gcNode *gcNode) Operate(in []*Msg) []*Msg {
|
|
|
|
//fmt.Println("Do gcNode operation")
|
|
|
|
|
|
|
|
if len(in) != 1 {
|
|
|
|
log.Println("Invalid operate message input in gcNode, input length = ", len(in))
|
|
|
|
// TODO: add error handling
|
|
|
|
}
|
|
|
|
|
|
|
|
gcMsg, ok := (*in[0]).(*gcMsg)
|
|
|
|
if !ok {
|
|
|
|
log.Println("type assertion failed for gcMsg")
|
|
|
|
// TODO: add error handling
|
|
|
|
}
|
|
|
|
|
|
|
|
// drop collections
|
|
|
|
for _, collectionID := range gcMsg.gcRecord.collections {
|
|
|
|
err := gcNode.replica.removeCollection(collectionID)
|
|
|
|
if err != nil {
|
|
|
|
log.Println(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-02-04 20:31:23 +08:00
|
|
|
func newGCNode(replica Replica) *gcNode {
|
2021-01-19 11:37:16 +08:00
|
|
|
maxQueueLength := Params.FlowGraphMaxQueueLength
|
|
|
|
maxParallelism := Params.FlowGraphMaxParallelism
|
|
|
|
|
|
|
|
baseNode := BaseNode{}
|
|
|
|
baseNode.SetMaxQueueLength(maxQueueLength)
|
|
|
|
baseNode.SetMaxParallelism(maxParallelism)
|
|
|
|
|
|
|
|
return &gcNode{
|
|
|
|
BaseNode: baseNode,
|
|
|
|
replica: replica,
|
|
|
|
}
|
|
|
|
}
|