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
fa4d9700
Commit
fa4d9700
authored
Oct 21, 2014
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tweaks
parent
cf615282
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
13 deletions
+16
-13
LoadBalancerClient.java
...amework/cloud/client/loadbalancer/LoadBalancerClient.java
+4
-4
RibbonAutoConfiguration.java
...amework/cloud/netflix/ribbon/RibbonAutoConfiguration.java
+4
-3
RibbonLoadBalancerClient.java
...mework/cloud/netflix/ribbon/RibbonLoadBalancerClient.java
+2
-0
SpringClientFactory.java
...ngframework/cloud/netflix/ribbon/SpringClientFactory.java
+5
-5
EurekaRibbonClientPreprocessor.java
...netflix/ribbon/eureka/EurekaRibbonClientPreprocessor.java
+1
-1
No files found.
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/client/loadbalancer/LoadBalancerClient.java
View file @
fa4d9700
...
...
@@ -8,16 +8,16 @@ import org.springframework.cloud.client.ServiceInstance;
public
interface
LoadBalancerClient
{
/**
* Choose a {@see ServiceInstance} from the LoadBalancer for the specified service
* @param serviceId
The serviceId to use
to look up the LoadBalancer
* @return
* @param serviceId
the service id
to look up the LoadBalancer
* @return
a ServiceInstance that matches the serviceId
*/
public
ServiceInstance
choose
(
String
serviceId
);
/**
* Choose a {@see ServiceInstance} from the LoadBalancer for the specified service
* @param serviceId
The serviceId to use
to look up the LoadBalancer
* @param serviceId
the service id
to look up the LoadBalancer
* @param request allows implementations to execute pre and post actions such as incrementing metrics
* @return
* @return
the result of the LoadBalancerRequest callback on the selected ServiceInstance
*/
public
<
T
>
T
choose
(
String
serviceId
,
LoadBalancerRequest
<
T
>
request
);
}
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/ribbon/RibbonAutoConfiguration.java
View file @
fa4d9700
...
...
@@ -9,7 +9,6 @@ import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
import
org.springframework.cloud.client.loadbalancer.LoadBalancerClient
;
import
org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration
;
import
org.springframework.cloud.netflix.ribbon.eureka.EurekaRibbonClientPreprocessor
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.http.client.ClientHttpRequestInterceptor
;
...
...
@@ -18,7 +17,9 @@ import org.springframework.web.client.RestTemplate;
import
com.netflix.loadbalancer.BaseLoadBalancer
;
/**
* Auto configuration for Ribbon (client side load balancing)
* @author Spencer Gibb
* @author Dave Syer
*/
@Configuration
@AutoConfigureAfter
(
EurekaClientAutoConfiguration
.
class
)
...
...
@@ -28,9 +29,8 @@ public class RibbonAutoConfiguration {
private
List
<
BaseLoadBalancer
>
balancers
=
Collections
.
emptyList
();
@Autowired
private
Eureka
RibbonClientPreprocessor
clientPreprocessor
;
private
RibbonClientPreprocessor
clientPreprocessor
;
// TODO: need to find a default for this?
@Autowired
private
SpringClientFactory
springClientFactory
;
...
...
@@ -59,6 +59,7 @@ public class RibbonAutoConfiguration {
protected
static
class
DefaultRibbonClientPreprocessor
{
@Bean
@ConditionalOnMissingBean
(
RibbonClientPreprocessor
.
class
)
public
RibbonClientPreprocessor
ribbonClientPreprocessor
()
{
return
new
RibbonClientPreprocessor
()
{
@Override
...
...
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/ribbon/RibbonLoadBalancerClient.java
View file @
fa4d9700
...
...
@@ -26,6 +26,8 @@ public class RibbonLoadBalancerClient implements LoadBalancerClient {
private
Map
<
String
,
ILoadBalancer
>
balancers
=
new
HashMap
<
String
,
ILoadBalancer
>();
public
RibbonLoadBalancerClient
(
RibbonClientPreprocessor
ribbonClientPreprocessor
,
SpringClientFactory
clientFactory
,
List
<
BaseLoadBalancer
>
balancers
)
{
this
.
ribbonClientPreprocessor
=
ribbonClientPreprocessor
;
this
.
clientFactory
=
clientFactory
;
for
(
BaseLoadBalancer
balancer
:
balancers
)
{
this
.
balancers
.
put
(
balancer
.
getName
(),
balancer
);
}
...
...
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/ribbon/SpringClientFactory.java
View file @
fa4d9700
...
...
@@ -3,12 +3,12 @@ package org.springframework.cloud.netflix.ribbon;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
import
lombok.extern.slf4j.Slf4j
;
import
com.netflix.client.AbstractLoadBalancerAwareClient
;
import
com.netflix.client.ClientException
;
import
com.netflix.client.IClient
;
import
com.netflix.client.IClientConfigAware
;
import
lombok.extern.slf4j.Slf4j
;
import
com.netflix.client.config.CommonClientConfigKey
;
import
com.netflix.client.config.DefaultClientConfigImpl
;
import
com.netflix.client.config.IClientConfig
;
...
...
@@ -44,9 +44,9 @@ public class SpringClientFactory {
"A Rest Client with this name is already registered. Please use a different name"
);
}
try
{
String
clientClassName
=
(
String
)
clientConfig
.
get
Property
(
CommonClientConfigKey
.
ClientClassName
);
String
clientClassName
=
(
String
)
clientConfig
.
get
(
CommonClientConfigKey
.
ClientClassName
);
client
=
(
IClient
<?,
?>)
instantiateInstanceWithClientConfig
(
clientClassName
,
clientConfig
);
boolean
initializeNFLoadBalancer
=
Boolean
.
parseBoolean
(
clientConfig
.
get
Property
(
boolean
initializeNFLoadBalancer
=
Boolean
.
parseBoolean
(
clientConfig
.
get
(
CommonClientConfigKey
.
InitializeNFLoadBalancer
,
DefaultClientConfigImpl
.
DEFAULT_ENABLE_LOADBALANCER
).
toString
());
if
(
initializeNFLoadBalancer
)
{
loadBalancer
=
getNamedLoadBalancer
(
restClientName
,
clientConfig
.
getClass
());
...
...
@@ -149,7 +149,7 @@ public class SpringClientFactory {
}
ILoadBalancer
lb
=
null
;
try
{
String
loadBalancerClassName
=
(
String
)
clientConfig
.
get
Property
(
CommonClientConfigKey
.
NFLoadBalancerClassName
);
String
loadBalancerClassName
=
(
String
)
clientConfig
.
get
(
CommonClientConfigKey
.
NFLoadBalancerClassName
);
lb
=
(
ILoadBalancer
)
instantiateInstanceWithClientConfig
(
loadBalancerClassName
,
clientConfig
);
namedLBMap
.
put
(
name
,
lb
);
log
.
info
(
"Client:"
+
name
...
...
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/ribbon/eureka/EurekaRibbonClientPreprocessor.java
View file @
fa4d9700
...
...
@@ -6,8 +6,8 @@ import static com.netflix.client.config.CommonClientConfigKey.NFLoadBalancerRule
import
static
com
.
netflix
.
client
.
config
.
CommonClientConfigKey
.
NIWSServerListClassName
;
import
static
com
.
netflix
.
client
.
config
.
CommonClientConfigKey
.
NIWSServerListFilterClassName
;
import
org.springframework.cloud.netflix.ribbon.SpringClientFactory
;
import
org.springframework.cloud.netflix.ribbon.RibbonClientPreprocessor
;
import
org.springframework.cloud.netflix.ribbon.SpringClientFactory
;
import
com.netflix.config.ConfigurationManager
;
import
com.netflix.config.DeploymentContext.ContextKey
;
...
...
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