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
c31f700b
Commit
c31f700b
authored
Jan 19, 2015
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use serviceId as prefix for RibbonCommand hystrix command key
Fixes gh-160
parent
a0b73fe7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
4 deletions
+8
-4
RibbonCommand.java
...ework/cloud/netflix/zuul/filters/route/RibbonCommand.java
+3
-1
RibbonRoutingFilter.java
...cloud/netflix/zuul/filters/route/RibbonRoutingFilter.java
+5
-3
No files found.
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/filters/route/RibbonCommand.java
View file @
c31f700b
...
@@ -31,6 +31,7 @@ import com.netflix.config.DynamicIntProperty;
...
@@ -31,6 +31,7 @@ import com.netflix.config.DynamicIntProperty;
import
com.netflix.config.DynamicPropertyFactory
;
import
com.netflix.config.DynamicPropertyFactory
;
import
com.netflix.hystrix.HystrixCommand
;
import
com.netflix.hystrix.HystrixCommand
;
import
com.netflix.hystrix.HystrixCommandGroupKey
;
import
com.netflix.hystrix.HystrixCommandGroupKey
;
import
com.netflix.hystrix.HystrixCommandKey
;
import
com.netflix.hystrix.HystrixCommandProperties
;
import
com.netflix.hystrix.HystrixCommandProperties
;
import
com.netflix.hystrix.HystrixCommandProperties.ExecutionIsolationStrategy
;
import
com.netflix.hystrix.HystrixCommandProperties.ExecutionIsolationStrategy
;
import
com.netflix.niws.client.http.RestClient
;
import
com.netflix.niws.client.http.RestClient
;
...
@@ -87,7 +88,8 @@ public class RibbonCommand extends HystrixCommand<HttpResponse> {
...
@@ -87,7 +88,8 @@ public class RibbonCommand extends HystrixCommand<HttpResponse> {
HystrixCommandProperties
.
Setter
setter
=
HystrixCommandProperties
.
Setter
()
HystrixCommandProperties
.
Setter
setter
=
HystrixCommandProperties
.
Setter
()
.
withExecutionIsolationStrategy
(
ExecutionIsolationStrategy
.
SEMAPHORE
)
.
withExecutionIsolationStrategy
(
ExecutionIsolationStrategy
.
SEMAPHORE
)
.
withExecutionIsolationSemaphoreMaxConcurrentRequests
(
value
.
get
());
.
withExecutionIsolationSemaphoreMaxConcurrentRequests
(
value
.
get
());
return
Setter
.
withGroupKey
(
HystrixCommandGroupKey
.
Factory
.
asKey
(
commandKey
))
return
Setter
.
withGroupKey
(
HystrixCommandGroupKey
.
Factory
.
asKey
(
"RibbonCommand"
))
.
andCommandKey
(
HystrixCommandKey
.
Factory
.
asKey
(
commandKey
+
"RibbonCommand"
))
.
andCommandPropertiesDefaults
(
setter
);
.
andCommandPropertiesDefaults
(
setter
);
}
}
...
...
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/filters/route/RibbonRoutingFilter.java
View file @
c31f700b
...
@@ -29,6 +29,7 @@ import javax.servlet.http.HttpServletResponse;
...
@@ -29,6 +29,7 @@ import javax.servlet.http.HttpServletResponse;
import
javax.ws.rs.core.MultivaluedMap
;
import
javax.ws.rs.core.MultivaluedMap
;
import
lombok.extern.apachecommons.CommonsLog
;
import
lombok.extern.apachecommons.CommonsLog
;
import
org.springframework.cloud.netflix.ribbon.SpringClientFactory
;
import
org.springframework.cloud.netflix.ribbon.SpringClientFactory
;
import
org.springframework.cloud.netflix.zuul.filters.ProxyRequestHelper
;
import
org.springframework.cloud.netflix.zuul.filters.ProxyRequestHelper
;
import
org.springframework.util.LinkedMultiValueMap
;
import
org.springframework.util.LinkedMultiValueMap
;
...
@@ -102,9 +103,10 @@ public class RibbonRoutingFilter extends ZuulFilter {
...
@@ -102,9 +103,10 @@ public class RibbonRoutingFilter extends ZuulFilter {
}
}
// remove double slashes
// remove double slashes
uri
=
uri
.
replace
(
"//"
,
"/"
);
uri
=
uri
.
replace
(
"//"
,
"/"
);
String
service
=
(
String
)
context
.
get
(
"serviceId"
);
try
{
try
{
HttpResponse
response
=
forward
(
restClient
,
verb
,
uri
,
headers
,
params
,
HttpResponse
response
=
forward
(
restClient
,
service
,
verb
,
uri
,
headers
,
params
,
requestEntity
);
requestEntity
);
setResponse
(
response
);
setResponse
(
response
);
return
response
;
return
response
;
...
@@ -116,12 +118,12 @@ public class RibbonRoutingFilter extends ZuulFilter {
...
@@ -116,12 +118,12 @@ public class RibbonRoutingFilter extends ZuulFilter {
return
null
;
return
null
;
}
}
private
HttpResponse
forward
(
RestClient
restClient
,
Verb
verb
,
String
uri
,
private
HttpResponse
forward
(
RestClient
restClient
,
String
service
,
Verb
verb
,
String
uri
,
MultiValueMap
<
String
,
String
>
headers
,
MultiValueMap
<
String
,
String
>
params
,
MultiValueMap
<
String
,
String
>
headers
,
MultiValueMap
<
String
,
String
>
params
,
InputStream
requestEntity
)
throws
Exception
{
InputStream
requestEntity
)
throws
Exception
{
Map
<
String
,
Object
>
info
=
this
.
helper
.
debug
(
verb
.
verb
(),
uri
,
headers
,
params
,
Map
<
String
,
Object
>
info
=
this
.
helper
.
debug
(
verb
.
verb
(),
uri
,
headers
,
params
,
requestEntity
);
requestEntity
);
RibbonCommand
command
=
new
RibbonCommand
(
restClient
,
verb
,
uri
,
RibbonCommand
command
=
new
RibbonCommand
(
service
,
restClient
,
verb
,
uri
,
convertHeaders
(
headers
),
convertHeaders
(
params
),
requestEntity
);
convertHeaders
(
headers
),
convertHeaders
(
params
),
requestEntity
);
try
{
try
{
HttpResponse
response
=
command
.
execute
();
HttpResponse
response
=
command
.
execute
();
...
...
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