Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
2
22a7f0099
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Summer2022
22a7f0099
Commits
3b5ea5ce
Commit
3b5ea5ce
authored
Aug 19, 2019
by
高辛格
Browse files
Options
Downloads
Patches
Plain Diff
fix typo
parent
5f022b85
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
remoting/zookeeper/listener.go
+14
-16
14 additions, 16 deletions
remoting/zookeeper/listener.go
with
14 additions
and
16 deletions
remoting/zookeeper/listener.go
+
14
−
16
View file @
3b5ea5ce
...
@@ -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
(
dubbo
Path
)
{
if
l
.
ListenServiceNodeEvent
(
zk
Path
)
{
listener
.
DataChange
(
remoting
.
Event
{
Path
:
dubbo
Path
,
Action
:
remoting
.
EventTypeDel
})
listener
.
DataChange
(
remoting
.
Event
{
Path
:
zk
Path
,
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
//li
s
ten 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::Registe
r
/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
(
dubbo
Path
)
{
if
l
.
ListenServiceNodeEvent
(
zk
Path
)
{
listener
.
DataChange
(
remoting
.
Event
{
Path
:
dubbo
Path
,
Action
:
remoting
.
EventTypeDel
})
listener
.
DataChange
(
remoting
.
Event
{
Path
:
zk
Path
,
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
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment