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
0cd544b4
Unverified
Commit
0cd544b4
authored
May 19, 2017
by
Spencer Gibb
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'lalib-gh-1720'
parents
aa4d9d62
6362be81
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
4 deletions
+33
-4
ZuulProperties.java
...gframework/cloud/netflix/zuul/filters/ZuulProperties.java
+11
-1
SimpleHostRoutingFilter.java
...d/netflix/zuul/filters/route/SimpleHostRoutingFilter.java
+4
-2
SimpleHostRoutingFilterTests.java
...flix/zuul/filters/route/SimpleHostRoutingFilterTests.java
+18
-1
No files found.
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/filters/ZuulProperties.java
View file @
0cd544b4
/*
* Copyright 2013-201
5
the original author or authors.
* Copyright 2013-201
7
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -33,6 +33,7 @@ import java.util.List;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
java.util.Set
;
import
java.util.concurrent.TimeUnit
;
import
static
com
.
netflix
.
hystrix
.
HystrixCommandProperties
.
ExecutionIsolationStrategy
.
SEMAPHORE
;
...
...
@@ -40,6 +41,7 @@ import static com.netflix.hystrix.HystrixCommandProperties.ExecutionIsolationStr
* @author Spencer Gibb
* @author Dave Syer
* @author Mathias Düsterhöft
* @author Bilal Alp
*/
@Data
@ConfigurationProperties
(
"zuul"
)
...
...
@@ -326,6 +328,14 @@ public class ZuulProperties {
* The maximum number of connections that can be used by a single route.
*/
private
int
maxPerRouteConnections
=
20
;
/**
* The lifetime for the connection pool.
*/
private
long
timeToLive
=
-
1
;
/**
* The time unit for timeToLive.
*/
private
TimeUnit
timeUnit
=
TimeUnit
.
MILLISECONDS
;
}
@Data
...
...
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/filters/route/SimpleHostRoutingFilter.java
View file @
0cd544b4
/*
* Copyright 2013-201
5
the original author or authors.
* Copyright 2013-201
7
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -92,6 +92,7 @@ import static org.springframework.cloud.netflix.zuul.filters.support.FilterConst
*
* @author Spencer Gibb
* @author Dave Syer
* @author Bilal Alp
*/
public
class
SimpleHostRoutingFilter
extends
ZuulFilter
{
...
...
@@ -235,7 +236,8 @@ public class SimpleHostRoutingFilter extends ZuulFilter {
}
final
Registry
<
ConnectionSocketFactory
>
registry
=
registryBuilder
.
build
();
this
.
connectionManager
=
new
PoolingHttpClientConnectionManager
(
registry
);
this
.
connectionManager
=
new
PoolingHttpClientConnectionManager
(
registry
,
null
,
null
,
null
,
hostProperties
.
getTimeToLive
(),
hostProperties
.
getTimeUnit
());
this
.
connectionManager
.
setMaxTotal
(
this
.
hostProperties
.
getMaxTotalConnections
());
this
.
connectionManager
.
setDefaultMaxPerRoute
(
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/zuul/filters/route/SimpleHostRoutingFilterTests.java
View file @
0cd544b4
...
...
@@ -19,8 +19,10 @@ package org.springframework.cloud.netflix.zuul.filters.route;
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.lang.reflect.Field
;
import
java.nio.charset.Charset
;
import
java.util.Arrays
;
import
java.util.concurrent.TimeUnit
;
import
java.util.zip.GZIPOutputStream
;
import
javax.servlet.http.HttpServletResponse
;
...
...
@@ -49,6 +51,7 @@ import org.springframework.mock.web.MockHttpServletRequest;
import
org.springframework.test.annotation.DirtiesContext
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
org.springframework.util.LinkedMultiValueMap
;
import
org.springframework.util.ReflectionUtils
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
...
...
@@ -87,11 +90,25 @@ public class SimpleHostRoutingFilterTests {
@Test
public
void
connectionPropertiesAreApplied
()
{
addEnvironment
(
this
.
context
,
"zuul.host.maxTotalConnections=100"
,
"zuul.host.maxPerRouteConnections=10"
);
addEnvironment
(
this
.
context
,
"zuul.host.maxTotalConnections=100"
,
"zuul.host.maxPerRouteConnections=10"
,
"zuul.host.timeToLive=5"
,
"zuul.host.timeUnit=SECONDS"
);
setupContext
();
PoolingHttpClientConnectionManager
connMgr
=
getFilter
().
newConnectionManager
();
assertEquals
(
100
,
connMgr
.
getMaxTotal
());
assertEquals
(
10
,
connMgr
.
getDefaultMaxPerRoute
());
Object
pool
=
getField
(
connMgr
,
"pool"
);
Long
timeToLive
=
getField
(
pool
,
"timeToLive"
);
TimeUnit
timeUnit
=
getField
(
pool
,
"tunit"
);
assertEquals
(
new
Long
(
5
),
timeToLive
);
assertEquals
(
TimeUnit
.
SECONDS
,
timeUnit
);
}
protected
<
T
>
T
getField
(
Object
target
,
String
name
)
{
Field
field
=
ReflectionUtils
.
findField
(
target
.
getClass
(),
name
);
ReflectionUtils
.
makeAccessible
(
field
);
Object
value
=
ReflectionUtils
.
getField
(
field
,
target
);
return
(
T
)
value
;
}
@Test
...
...
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