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
26708908
Commit
26708908
authored
Mar 08, 2016
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Whitespace
parent
48c9d487
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
17 deletions
+22
-17
RibbonClientHttpRequestFactory.java
.../cloud/netflix/ribbon/RibbonClientHttpRequestFactory.java
+22
-17
No files found.
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/ribbon/RibbonClientHttpRequestFactory.java
View file @
26708908
...
@@ -38,39 +38,44 @@ public class RibbonClientHttpRequestFactory implements ClientHttpRequestFactory
...
@@ -38,39 +38,44 @@ public class RibbonClientHttpRequestFactory implements ClientHttpRequestFactory
private
final
SpringClientFactory
clientFactory
;
private
final
SpringClientFactory
clientFactory
;
private
LoadBalancerClient
loadBalancer
;
private
LoadBalancerClient
loadBalancer
;
public
RibbonClientHttpRequestFactory
(
SpringClientFactory
clientFactory
,
LoadBalancerClient
loadBalancer
)
{
public
RibbonClientHttpRequestFactory
(
SpringClientFactory
clientFactory
,
LoadBalancerClient
loadBalancer
)
{
this
.
clientFactory
=
clientFactory
;
this
.
clientFactory
=
clientFactory
;
this
.
loadBalancer
=
loadBalancer
;
this
.
loadBalancer
=
loadBalancer
;
}
}
@Override
@Override
@SuppressWarnings
(
"deprecation"
)
@SuppressWarnings
(
"deprecation"
)
public
ClientHttpRequest
createRequest
(
URI
originalUri
,
HttpMethod
httpMethod
)
public
ClientHttpRequest
createRequest
(
URI
originalUri
,
HttpMethod
httpMethod
)
throws
IOException
{
throws
IOException
{
String
serviceId
=
originalUri
.
getHost
();
String
serviceId
=
originalUri
.
getHost
();
if
(
serviceId
==
null
)
{
if
(
serviceId
==
null
)
{
throw
new
IOException
(
"Invalid hostname in the URI ["
+
originalUri
.
toASCIIString
()
+
"]"
);
throw
new
IOException
(
}
"Invalid hostname in the URI ["
+
originalUri
.
toASCIIString
()
+
"]"
);
ServiceInstance
instance
=
loadBalancer
.
choose
(
serviceId
);
}
ServiceInstance
instance
=
this
.
loadBalancer
.
choose
(
serviceId
);
if
(
instance
==
null
)
{
if
(
instance
==
null
)
{
throw
new
IllegalStateException
(
"No instances available for "
+
serviceId
);
throw
new
IllegalStateException
(
"No instances available for "
+
serviceId
);
}
}
URI
uri
=
this
.
loadBalancer
.
reconstructURI
(
instance
,
originalUri
);
URI
uri
=
this
.
loadBalancer
.
reconstructURI
(
instance
,
originalUri
);
//@formatter:off
IClientConfig
clientConfig
=
this
.
clientFactory
.
getClientConfig
(
instance
.
getServiceId
());
IClientConfig
clientConfig
=
this
.
clientFactory
RestClient
client
=
this
.
clientFactory
.
getClient
(
instance
.
getServiceId
(),
RestClient
.
class
);
.
getClientConfig
(
instance
.
getServiceId
());
RestClient
client
=
this
.
clientFactory
.
getClient
(
instance
.
getServiceId
(),
RestClient
.
class
);
HttpRequest
.
Verb
verb
=
HttpRequest
.
Verb
.
valueOf
(
httpMethod
.
name
());
HttpRequest
.
Verb
verb
=
HttpRequest
.
Verb
.
valueOf
(
httpMethod
.
name
());
RibbonLoadBalancerContext
context
=
this
.
clientFactory
.
getLoadBalancerContext
(
serviceId
);
RibbonLoadBalancerContext
context
=
this
.
clientFactory
.
getLoadBalancerContext
(
serviceId
);
Server
server
=
null
;
Server
server
=
null
;
if
(
instance
instanceof
RibbonServer
)
{
if
(
instance
instanceof
RibbonServer
)
{
server
=
((
RibbonServer
)
instance
).
getServer
();
server
=
((
RibbonServer
)
instance
).
getServer
();
}
}
RibbonStatsRecorder
statsRecorder
=
new
RibbonStatsRecorder
(
context
,
server
);
RibbonStatsRecorder
statsRecorder
=
new
RibbonStatsRecorder
(
context
,
server
);
//@formatter:on
return
new
RibbonHttpRequest
(
uri
,
verb
,
client
,
clientConfig
,
statsRecorder
);
return
new
RibbonHttpRequest
(
uri
,
verb
,
client
,
clientConfig
,
statsRecorder
);
}
}
...
...
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