diff --git a/registry/zookeeper/listener.go b/registry/zookeeper/listener.go index 19f25693c82b6390c7c54e47d13a4e9e36fa85ce..7d58cee1220b9aedba353d929ca1e936cf9366f2 100644 --- a/registry/zookeeper/listener.go +++ b/registry/zookeeper/listener.go @@ -46,10 +46,15 @@ func (l *RegistryDataListener) AddInterestedURL(url *common.URL) { func (l *RegistryDataListener) DataChange(eventType remoting.Event) bool { // Intercept the last bit - url := eventType.Path[strings.Index(eventType.Path, "/providers/")+len("/providers/"):] + index := strings.Index(eventType.Path, "/providers/") + if index == -1 { + logger.Warn("Listen with no url, event.path={%v}", eventType.Path) + return false + } + url := eventType.Path[index+len("/providers/"):] serviceURL, err := common.NewURL(context.TODO(), url) if err != nil { - logger.Errorf("Listen NewURL(r{%s}) = error{%v}", url, err) + logger.Errorf("Listen NewURL(r{%s}) = error{%v} eventType.Path={%v}", url, err, eventType.Path) return false } for _, v := range l.interestedURL { diff --git a/registry/zookeeper/registry.go b/registry/zookeeper/registry.go index e2fca972306aa380e3f584b093e1315e1468a45e..ff57eb638aa8919720b9eeed1cb4603cc2928cf2 100644 --- a/registry/zookeeper/registry.go +++ b/registry/zookeeper/registry.go @@ -381,7 +381,11 @@ func (r *zkRegistry) registerTempZookeeperNode(root string, node string) error { } zkPath, err = r.client.RegisterTemp(root, node) if err != nil { - logger.Errorf("RegisterTempNode(root{%s}, node{%s}) = error{%v}", root, node, perrors.WithStack(err)) + if err == zk.ErrNodeExists { + logger.Warnf("RegisterTempNode(root{%s}, node{%s}) = error{%v}", root, node, perrors.WithStack(err)) + } else { + logger.Errorf("RegisterTempNode(root{%s}, node{%s}) = error{%v}", root, node, perrors.WithStack(err)) + } return perrors.WithMessagef(err, "RegisterTempNode(root{%s}, node{%s})", root, node) } logger.Debugf("create a zookeeper node:%s", zkPath) diff --git a/remoting/zookeeper/listener.go b/remoting/zookeeper/listener.go index 3df87ed4f603956a653cec692031dee94639de16..d9efd4fed1db7bac69ac5368b08cb0bd28aa7dea 100644 --- a/remoting/zookeeper/listener.go +++ b/remoting/zookeeper/listener.go @@ -208,6 +208,20 @@ func (l *ZkEventListener) listenDirEvent(zkPath string, listener remoting.DataLi // listen l service node dubboPath := path.Join(zkPath, c) + + //Save the path to avoid listen repeatly + l.pathMapLock.Lock() + _, ok := l.pathMap[dubboPath] + l.pathMapLock.Unlock() + if ok { + logger.Warnf("@zkPath %s has already been listened.", zkPath) + continue + } + + l.pathMapLock.Lock() + l.pathMap[dubboPath] = struct{}{} + l.pathMapLock.Unlock() + content, _, err := l.client.Conn.Get(dubboPath) if err != nil { logger.Errorf("Get new node path {%v} 's content error,message is {%v}", dubboPath, perrors.WithStack(err))