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
196abf2a
Unverified
Commit
196abf2a
authored
Apr 10, 2018
by
Spencer Gibb
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'brenuart-gh2807'
parents
406e112a
b2d27a1d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
55 deletions
+20
-55
ZuulProxyAutoConfiguration.java
...mework/cloud/netflix/zuul/ZuulProxyAutoConfiguration.java
+0
-49
ZuulServerAutoConfiguration.java
...ework/cloud/netflix/zuul/ZuulServerAutoConfiguration.java
+20
-6
No files found.
spring-cloud-netflix-zuul/src/main/java/org/springframework/cloud/netflix/zuul/ZuulProxyAutoConfiguration.java
View file @
196abf2a
...
...
@@ -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 @
196abf2a
...
...
@@ -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
ParentHeartbeatEvent
)
{
ParentHeartbeatEvent
e
=
(
ParentHeartbeatEvent
)
event
;
resetIfNeeded
(
e
.
getValue
());
}
else
if
(
event
instanceof
HeartbeatEvent
)
{
if
(
this
.
heartbeatMonitor
.
update
(((
HeartbeatEvent
)
event
).
getValue
()))
{
this
.
zuulHandlerMapping
.
setDirty
(
true
);
}
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