Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issue 1166: treat all zk child path url as new child #1225

Merged
merged 1 commit into from
May 30, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions remoting/zookeeper/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,6 @@ func (l *ZkEventListener) handleZkNodeEvent(zkPath string, children []string, li
newNode string
)
for _, n := range newChildren {
if contains(children, n) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里去掉的话可能会造成goroutine 开启的过多吧 , 应该把之前监听的goroutine 关闭

image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个地方去掉会发生重复监听的。不应该去掉

continue
}

newNode = path.Join(zkPath, n)
logger.Infof("add zkNode{%s}", newNode)
content, _, connErr := l.client.Conn.Get(newNode)
Expand Down Expand Up @@ -323,12 +319,24 @@ func (l *ZkEventListener) listenDirEvent(conf *common.URL, zkPath string, listen
}
}
// Periodically update provider information
ticker := time.NewTicker(ttl)
tickerTTL := ttl
if tickerTTL > 20e9 {
tickerTTL = 20e9
}
ticker := time.NewTicker(tickerTTL)
WATCH:
for {
select {
case <-ticker.C:
l.handleZkNodeEvent(zkPath, children, listener)
if tickerTTL < ttl {
tickerTTL *= 2
if tickerTTL > ttl {
tickerTTL = ttl
}
ticker.Stop()
ticker = time.NewTicker(tickerTTL)
}
case zkEvent = <-childEventCh:
logger.Warnf("get a zookeeper childEventCh{type:%s, server:%s, path:%s, state:%d-%s, err:%s}",
zkEvent.Type.String(), zkEvent.Server, zkEvent.Path, zkEvent.State, gxzookeeper.StateToString(zkEvent.State), zkEvent.Err)
Expand Down