Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
wenxuwan committed Aug 5, 2020
1 parent c618e0b commit 1fdaa05
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions remoting/zookeeper/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,10 @@ func (l *ZkEventListener) listenDirEvent(conf *common.URL, zkPath string, listen
if err == nil {
ttl = timeout
} else {
logger.Warnf("wrong configuration for ttl, error:=%+v", err)
logger.Warnf("wrong configuration for registry ttl, error:=%+v", err)
}
defer close(event)
for {
// Periodically update provider information
ticker := time.NewTicker(timeout)
// get current children for a zkPath
children, childEventCh, err := l.client.GetChildrenW(zkPath)
if err != nil {
Expand Down Expand Up @@ -316,20 +314,29 @@ func (l *ZkEventListener) listenDirEvent(conf *common.URL, zkPath string, listen
}(dubboPath, listener)
}
}
select {
case <-ticker.C:
l.handleZkNodeEvent(zkEvent.Path, children, listener)
case zkEvent = <-childEventCh:
logger.Warnf("get a zookeeper zkEvent{type:%s, server:%s, path:%s, state:%d-%s, err:%s}",
zkEvent.Type.String(), zkEvent.Server, zkEvent.Path, zkEvent.State, StateToString(zkEvent.State), zkEvent.Err)
if zkEvent.Type != zk.EventNodeChildrenChanged {
continue
// Periodically update provider information
ticker := time.NewTicker(ttl)
WATCH:
for {
select {
case <-ticker.C:
l.handleZkNodeEvent(zkEvent.Path, children, listener)
case zkEvent = <-childEventCh:
logger.Warnf("get a zookeeper zkEvent{type:%s, server:%s, path:%s, state:%d-%s, err:%s}",
zkEvent.Type.String(), zkEvent.Server, zkEvent.Path, zkEvent.State, StateToString(zkEvent.State), zkEvent.Err)
ticker.Stop()
if zkEvent.Type != zk.EventNodeChildrenChanged {
break WATCH
}
l.handleZkNodeEvent(zkEvent.Path, children, listener)
break WATCH
case <-l.client.Done():
logger.Warnf("client.done(), listen(path{%s}) goroutine exit now...", zkPath)
ticker.Stop()
return
}
l.handleZkNodeEvent(zkEvent.Path, children, listener)
case <-l.client.Done():
logger.Warnf("client.done(), listen(path{%s}) goroutine exit now...", zkPath)
return
}

}
}

Expand Down

0 comments on commit 1fdaa05

Please sign in to comment.