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
50b1c482
Commit
50b1c482
authored
Oct 17, 2014
by
Spencer Gibb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
renamed ServerListInitializer to RibbonClientPreprocessor as it is a bit more descriptive
parent
6654d320
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
29 additions
and
26 deletions
+29
-26
FeignConfigurer.java
.../springframework/cloud/netflix/feign/FeignConfigurer.java
+3
-3
RibbonAutoConfiguration.java
...amework/cloud/netflix/ribbon/RibbonAutoConfiguration.java
+5
-5
RibbonClientPreprocessor.java
...mework/cloud/netflix/ribbon/RibbonClientPreprocessor.java
+4
-2
RibbonLoadBalancerClient.java
...mework/cloud/netflix/ribbon/RibbonLoadBalancerClient.java
+2
-2
EurekaRibbonClientPreprocessor.java
...netflix/ribbon/eureka/EurekaRibbonClientPreprocessor.java
+7
-6
RibbonEurekaAutoConfiguration.java
.../netflix/ribbon/eureka/RibbonEurekaAutoConfiguration.java
+3
-3
RibbonRoutingFilter.java
...cloud/netflix/zuul/filters/route/RibbonRoutingFilter.java
+2
-2
EurekaRibbonClientPreprocessorTests.java
...ix/ribbon/eureka/EurekaRibbonClientPreprocessorTests.java
+3
-3
No files found.
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/feign/FeignConfigurer.java
View file @
50b1c482
...
...
@@ -7,7 +7,7 @@ import feign.codec.Decoder;
import
feign.codec.Encoder
;
import
feign.ribbon.LoadBalancingTarget
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cloud.netflix.ribbon.
ServerListInitialize
r
;
import
org.springframework.cloud.netflix.ribbon.
RibbonClientPreprocesso
r
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.cloud.netflix.archaius.ConfigurableEnvironmentConfiguration
;
...
...
@@ -22,7 +22,7 @@ public class FeignConfigurer {
ConfigurableEnvironmentConfiguration
envConfig
;
//FIXME: howto enforce this?
@Autowired
ServerListInitializer
serverListInitialize
r
;
RibbonClientPreprocessor
ribbonClientPreprocesso
r
;
@Autowired
Decoder
decoder
;
...
...
@@ -52,7 +52,7 @@ public class FeignConfigurer {
protected
<
T
>
T
loadBalance
(
Feign
.
Builder
builder
,
Class
<
T
>
type
,
String
schemeName
)
{
String
name
=
URI
.
create
(
schemeName
).
getHost
();
serverListInitializer
.
initialize
(
name
);
ribbonClientPreprocessor
.
preprocess
(
name
);
return
builder
.
target
(
LoadBalancingTarget
.
create
(
type
,
schemeName
));
}
...
...
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/ribbon/RibbonAutoConfiguration.java
View file @
50b1c482
...
...
@@ -5,7 +5,7 @@ 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.EurekaRibbon
Initialize
r
;
import
org.springframework.cloud.netflix.ribbon.eureka.EurekaRibbon
ClientPreprocesso
r
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.http.client.ClientHttpRequestInterceptor
;
...
...
@@ -28,7 +28,7 @@ public class RibbonAutoConfiguration {
private
List
<
BaseLoadBalancer
>
balancers
=
Collections
.
emptyList
();
@Autowired
(
required
=
false
)
private
EurekaRibbon
Initializer
initialize
r
;
private
EurekaRibbon
ClientPreprocessor
clientPreprocesso
r
;
@Bean
@ConditionalOnMissingBean
(
RestTemplate
.
class
)
...
...
@@ -52,10 +52,10 @@ public class RibbonAutoConfiguration {
}
@Bean
public
ServerListInitializer
serverListInitialize
r
()
{
return
new
ServerListInitialize
r
()
{
public
RibbonClientPreprocessor
ribbonClientPreprocesso
r
()
{
return
new
RibbonClientPreprocesso
r
()
{
@Override
public
void
initialize
(
String
serviceId
)
{
public
void
preprocess
(
String
serviceId
)
{
//no-op
}
};
...
...
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/ribbon/
ServerListInitialize
r.java
→
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/ribbon/
RibbonClientPreprocesso
r.java
View file @
50b1c482
package
org
.
springframework
.
cloud
.
netflix
.
ribbon
;
/**
* Allows different service discovery implementations to configure ribbon prior to usage.
* TODO: this could potentially be done via AOP
* @author Spencer Gibb
*/
public
interface
ServerListInitialize
r
{
public
void
initialize
(
String
serviceId
);
public
interface
RibbonClientPreprocesso
r
{
public
void
preprocess
(
String
serviceId
);
}
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/ribbon/RibbonLoadBalancerClient.java
View file @
50b1c482
...
...
@@ -19,7 +19,7 @@ import com.netflix.loadbalancer.Server;
public
class
RibbonLoadBalancerClient
implements
LoadBalancerClient
{
@Autowired
private
ServerListInitializer
serverListInitialize
r
;
private
RibbonClientPreprocessor
ribbonClientPreprocesso
r
;
@Autowired
private
SpringClientFactory
clientFactory
;
...
...
@@ -34,7 +34,7 @@ public class RibbonLoadBalancerClient implements LoadBalancerClient {
@Override
public
ServiceInstance
choose
(
String
serviceId
)
{
serverListInitializer
.
initialize
(
serviceId
);
ribbonClientPreprocessor
.
preprocess
(
serviceId
);
ILoadBalancer
loadBalancer
=
this
.
balancers
.
get
(
serviceId
);
if
(
loadBalancer
==
null
)
{
loadBalancer
=
clientFactory
.
getNamedLoadBalancer
(
serviceId
);
...
...
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/ribbon/eureka/EurekaRibbon
Initialize
r.java
→
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/ribbon/eureka/EurekaRibbon
ClientPreprocesso
r.java
View file @
50b1c482
...
...
@@ -7,7 +7,7 @@ import static com.netflix.client.config.CommonClientConfigKey.NIWSServerListClas
import
static
com
.
netflix
.
client
.
config
.
CommonClientConfigKey
.
NIWSServerListFilterClassName
;
import
org.springframework.cloud.netflix.ribbon.SpringClientFactory
;
import
org.springframework.cloud.netflix.ribbon.
ServerListInitialize
r
;
import
org.springframework.cloud.netflix.ribbon.
RibbonClientPreprocesso
r
;
import
com.netflix.config.ConfigurationManager
;
import
com.netflix.config.DeploymentContext.ContextKey
;
...
...
@@ -20,24 +20,25 @@ import com.netflix.loadbalancer.ZoneAvoidanceRule;
import
com.netflix.niws.loadbalancer.DiscoveryEnabledNIWSServerList
;
/**
* Convenience class that sets up some configuration defaults for eureka-discovered ribbon
* clients.
* Preprocessor that configures defaults for eureka-discovered ribbon clients.
* Such as: @zone, NIWSServerListClassName, DeploymentContextBasedVipAddresses,
* NFLoadBalancerRuleClassName, NIWSServerListFilterClassName and more
*
* @author Spencer Gibb
* @author Dave Syer
*/
public
class
EurekaRibbon
Initializer
implements
ServerListInitialize
r
{
public
class
EurekaRibbon
ClientPreprocessor
implements
RibbonClientPreprocesso
r
{
private
EurekaClientConfig
clientConfig
;
private
SpringClientFactory
clientFactory
;
public
EurekaRibbon
Initialize
r
(
EurekaClientConfig
clientConfig
,
SpringClientFactory
clientFactory
)
{
public
EurekaRibbon
ClientPreprocesso
r
(
EurekaClientConfig
clientConfig
,
SpringClientFactory
clientFactory
)
{
this
.
clientConfig
=
clientConfig
;
this
.
clientFactory
=
clientFactory
;
}
@Override
public
void
initialize
(
String
serviceId
)
{
public
void
preprocess
(
String
serviceId
)
{
if
(
clientConfig
!=
null
&&
ConfigurationManager
.
getDeploymentContext
().
getValue
(
ContextKey
.
zone
)
==
null
)
{
String
[]
zones
=
clientConfig
.
getAvailabilityZones
(
clientConfig
.
getRegion
());
...
...
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/ribbon/eureka/RibbonEurekaAutoConfiguration.java
View file @
50b1c482
...
...
@@ -22,7 +22,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.cloud.netflix.ribbon.SpringClientFactory
;
import
org.springframework.cloud.netflix.ribbon.RibbonAutoConfiguration
;
import
org.springframework.cloud.netflix.ribbon.
ServerListInitialize
r
;
import
org.springframework.cloud.netflix.ribbon.
RibbonClientPreprocesso
r
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
...
...
@@ -44,7 +44,7 @@ public class RibbonEurekaAutoConfiguration {
private
EurekaClientConfig
clientConfig
;
@Bean
public
ServerListInitializer
serverListInitialize
r
(
SpringClientFactory
clientFactory
)
{
return
new
EurekaRibbon
Initialize
r
(
clientConfig
,
clientFactory
);
public
RibbonClientPreprocessor
ribbonClientPreprocesso
r
(
SpringClientFactory
clientFactory
)
{
return
new
EurekaRibbon
ClientPreprocesso
r
(
clientConfig
,
clientFactory
);
}
}
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/filters/route/RibbonRoutingFilter.java
View file @
50b1c482
...
...
@@ -17,7 +17,7 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
org.springframework.boot.actuate.trace.TraceRepository
;
import
org.springframework.cloud.netflix.ribbon.SpringClientFactory
;
import
org.springframework.cloud.netflix.ribbon.
ServerListInitialize
r
;
import
org.springframework.cloud.netflix.ribbon.
RibbonClientPreprocesso
r
;
import
org.springframework.cloud.netflix.zuul.RibbonCommand
;
import
org.springframework.cloud.netflix.zuul.SpringFilter
;
import
org.springframework.util.StringUtils
;
...
...
@@ -71,7 +71,7 @@ public class RibbonRoutingFilter extends SpringFilter {
String
serviceId
=
(
String
)
context
.
get
(
"serviceId"
);
getBean
(
ServerListInitializer
.
class
).
initialize
(
serviceId
);
getBean
(
RibbonClientPreprocessor
.
class
).
preprocess
(
serviceId
);
RestClient
restClient
=
getBean
(
SpringClientFactory
.
class
).
namedClient
(
serviceId
,
RestClient
.
class
);
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/ribbon/eureka/EurekaRibbon
Initialize
rTests.java
→
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/ribbon/eureka/EurekaRibbon
ClientPreprocesso
rTests.java
View file @
50b1c482
...
...
@@ -34,7 +34,7 @@ import com.netflix.loadbalancer.ZoneAwareLoadBalancer;
* @author Dave Syer
*
*/
public
class
EurekaRibbon
Initialize
rTests
{
public
class
EurekaRibbon
ClientPreprocesso
rTests
{
@After
public
void
close
()
{
...
...
@@ -46,9 +46,9 @@ public class EurekaRibbonInitializerTests {
EurekaClientConfigBean
client
=
new
EurekaClientConfigBean
();
client
.
getAvailabilityZones
().
put
(
client
.
getRegion
(),
"foo"
);
SpringClientFactory
clientFactory
=
new
SpringClientFactory
();
EurekaRibbon
Initializer
initializer
=
new
EurekaRibbonInitialize
r
(
EurekaRibbon
ClientPreprocessor
clientPreprocessor
=
new
EurekaRibbonClientPreprocesso
r
(
client
,
clientFactory
);
initializer
.
initialize
(
"service"
);
clientPreprocessor
.
preprocess
(
"service"
);
ILoadBalancer
balancer
=
clientFactory
.
getNamedLoadBalancer
(
"service"
);
assertNotNull
(
balancer
);
@SuppressWarnings
(
"unchecked"
)
...
...
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