Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
apollo
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
apollo
Commits
469c1c18
Commit
469c1c18
authored
May 21, 2019
by
bkblack
Committed by
Jason Song
May 21, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
https://github.com/ctripcorp/apollo/issues/2111
(#2255)
parent
989f37b1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
21 deletions
+28
-21
apollo-configservice/src/main/java/com/ctrip/framework/apollo/configservice/controller/NotificationControllerV2.java
...lo/configservice/controller/NotificationControllerV2.java
+28
-21
No files found.
apollo-configservice/src/main/java/com/ctrip/framework/apollo/configservice/controller/NotificationControllerV2.java
View file @
469c1c18
...
@@ -132,6 +132,34 @@ public class NotificationControllerV2 implements ReleaseMessageListener {
...
@@ -132,6 +132,34 @@ public class NotificationControllerV2 implements ReleaseMessageListener {
Set
<
String
>
watchedKeys
=
Sets
.
newHashSet
(
watchedKeysMap
.
values
());
Set
<
String
>
watchedKeys
=
Sets
.
newHashSet
(
watchedKeysMap
.
values
());
/**
* 1、set deferredResult before the check, for avoid more waiting
* If the check before setting deferredResult,it may receive a notification the next time
* when method handleMessage is executed between check and set deferredResult.
*/
deferredResultWrapper
.
onTimeout
(()
->
logWatchedKeys
(
watchedKeys
,
"Apollo.LongPoll.TimeOutKeys"
));
deferredResultWrapper
.
onCompletion
(()
->
{
//unregister all keys
for
(
String
key
:
watchedKeys
)
{
deferredResults
.
remove
(
key
,
deferredResultWrapper
);
}
logWatchedKeys
(
watchedKeys
,
"Apollo.LongPoll.CompletedKeys"
);
});
//register all keys
for
(
String
key
:
watchedKeys
)
{
this
.
deferredResults
.
put
(
key
,
deferredResultWrapper
);
}
logWatchedKeys
(
watchedKeys
,
"Apollo.LongPoll.RegisteredKeys"
);
logger
.
debug
(
"Listening {} from appId: {}, cluster: {}, namespace: {}, datacenter: {}"
,
watchedKeys
,
appId
,
cluster
,
namespaces
,
dataCenter
);
/**
* 2、check new release
*/
List
<
ReleaseMessage
>
latestReleaseMessages
=
List
<
ReleaseMessage
>
latestReleaseMessages
=
releaseMessageService
.
findLatestReleaseMessagesGroupByMessages
(
watchedKeys
);
releaseMessageService
.
findLatestReleaseMessagesGroupByMessages
(
watchedKeys
);
...
@@ -149,26 +177,6 @@ public class NotificationControllerV2 implements ReleaseMessageListener {
...
@@ -149,26 +177,6 @@ public class NotificationControllerV2 implements ReleaseMessageListener {
if
(!
CollectionUtils
.
isEmpty
(
newNotifications
))
{
if
(!
CollectionUtils
.
isEmpty
(
newNotifications
))
{
deferredResultWrapper
.
setResult
(
newNotifications
);
deferredResultWrapper
.
setResult
(
newNotifications
);
}
else
{
deferredResultWrapper
.
onTimeout
(()
->
logWatchedKeys
(
watchedKeys
,
"Apollo.LongPoll.TimeOutKeys"
));
deferredResultWrapper
.
onCompletion
(()
->
{
//unregister all keys
for
(
String
key
:
watchedKeys
)
{
deferredResults
.
remove
(
key
,
deferredResultWrapper
);
}
logWatchedKeys
(
watchedKeys
,
"Apollo.LongPoll.CompletedKeys"
);
});
//register all keys
for
(
String
key
:
watchedKeys
)
{
this
.
deferredResults
.
put
(
key
,
deferredResultWrapper
);
}
logWatchedKeys
(
watchedKeys
,
"Apollo.LongPoll.RegisteredKeys"
);
logger
.
debug
(
"Listening {} from appId: {}, cluster: {}, namespace: {}, datacenter: {}"
,
watchedKeys
,
appId
,
cluster
,
namespaces
,
dataCenter
);
}
}
return
deferredResultWrapper
.
getResult
();
return
deferredResultWrapper
.
getResult
();
...
@@ -308,4 +316,3 @@ public class NotificationControllerV2 implements ReleaseMessageListener {
...
@@ -308,4 +316,3 @@ public class NotificationControllerV2 implements ReleaseMessageListener {
}
}
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment