Skip to content

Commit

Permalink
fix issue 1166: treat all zk child path url as new child
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexStocks committed May 29, 2021
1 parent 1a83480 commit f137724
Showing 1 changed file with 13 additions and 5 deletions.
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) {
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 < 30e9 {
tickerTTL = 30e9
}
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

0 comments on commit f137724

Please sign in to comment.