提交 456d0e8c 编写于 作者: B bigsheeper 提交者: yefu.chen

Refactor time tick align strategy

Signed-off-by: Nbigsheeper <yihao.dai@zilliz.com>
上级 f0a0ae43
...@@ -147,29 +147,33 @@ func (nodeCtx *nodeCtx) collectInputMessages() context.Context { ...@@ -147,29 +147,33 @@ func (nodeCtx *nodeCtx) collectInputMessages() context.Context {
for i := 1; i < len(nodeCtx.inputMessages); i++ { for i := 1; i < len(nodeCtx.inputMessages); i++ {
if t < nodeCtx.inputMessages[i].TimeTick() { if t < nodeCtx.inputMessages[i].TimeTick() {
latestTime = nodeCtx.inputMessages[i].TimeTick() latestTime = nodeCtx.inputMessages[i].TimeTick()
//err := errors.New("Fatal, misaligned time tick," +
// "t1=" + strconv.FormatUint(time, 10) +
// ", t2=" + strconv.FormatUint((*nodeCtx.inputMessages[i]).TimeTick(), 10) +
// ", please restart pulsar")
//panic(err)
} }
} }
// wait for time tick // wait for time tick
for i := 0; i < len(nodeCtx.inputMessages); i++ { sign := make(chan struct{})
for nodeCtx.inputMessages[i].TimeTick() != latestTime { go func() {
channel := nodeCtx.inputChannels[i] for i := 0; i < len(nodeCtx.inputMessages); i++ {
select { for nodeCtx.inputMessages[i].TimeTick() != latestTime {
case <-time.After(10 * time.Second): fmt.Println("try to align timestamp, t1 =", latestTime, ", t2 =", nodeCtx.inputMessages[i].TimeTick())
panic("cannot find time tick in flow graph") channel := nodeCtx.inputChannels[i]
case msg, ok := <-channel: msg, ok := <-channel
if !ok { if !ok {
log.Println("input channel closed") log.Println("input channel closed")
return nil return
} }
nodeCtx.inputMessages[i] = msg.msg nodeCtx.inputMessages[i] = msg.msg
} }
} }
sign <- struct{}{}
}()
select {
case <-time.After(10 * time.Second):
panic("Fatal, misaligned time tick, please restart pulsar")
case <-sign:
} }
} }
return ctx return ctx
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册