2020-08-25 15:38:35 +08:00
|
|
|
package reader
|
|
|
|
|
2020-09-15 17:41:05 +08:00
|
|
|
import (
|
2020-09-18 15:44:09 +08:00
|
|
|
"context"
|
2020-09-16 11:07:55 +08:00
|
|
|
"log"
|
2020-09-15 17:41:05 +08:00
|
|
|
"sync"
|
2020-09-18 15:44:09 +08:00
|
|
|
|
|
|
|
"github.com/czs007/suvlim/reader/message_client"
|
2020-09-15 17:41:05 +08:00
|
|
|
)
|
|
|
|
|
2020-09-16 11:07:55 +08:00
|
|
|
func StartQueryNode(pulsarURL string, numOfQueryNode int, messageClientID int) {
|
|
|
|
if messageClientID >= numOfQueryNode {
|
|
|
|
log.Printf("Illegal channel id")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
mc := message_client.MessageClient{
|
|
|
|
MessageClientID: messageClientID,
|
|
|
|
}
|
|
|
|
mc.InitClient(pulsarURL, numOfQueryNode)
|
2020-08-28 17:29:26 +08:00
|
|
|
|
2020-09-15 17:41:05 +08:00
|
|
|
mc.ReceiveMessage()
|
|
|
|
qn := CreateQueryNode(0, 0, &mc)
|
|
|
|
qn.InitQueryNodeCollection()
|
2020-09-16 15:21:10 +08:00
|
|
|
|
|
|
|
// Segments Services
|
|
|
|
// go qn.SegmentManagementService()
|
|
|
|
go qn.SegmentStatisticService()
|
|
|
|
|
2020-09-15 17:41:05 +08:00
|
|
|
wg := sync.WaitGroup{}
|
|
|
|
wg.Add(2)
|
|
|
|
go qn.RunInsertDelete(&wg)
|
|
|
|
go qn.RunSearch(&wg)
|
|
|
|
wg.Wait()
|
|
|
|
qn.Close()
|
2020-08-25 15:38:35 +08:00
|
|
|
}
|
2020-09-18 15:44:09 +08:00
|
|
|
|
|
|
|
func StartQueryNode2() {
|
|
|
|
ctx := context.Background()
|
|
|
|
qn := CreateQueryNode(0, 0, nil)
|
|
|
|
//qn.InitQueryNodeCollection()
|
|
|
|
wg := sync.WaitGroup{}
|
|
|
|
wg.Add(1)
|
|
|
|
//go qn.RunInsertDelete(&wg)
|
|
|
|
//go qn.RunSearch(&wg)
|
|
|
|
go qn.RunMetaService(ctx, &wg)
|
|
|
|
wg.Wait()
|
|
|
|
qn.Close()
|
|
|
|
}
|