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
5a5a1aaa
Commit
5a5a1aaa
authored
Oct 26, 2016
by
Ryan Baxter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
-Made spring-retry optional
-additional refactoring from changes in s-c-commons
parent
5a42cb1b
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
156 additions
and
12 deletions
+156
-12
pom.xml
pom.xml
+7
-0
pom.xml
spring-cloud-netflix-core/pom.xml
+8
-0
RibbonAutoConfiguration.java
...amework/cloud/netflix/ribbon/RibbonAutoConfiguration.java
+4
-0
RibbonLoadBalancedRetryPolicyFactory.java
.../netflix/ribbon/RibbonLoadBalancedRetryPolicyFactory.java
+2
-2
RibbonLoadBalancerClient.java
...mework/cloud/netflix/ribbon/RibbonLoadBalancerClient.java
+8
-10
SpringRetryDisabledTests.java
...mework/cloud/netflix/ribbon/SpringRetryDisabledTests.java
+63
-0
SpringRetryEnabledTests.java
...amework/cloud/netflix/ribbon/SpringRetryEnabledTests.java
+56
-0
pom.xml
spring-cloud-starter-ribbon/pom.xml
+8
-0
No files found.
pom.xml
View file @
5a5a1aaa
...
...
@@ -81,6 +81,13 @@
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-commons
</artifactId>
<type>
test-jar
</type>
<scope>
test
</scope>
<version>
${spring-cloud-commons.version}
</version>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-config-dependencies
</artifactId>
<version>
${spring-cloud-config.version}
</version>
<type>
pom
</type>
...
...
spring-cloud-netflix-core/pom.xml
View file @
5a5a1aaa
...
...
@@ -47,10 +47,12 @@
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-aop
</artifactId>
<optional>
true
</optional>
</dependency>
<dependency>
<groupId>
org.springframework.retry
</groupId>
<artifactId>
spring-retry
</artifactId>
<optional>
true
</optional>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
...
...
@@ -192,6 +194,12 @@
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-commons
</artifactId>
<type>
test-jar
</type>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.aspectj
</groupId>
<artifactId>
aspectjweaver
</artifactId>
<optional>
true
</optional>
...
...
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/ribbon/RibbonAutoConfiguration.java
View file @
5a5a1aaa
...
...
@@ -28,6 +28,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.boot.autoconfigure.AutoConfigureAfter
;
import
org.springframework.boot.autoconfigure.AutoConfigureBefore
;
import
org.springframework.boot.autoconfigure.condition.AnyNestedCondition
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
;
...
...
@@ -36,9 +37,11 @@ import org.springframework.cloud.client.loadbalancer.LoadBalancedRetryPolicyFact
import
org.springframework.cloud.client.loadbalancer.LoadBalancerAutoConfiguration
;
import
org.springframework.cloud.client.loadbalancer.LoadBalancerClient
;
import
org.springframework.cloud.client.loadbalancer.RestTemplateCustomizer
;
import
org.springframework.cloud.client.loadbalancer.RetryLoadBalancerInterceptor
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Conditional
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.retry.support.RetryTemplate
;
import
org.springframework.web.client.RestTemplate
;
import
com.netflix.client.IClient
;
...
...
@@ -80,6 +83,7 @@ public class RibbonAutoConfiguration {
}
@Bean
@ConditionalOnClass
(
name
=
"org.springframework.retry.support.RetryTemplate"
)
public
LoadBalancedRetryPolicyFactory
loadBalancedRetryPolicyFactory
(
SpringClientFactory
clientFactory
)
{
return
new
RibbonLoadBalancedRetryPolicyFactory
(
clientFactory
);
}
...
...
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/ribbon/RibbonLoadBalancedRetryPolicyFactory.java
View file @
5a5a1aaa
...
...
@@ -16,10 +16,10 @@
package
org
.
springframework
.
cloud
.
netflix
.
ribbon
;
import
org.springframework.cloud.client.ServiceInstance
;
import
org.springframework.cloud.client.loadbalancer.LoadBalanceChooser
;
import
org.springframework.cloud.client.loadbalancer.LoadBalancedRetryContext
;
import
org.springframework.cloud.client.loadbalancer.LoadBalancedRetryPolicy
;
import
org.springframework.cloud.client.loadbalancer.LoadBalancedRetryPolicyFactory
;
import
org.springframework.cloud.client.loadbalancer.ServiceInstanceChooser
;
import
org.springframework.http.HttpMethod
;
/**
...
...
@@ -34,7 +34,7 @@ public class RibbonLoadBalancedRetryPolicyFactory implements LoadBalancedRetryPo
}
@Override
public
LoadBalancedRetryPolicy
create
(
final
String
serviceId
,
final
LoadBal
anceChooser
loadBalanceChooser
)
{
public
LoadBalancedRetryPolicy
create
(
final
String
serviceId
,
final
ServiceInst
anceChooser
loadBalanceChooser
)
{
final
RibbonLoadBalancerContext
lbContext
=
this
.
clientFactory
.
getLoadBalancerContext
(
serviceId
);
return
new
LoadBalancedRetryPolicy
()
{
...
...
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/ribbon/RibbonLoadBalancerClient.java
View file @
5a5a1aaa
...
...
@@ -16,28 +16,26 @@
package
org
.
springframework
.
cloud
.
netflix
.
ribbon
;
import
com.netflix.client.config.IClientConfig
;
import
com.netflix.loadbalancer.ILoadBalancer
;
import
com.netflix.loadbalancer.Server
;
import
java.io.IOException
;
import
java.net.URI
;
import
java.util.Collections
;
import
java.util.Map
;
import
org.springframework.cloud.client.DefaultServiceInstance
;
import
org.springframework.cloud.client.ServiceInstance
;
import
org.springframework.cloud.client.loadbalancer.LoadBalancerClient
;
import
org.springframework.cloud.client.loadbalancer.LoadBalancerRequest
;
import
org.springframework.util.Assert
;
import
org.springframework.util.ReflectionUtils
;
import
org.springframework.web.util.UriComponentsBuilder
;
import
java.io.IOException
;
import
java.net.URI
;
import
java.util.Collections
;
import
java.util.Map
;
import
com.netflix.client.config.IClientConfig
;
import
com.netflix.loadbalancer.ILoadBalancer
;
import
com.netflix.loadbalancer.Server
;
/**
* @author Spencer Gibb
* @author Dave Syer
* @author Ryan Baxter
*/
public
class
RibbonLoadBalancerClient
implements
LoadBalancerClient
{
public
class
RibbonLoadBalancerClient
implements
LoadBalancerClient
{
private
SpringClientFactory
clientFactory
;
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/ribbon/SpringRetryDisabledTests.java
0 → 100644
View file @
5a5a1aaa
/*
*
* * Copyright 2013-2016 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.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package
org
.
springframework
.
cloud
.
netflix
.
ribbon
;
import
java.util.Map
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.boot.builder.SpringApplicationBuilder
;
import
org.springframework.cloud.ClassPathExclusions
;
import
org.springframework.cloud.FilteredClassPathRunner
;
import
org.springframework.cloud.client.loadbalancer.LoadBalancedRetryPolicyFactory
;
import
org.springframework.cloud.client.loadbalancer.LoadBalancerAutoConfiguration
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
static
org
.
hamcrest
.
MatcherAssert
.
assertThat
;
import
static
org
.
hamcrest
.
Matchers
.
hasSize
;
/**
* @author Ryan Baxter
*/
@RunWith
(
FilteredClassPathRunner
.
class
)
@ClassPathExclusions
({
"spring-retry-*.jar"
,
"spring-boot-starter-aop-*.jar"
})
public
class
SpringRetryDisabledTests
{
private
ConfigurableApplicationContext
context
;
@Before
public
void
setUp
()
{
context
=
new
SpringApplicationBuilder
().
web
(
false
)
.
sources
(
RibbonAutoConfiguration
.
class
,
LoadBalancerAutoConfiguration
.
class
).
run
();
}
@After
public
void
tearDown
()
{
if
(
context
!=
null
)
{
context
.
close
();
}
}
@Test
public
void
testLoadBalancedRetryFactoryBean
()
throws
Exception
{
Map
<
String
,
LoadBalancedRetryPolicyFactory
>
factories
=
context
.
getBeansOfType
(
LoadBalancedRetryPolicyFactory
.
class
);
assertThat
(
factories
.
values
(),
hasSize
(
0
));
}
}
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/ribbon/SpringRetryEnabledTests.java
0 → 100644
View file @
5a5a1aaa
/*
*
* * Copyright 2013-2016 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.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package
org
.
springframework
.
cloud
.
netflix
.
ribbon
;
import
java.util.Map
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.BeansException
;
import
org.springframework.cloud.client.loadbalancer.LoadBalancedRetryPolicyFactory
;
import
org.springframework.cloud.client.loadbalancer.LoadBalancerAutoConfiguration
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationContextAware
;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
static
org
.
hamcrest
.
MatcherAssert
.
assertThat
;
import
static
org
.
hamcrest
.
Matchers
.
instanceOf
;
import
static
org
.
hamcrest
.
collection
.
IsCollectionWithSize
.
hasSize
;
/**
* @author Ryan Baxter
*/
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@ContextConfiguration
(
classes
=
{
RibbonAutoConfiguration
.
class
,
LoadBalancerAutoConfiguration
.
class
})
public
class
SpringRetryEnabledTests
implements
ApplicationContextAware
{
private
ApplicationContext
context
;
@Test
public
void
testLoadBalancedRetryFactoryBean
()
throws
Exception
{
Map
<
String
,
LoadBalancedRetryPolicyFactory
>
factories
=
context
.
getBeansOfType
(
LoadBalancedRetryPolicyFactory
.
class
);
assertThat
(
factories
.
values
(),
hasSize
(
1
));
assertThat
(
factories
.
values
().
toArray
()[
0
],
instanceOf
(
RibbonLoadBalancedRetryPolicyFactory
.
class
));
}
@Override
public
void
setApplicationContext
(
ApplicationContext
context
)
throws
BeansException
{
this
.
context
=
context
;
}
}
spring-cloud-starter-ribbon/pom.xml
View file @
5a5a1aaa
...
...
@@ -21,6 +21,14 @@
</properties>
<dependencies>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-aop
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.retry
</groupId>
<artifactId>
spring-retry
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter
</artifactId>
</dependency>
...
...
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