2021-01-16 02:12:14 +00:00
|
|
|
package querynode
|
2021-01-06 08:44:12 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
)
|
|
|
|
|
|
|
|
type gcNode struct {
|
2021-01-15 07:28:54 +00:00
|
|
|
baseNode
|
2021-01-06 08:44:12 +00:00
|
|
|
replica collectionReplica
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2021-02-04 03:08:36 +00:00
|
|
|
_, ok := (*in[0]).(*gcMsg)
|
2021-01-06 08:44:12 +00:00
|
|
|
if !ok {
|
|
|
|
log.Println("type assertion failed for gcMsg")
|
|
|
|
// TODO: add error handling
|
|
|
|
}
|
|
|
|
|
2021-02-04 03:08:36 +00:00
|
|
|
// Use `releasePartition` and `releaseCollection`,
|
|
|
|
// because if we drop collections or partitions here, query service doesn't know this behavior,
|
|
|
|
// which would lead the wrong result of `showCollections` or `showPartition`
|
2021-01-06 08:44:12 +00:00
|
|
|
|
2021-02-04 03:08:36 +00:00
|
|
|
//// drop collections
|
|
|
|
//for _, collectionID := range gcMsg.gcRecord.collections {
|
|
|
|
// err := gcNode.replica.removeCollection(collectionID)
|
|
|
|
// if err != nil {
|
|
|
|
// log.Println(err)
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
//
|
|
|
|
//// drop partitions
|
|
|
|
//for _, partition := range gcMsg.gcRecord.partitions {
|
2021-02-05 02:53:11 +00:00
|
|
|
// err := gcNode.replica.removePartition(partition.partitionID)
|
2021-02-04 03:08:36 +00:00
|
|
|
// if err != nil {
|
|
|
|
// log.Println(err)
|
|
|
|
// }
|
|
|
|
//}
|
2021-01-06 08:44:12 +00:00
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func newGCNode(replica collectionReplica) *gcNode {
|
|
|
|
maxQueueLength := Params.FlowGraphMaxQueueLength
|
|
|
|
maxParallelism := Params.FlowGraphMaxParallelism
|
|
|
|
|
2021-01-15 07:28:54 +00:00
|
|
|
baseNode := baseNode{}
|
2021-01-06 08:44:12 +00:00
|
|
|
baseNode.SetMaxQueueLength(maxQueueLength)
|
|
|
|
baseNode.SetMaxParallelism(maxParallelism)
|
|
|
|
|
|
|
|
return &gcNode{
|
2021-01-15 07:28:54 +00:00
|
|
|
baseNode: baseNode,
|
2021-01-06 08:44:12 +00:00
|
|
|
replica: replica,
|
|
|
|
}
|
|
|
|
}
|