This is an automated email from the ASF dual-hosted git repository.
alexstocks pushed a commit to branch 1.5
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git
The following commit(s) were added to refs/heads/1.5 by this push:
new cdae603 fix issue 1166: treat all zk child path url as new child
(#1225)
cdae603 is described below
commit cdae603bd7b60f462557dfee69192b43c067b58b
Author: Xin.Zh <[email protected]>
AuthorDate: Sun May 30 16:11:52 2021 +0800
fix issue 1166: treat all zk child path url as new child (#1225)
---
remoting/zookeeper/listener.go | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/remoting/zookeeper/listener.go b/remoting/zookeeper/listener.go
index 216fb8c..66885e9 100644
--- a/remoting/zookeeper/listener.go
+++ b/remoting/zookeeper/listener.go
@@ -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)
@@ -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)