milvus/internal/reader/stats_service.go
godchen 4a3ca1632b Add master partition task implementation
Signed-off-by: godchen <qingxiang.chen@zilliz.com>
2020-11-13 17:20:13 +08:00

54 lines
1.2 KiB
Go

package reader
import (
"context"
"fmt"
"strconv"
"time"
"github.com/zilliztech/milvus-distributed/internal/msgstream"
"github.com/zilliztech/milvus-distributed/internal/proto/internalpb"
)
type statsService struct {
ctx context.Context
msgStream *msgstream.PulsarMsgStream
container *container
}
func newStatsService(ctx context.Context, container *container, pulsarAddress string) *statsService {
// TODO: add pulsar message stream init
return &statsService{
ctx: ctx,
container: container,
}
}
func (sService *statsService) start() {
sleepMillisecondTime := 1000
fmt.Println("do segments statistic in ", strconv.Itoa(sleepMillisecondTime), "ms")
for {
select {
case <-sService.ctx.Done():
return
default:
time.Sleep(time.Duration(sleepMillisecondTime) * time.Millisecond)
sService.sendSegmentStatistic()
}
}
}
func (sService *statsService) sendSegmentStatistic() {
var statisticData = (*sService.container).getSegmentStatistics()
// fmt.Println("Publish segment statistic")
// fmt.Println(statisticData)
sService.publicStatistic(statisticData)
}
func (sService *statsService) publicStatistic(statistic *internalpb.QueryNodeSegStats) {
// TODO: publish statistic
}