Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
spring-cloud-netflix
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
openSource
spring-cloud-netflix
Commits
b2d27a1d
Unverified
Commit
b2d27a1d
authored
Apr 10, 2018
by
Bertrand Renuart
Committed by
Spencer Gibb
Apr 10, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor HandlerMapping refresh into a single listener
fixes gh-2807
parent
406e112a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
54 deletions
+19
-54
ZuulProxyAutoConfiguration.java
...mework/cloud/netflix/zuul/ZuulProxyAutoConfiguration.java
+0
-49
ZuulServerAutoConfiguration.java
...ework/cloud/netflix/zuul/ZuulServerAutoConfiguration.java
+19
-5
No files found.
spring-cloud-netflix-zuul/src/main/java/org/springframework/cloud/netflix/zuul/ZuulProxyAutoConfiguration.java
View file @
b2d27a1d
...
...
@@ -31,10 +31,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass
;
import
org.springframework.cloud.client.actuator.HasFeatures
;
import
org.springframework.cloud.client.discovery.DiscoveryClient
;
import
org.springframework.cloud.client.discovery.event.HeartbeatEvent
;
import
org.springframework.cloud.client.discovery.event.HeartbeatMonitor
;
import
org.springframework.cloud.client.discovery.event.InstanceRegisteredEvent
;
import
org.springframework.cloud.client.discovery.event.ParentHeartbeatEvent
;
import
org.springframework.cloud.client.serviceregistry.Registration
;
import
org.springframework.cloud.commons.httpclient.ApacheHttpClientConnectionManagerFactory
;
import
org.springframework.cloud.commons.httpclient.ApacheHttpClientFactory
;
...
...
@@ -51,9 +47,6 @@ import org.springframework.cloud.netflix.zuul.filters.pre.PreDecorationFilter;
import
org.springframework.cloud.netflix.zuul.filters.route.RibbonCommandFactory
;
import
org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter
;
import
org.springframework.cloud.netflix.zuul.filters.route.SimpleHostRoutingFilter
;
import
org.springframework.cloud.netflix.zuul.web.ZuulHandlerMapping
;
import
org.springframework.context.ApplicationEvent
;
import
org.springframework.context.ApplicationListener
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Import
;
...
...
@@ -135,11 +128,6 @@ public class ZuulProxyAutoConfiguration extends ZuulServerAutoConfiguration {
}
@Bean
public
ApplicationListener
<
ApplicationEvent
>
zuulDiscoveryRefreshRoutesListener
()
{
return
new
ZuulDiscoveryRefreshListener
();
}
@Bean
@ConditionalOnMissingBean
(
ServiceRouteMapper
.
class
)
public
ServiceRouteMapper
serviceRouteMapper
()
{
return
new
SimpleServiceRouteMapper
();
...
...
@@ -190,41 +178,4 @@ public class ZuulProxyAutoConfiguration extends ZuulServerAutoConfiguration {
return
helper
;
}
}
private
static
class
ZuulDiscoveryRefreshListener
implements
ApplicationListener
<
ApplicationEvent
>
{
private
HeartbeatMonitor
monitor
=
new
HeartbeatMonitor
();
@Autowired
private
ZuulHandlerMapping
zuulHandlerMapping
;
@Override
public
void
onApplicationEvent
(
ApplicationEvent
event
)
{
if
(
event
instanceof
InstanceRegisteredEvent
)
{
reset
();
}
else
if
(
event
instanceof
ParentHeartbeatEvent
)
{
ParentHeartbeatEvent
e
=
(
ParentHeartbeatEvent
)
event
;
resetIfNeeded
(
e
.
getValue
());
}
else
if
(
event
instanceof
HeartbeatEvent
)
{
HeartbeatEvent
e
=
(
HeartbeatEvent
)
event
;
resetIfNeeded
(
e
.
getValue
());
}
}
private
void
resetIfNeeded
(
Object
value
)
{
if
(
this
.
monitor
.
update
(
value
))
{
reset
();
}
}
private
void
reset
()
{
this
.
zuulHandlerMapping
.
setDirty
(
true
);
}
}
}
spring-cloud-netflix-zuul/src/main/java/org/springframework/cloud/netflix/zuul/ZuulServerAutoConfiguration.java
View file @
b2d27a1d
...
...
@@ -32,6 +32,8 @@ import org.springframework.boot.web.servlet.error.ErrorController;
import
org.springframework.cloud.client.actuator.HasFeatures
;
import
org.springframework.cloud.client.discovery.event.HeartbeatEvent
;
import
org.springframework.cloud.client.discovery.event.HeartbeatMonitor
;
import
org.springframework.cloud.client.discovery.event.InstanceRegisteredEvent
;
import
org.springframework.cloud.client.discovery.event.ParentHeartbeatEvent
;
import
org.springframework.cloud.context.scope.refresh.RefreshScopeRefreshedEvent
;
import
org.springframework.cloud.netflix.ribbon.SpringClientFactory
;
import
org.springframework.cloud.netflix.zuul.filters.CompositeRouteLocator
;
...
...
@@ -238,16 +240,28 @@ public class ZuulServerAutoConfiguration {
public
void
onApplicationEvent
(
ApplicationEvent
event
)
{
if
(
event
instanceof
ContextRefreshedEvent
||
event
instanceof
RefreshScopeRefreshedEvent
||
event
instanceof
RoutesRefreshedEvent
)
{
this
.
zuulHandlerMapping
.
setDirty
(
true
);
||
event
instanceof
RoutesRefreshedEvent
||
event
instanceof
InstanceRegisteredEvent
)
{
reset
();
}
else
if
(
event
instanceof
HeartbeatEvent
)
{
if
(
this
.
heartbeatMonitor
.
update
(((
HeartbeatEvent
)
event
).
getValue
()))
{
this
.
zuulHandlerMapping
.
setDirty
(
true
);
else
if
(
event
instanceof
Parent
HeartbeatEvent
)
{
ParentHeartbeatEvent
e
=
(
ParentHeartbeatEvent
)
event
;
resetIfNeeded
(
e
.
getValue
()
);
}
else
if
(
event
instanceof
HeartbeatEvent
)
{
HeartbeatEvent
e
=
(
HeartbeatEvent
)
event
;
resetIfNeeded
(
e
.
getValue
());
}
}
private
void
resetIfNeeded
(
Object
value
)
{
if
(
this
.
heartbeatMonitor
.
update
(
value
))
{
reset
();
}
}
private
void
reset
()
{
this
.
zuulHandlerMapping
.
setDirty
(
true
);
}
}
}
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