Skip to content
Snippets Groups Projects
Commit 3b5ea5ce authored by 高辛格's avatar 高辛格
Browse files

fix typo

parent 5f022b85
No related branches found
No related tags found
No related merge requests found
...@@ -47,9 +47,11 @@ func NewZkEventListener(client *ZookeeperClient) *ZkEventListener { ...@@ -47,9 +47,11 @@ func NewZkEventListener(client *ZookeeperClient) *ZkEventListener {
pathMap: make(map[string]struct{}), pathMap: make(map[string]struct{}),
} }
} }
func (l *ZkEventListener) SetClient(client *ZookeeperClient) { func (l *ZkEventListener) SetClient(client *ZookeeperClient) {
l.client = client l.client = client
} }
func (l *ZkEventListener) ListenServiceNodeEvent(zkPath string, listener ...remoting.DataListener) bool { func (l *ZkEventListener) ListenServiceNodeEvent(zkPath string, listener ...remoting.DataListener) bool {
l.wg.Add(1) l.wg.Add(1)
defer l.wg.Done() defer l.wg.Done()
...@@ -72,7 +74,6 @@ func (l *ZkEventListener) ListenServiceNodeEvent(zkPath string, listener ...remo ...@@ -72,7 +74,6 @@ func (l *ZkEventListener) ListenServiceNodeEvent(zkPath string, listener ...remo
content, _, _ := l.client.Conn.Get(zkEvent.Path) content, _, _ := l.client.Conn.Get(zkEvent.Path)
listener[0].DataChange(remoting.Event{Path: zkEvent.Path, Action: remoting.EvnetTypeUpdate, Content: string(content)}) listener[0].DataChange(remoting.Event{Path: zkEvent.Path, Action: remoting.EvnetTypeUpdate, Content: string(content)})
} }
case zk.EventNodeCreated: case zk.EventNodeCreated:
logger.Warnf("zk.ExistW(key{%s}) = event{EventNodeCreated}", zkPath) logger.Warnf("zk.ExistW(key{%s}) = event{EventNodeCreated}", zkPath)
if len(listener) > 0 { if len(listener) > 0 {
...@@ -100,7 +101,6 @@ func (l *ZkEventListener) handleZkNodeEvent(zkPath string, children []string, li ...@@ -100,7 +101,6 @@ func (l *ZkEventListener) handleZkNodeEvent(zkPath string, children []string, li
return true return true
} }
} }
return false return false
} }
...@@ -130,14 +130,14 @@ func (l *ZkEventListener) handleZkNodeEvent(zkPath string, children []string, li ...@@ -130,14 +130,14 @@ func (l *ZkEventListener) handleZkNodeEvent(zkPath string, children []string, li
continue continue
} }
// listen l service node // listen l service node
go func(node string) { go func(node string, zkPath string, listener remoting.DataListener) {
logger.Infof("delete zkNode{%s}", node) logger.Infof("delete zkNode{%s}", node)
if l.ListenServiceNodeEvent(node, listener) { if l.ListenServiceNodeEvent(node, listener) {
logger.Infof("delete content{%s}", node) logger.Infof("delete content{%s}", node)
listener.DataChange(remoting.Event{Path: zkPath, Action: remoting.EventTypeDel}) listener.DataChange(remoting.Event{Path: zkPath, Action: remoting.EventTypeDel})
} }
logger.Warnf("listenSelf(zk path{%s}) goroutine exit now", zkPath) logger.Warnf("listenSelf(zk path{%s}) goroutine exit now", zkPath)
}(newNode) }(newNode, zkPath, listener)
} }
// old node was deleted // old node was deleted
...@@ -205,7 +205,6 @@ func (l *ZkEventListener) listenDirEvent(zkPath string, listener remoting.DataLi ...@@ -205,7 +205,6 @@ func (l *ZkEventListener) listenDirEvent(zkPath string, listener remoting.DataLi
} }
failTimes = 0 failTimes = 0
for _, c := range children { for _, c := range children {
// listen l service node // listen l service node
dubboPath := path.Join(zkPath, c) dubboPath := path.Join(zkPath, c)
content, _, err := l.client.Conn.Get(dubboPath) content, _, err := l.client.Conn.Get(dubboPath)
...@@ -217,14 +216,14 @@ func (l *ZkEventListener) listenDirEvent(zkPath string, listener remoting.DataLi ...@@ -217,14 +216,14 @@ func (l *ZkEventListener) listenDirEvent(zkPath string, listener remoting.DataLi
continue continue
} }
logger.Infof("listen dubbo service key{%s}", dubboPath) logger.Infof("listen dubbo service key{%s}", dubboPath)
go func(zkPath string) { go func(zkPath string, listener remoting.DataListener) {
if l.ListenServiceNodeEvent(dubboPath) { if l.ListenServiceNodeEvent(zkPath) {
listener.DataChange(remoting.Event{Path: dubboPath, Action: remoting.EventTypeDel}) listener.DataChange(remoting.Event{Path: zkPath, Action: remoting.EventTypeDel})
} }
logger.Warnf("listenSelf(zk path{%s}) goroutine exit now", zkPath) logger.Warnf("listenSelf(zk path{%s}) goroutine exit now", zkPath)
}(dubboPath) }(dubboPath, listener)
//liten sub path recursive //listen sub path recursive
go func(zkPath string, listener remoting.DataListener) { go func(zkPath string, listener remoting.DataListener) {
l.listenDirEvent(zkPath, listener) l.listenDirEvent(zkPath, listener)
logger.Warnf("listenDirEvent(zkPath{%s}) goroutine exit now", zkPath) logger.Warnf("listenDirEvent(zkPath{%s}) goroutine exit now", zkPath)
...@@ -310,7 +309,7 @@ func timeSecondDuration(sec int) time.Duration { ...@@ -310,7 +309,7 @@ func timeSecondDuration(sec int) time.Duration {
return time.Duration(sec) * time.Second return time.Duration(sec) * time.Second
} }
// this func is invoked by ZkConsumerRegistry::Registe/ZkConsumerRegistry::get/ZkConsumerRegistry::getListener // this func is invoked by ZkConsumerRegistry::Register/ZkConsumerRegistry::get/ZkConsumerRegistry::getListener
// registry.go:Listen -> listenServiceEvent -> listenDirEvent -> ListenServiceNodeEvent // registry.go:Listen -> listenServiceEvent -> listenDirEvent -> ListenServiceNodeEvent
// | // |
// --------> ListenServiceNodeEvent // --------> ListenServiceNodeEvent
...@@ -341,7 +340,6 @@ func (l *ZkEventListener) ListenServiceEvent(zkPath string, listener remoting.Da ...@@ -341,7 +340,6 @@ func (l *ZkEventListener) ListenServiceEvent(zkPath string, listener remoting.Da
} }
for _, c := range children { for _, c := range children {
// listen l service node // listen l service node
dubboPath = path.Join(zkPath, c) dubboPath = path.Join(zkPath, c)
content, _, err := l.client.Conn.Get(dubboPath) content, _, err := l.client.Conn.Get(dubboPath)
...@@ -352,12 +350,12 @@ func (l *ZkEventListener) ListenServiceEvent(zkPath string, listener remoting.Da ...@@ -352,12 +350,12 @@ func (l *ZkEventListener) ListenServiceEvent(zkPath string, listener remoting.Da
continue continue
} }
logger.Infof("listen dubbo service key{%s}", dubboPath) logger.Infof("listen dubbo service key{%s}", dubboPath)
go func(zkPath string) { go func(zkPath string, listener remoting.DataListener) {
if l.ListenServiceNodeEvent(dubboPath) { if l.ListenServiceNodeEvent(zkPath) {
listener.DataChange(remoting.Event{Path: dubboPath, Action: remoting.EventTypeDel}) listener.DataChange(remoting.Event{Path: zkPath, Action: remoting.EventTypeDel})
} }
logger.Warnf("listenSelf(zk path{%s}) goroutine exit now", zkPath) logger.Warnf("listenSelf(zk path{%s}) goroutine exit now", zkPath)
}(dubboPath) }(dubboPath, listener)
} }
logger.Infof("listen dubbo path{%s}", zkPath) logger.Infof("listen dubbo path{%s}", zkPath)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment