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
94c73da9
Commit
94c73da9
authored
Dec 22, 2015
by
Spencer Gibb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use new InetUtils bean to determin nic.
Allows for more fine-grained configuration of what to ignore.
parent
03f6d12e
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
111 additions
and
62 deletions
+111
-62
EurekaClientAutoConfiguration.java
...k/cloud/netflix/eureka/EurekaClientAutoConfiguration.java
+3
-2
EurekaInstanceConfigBean.java
...mework/cloud/netflix/eureka/EurekaInstanceConfigBean.java
+18
-6
DiscoveryClientConfigServiceAutoConfigurationTests.java
...g/DiscoveryClientConfigServiceAutoConfigurationTests.java
+3
-1
DiscoveryClientConfigServiceBootstrapConfigurationTests.java
...coveryClientConfigServiceBootstrapConfigurationTests.java
+3
-1
EurekaClientAutoConfigurationTests.java
...ud/netflix/eureka/EurekaClientAutoConfigurationTests.java
+10
-9
EurekaInstanceConfigBeanTests.java
...k/cloud/netflix/eureka/EurekaInstanceConfigBeanTests.java
+15
-7
InstanceInfoFactoryTests.java
...mework/cloud/netflix/eureka/InstanceInfoFactoryTests.java
+15
-10
RibbonClientPreprocessorOverridesIntegrationTests.java
...on/RibbonClientPreprocessorOverridesIntegrationTests.java
+2
-1
RibbonClientsPreprocessorIntegrationTests.java
...lix/ribbon/RibbonClientsPreprocessorIntegrationTests.java
+2
-1
EurekaRibbonClientConfigurationTests.java
...x/ribbon/eureka/EurekaRibbonClientConfigurationTests.java
+10
-4
EurekaRibbonClientPreprocessorIntegrationTests.java
...ureka/EurekaRibbonClientPreprocessorIntegrationTests.java
+2
-1
RibbonClientPreprocessorIntegrationTests.java
...bbon/eureka/RibbonClientPreprocessorIntegrationTests.java
+9
-5
RibbonClientDefaultConfigurationTestsConfig.java
...bon/test/RibbonClientDefaultConfigurationTestsConfig.java
+14
-13
SidecarConfiguration.java
...framework/cloud/netflix/sidecar/SidecarConfiguration.java
+5
-1
No files found.
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/eureka/EurekaClientAutoConfiguration.java
View file @
94c73da9
...
@@ -41,6 +41,7 @@ import org.springframework.cloud.client.actuator.HasFeatures;
...
@@ -41,6 +41,7 @@ import org.springframework.cloud.client.actuator.HasFeatures;
import
org.springframework.cloud.client.discovery.DiscoveryClient
;
import
org.springframework.cloud.client.discovery.DiscoveryClient
;
import
org.springframework.cloud.client.discovery.noop.NoopDiscoveryClientAutoConfiguration
;
import
org.springframework.cloud.client.discovery.noop.NoopDiscoveryClientAutoConfiguration
;
import
org.springframework.cloud.context.scope.refresh.RefreshScope
;
import
org.springframework.cloud.context.scope.refresh.RefreshScope
;
import
org.springframework.cloud.util.InetUtils
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Conditional
;
import
org.springframework.context.annotation.Conditional
;
...
@@ -96,8 +97,8 @@ public class EurekaClientAutoConfiguration {
...
@@ -96,8 +97,8 @@ public class EurekaClientAutoConfiguration {
@Bean
@Bean
@ConditionalOnMissingBean
(
value
=
EurekaInstanceConfig
.
class
,
search
=
SearchStrategy
.
CURRENT
)
@ConditionalOnMissingBean
(
value
=
EurekaInstanceConfig
.
class
,
search
=
SearchStrategy
.
CURRENT
)
public
EurekaInstanceConfigBean
eurekaInstanceConfigBean
()
{
public
EurekaInstanceConfigBean
eurekaInstanceConfigBean
(
InetUtils
inetUtils
)
{
EurekaInstanceConfigBean
instance
=
new
EurekaInstanceConfigBean
();
EurekaInstanceConfigBean
instance
=
new
EurekaInstanceConfigBean
(
inetUtils
);
instance
.
setNonSecurePort
(
this
.
nonSecurePort
);
instance
.
setNonSecurePort
(
this
.
nonSecurePort
);
instance
.
setInstanceId
(
getDefaultInstanceId
(
this
.
env
));
instance
.
setInstanceId
(
getDefaultInstanceId
(
this
.
env
));
if
(
this
.
managementPort
!=
this
.
nonSecurePort
&&
this
.
managementPort
!=
0
)
{
if
(
this
.
managementPort
!=
this
.
nonSecurePort
&&
this
.
managementPort
!=
0
)
{
...
...
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/eureka/EurekaInstanceConfigBean.java
View file @
94c73da9
...
@@ -21,14 +21,13 @@ import java.util.Map;
...
@@ -21,14 +21,13 @@ import java.util.Map;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.cloud.util.InetUtils
;
import
org.springframework.cloud.util.InetUtils.HostInfo
;
import
org.springframework.cloud.util.InetUtils.HostInfo
;
import
com.netflix.appinfo.DataCenterInfo
;
import
com.netflix.appinfo.DataCenterInfo
;
import
com.netflix.appinfo.InstanceInfo.InstanceStatus
;
import
com.netflix.appinfo.InstanceInfo.InstanceStatus
;
import
com.netflix.appinfo.MyDataCenterInfo
;
import
com.netflix.appinfo.MyDataCenterInfo
;
import
static
org
.
springframework
.
cloud
.
util
.
InetUtils
.
getFirstNonLoopbackHostInfo
;
import
lombok.AccessLevel
;
import
lombok.AccessLevel
;
import
lombok.Data
;
import
lombok.Data
;
import
lombok.Getter
;
import
lombok.Getter
;
...
@@ -44,7 +43,11 @@ public class EurekaInstanceConfigBean implements CloudEurekaInstanceConfig {
...
@@ -44,7 +43,11 @@ public class EurekaInstanceConfigBean implements CloudEurekaInstanceConfig {
@Getter
(
AccessLevel
.
PRIVATE
)
@Getter
(
AccessLevel
.
PRIVATE
)
@Setter
(
AccessLevel
.
PRIVATE
)
@Setter
(
AccessLevel
.
PRIVATE
)
private
HostInfo
hostInfo
=
getFirstNonLoopbackHostInfo
();
private
HostInfo
hostInfo
;
@Getter
(
AccessLevel
.
PRIVATE
)
@Setter
(
AccessLevel
.
PRIVATE
)
private
InetUtils
inetUtils
;
@Value
(
"${spring.application.name:unknown}"
)
@Value
(
"${spring.application.name:unknown}"
)
private
String
appname
=
"unknown"
;
private
String
appname
=
"unknown"
;
...
@@ -79,7 +82,7 @@ public class EurekaInstanceConfigBean implements CloudEurekaInstanceConfig {
...
@@ -79,7 +82,7 @@ public class EurekaInstanceConfigBean implements CloudEurekaInstanceConfig {
private
DataCenterInfo
dataCenterInfo
=
new
MyDataCenterInfo
(
private
DataCenterInfo
dataCenterInfo
=
new
MyDataCenterInfo
(
DataCenterInfo
.
Name
.
MyOwn
);
DataCenterInfo
.
Name
.
MyOwn
);
private
String
ipAddress
=
this
.
hostInfo
.
getIpAddress
()
;
private
String
ipAddress
;
private
String
statusPageUrlPath
=
"/info"
;
private
String
statusPageUrlPath
=
"/info"
;
...
@@ -97,7 +100,7 @@ public class EurekaInstanceConfigBean implements CloudEurekaInstanceConfig {
...
@@ -97,7 +100,7 @@ public class EurekaInstanceConfigBean implements CloudEurekaInstanceConfig {
private
String
namespace
=
"eureka"
;
private
String
namespace
=
"eureka"
;
private
String
hostname
=
this
.
hostInfo
.
getHostname
()
;
private
String
hostname
;
private
boolean
preferIpAddress
=
false
;
private
boolean
preferIpAddress
=
false
;
...
@@ -107,6 +110,15 @@ public class EurekaInstanceConfigBean implements CloudEurekaInstanceConfig {
...
@@ -107,6 +110,15 @@ public class EurekaInstanceConfigBean implements CloudEurekaInstanceConfig {
return
getHostName
(
false
);
return
getHostName
(
false
);
}
}
private
EurekaInstanceConfigBean
()
{}
public
EurekaInstanceConfigBean
(
InetUtils
inetUtils
)
{
this
.
inetUtils
=
inetUtils
;
this
.
hostInfo
=
this
.
inetUtils
.
findFirstNonLoopbackHostInfo
();
this
.
ipAddress
=
this
.
hostInfo
.
getIpAddress
();
this
.
hostname
=
this
.
hostInfo
.
getHostname
();
}
@Override
@Override
public
String
getInstanceId
()
{
public
String
getInstanceId
()
{
if
(
this
.
instanceId
==
null
&&
this
.
metadataMap
!=
null
)
{
if
(
this
.
instanceId
==
null
&&
this
.
metadataMap
!=
null
)
{
...
@@ -129,7 +141,7 @@ public class EurekaInstanceConfigBean implements CloudEurekaInstanceConfig {
...
@@ -129,7 +141,7 @@ public class EurekaInstanceConfigBean implements CloudEurekaInstanceConfig {
public
String
getHostName
(
boolean
refresh
)
{
public
String
getHostName
(
boolean
refresh
)
{
if
(
refresh
)
{
if
(
refresh
)
{
boolean
originalOverride
=
this
.
hostInfo
.
override
;
boolean
originalOverride
=
this
.
hostInfo
.
override
;
this
.
hostInfo
=
get
FirstNonLoopbackHostInfo
();
this
.
hostInfo
=
this
.
inetUtils
.
find
FirstNonLoopbackHostInfo
();
this
.
hostInfo
.
setOverride
(
originalOverride
);
this
.
hostInfo
.
setOverride
(
originalOverride
);
this
.
ipAddress
=
this
.
hostInfo
.
getIpAddress
();
this
.
ipAddress
=
this
.
hostInfo
.
getIpAddress
();
if
(!
this
.
hostInfo
.
override
)
{
if
(!
this
.
hostInfo
.
override
)
{
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/config/DiscoveryClientConfigServiceAutoConfigurationTests.java
View file @
94c73da9
...
@@ -24,6 +24,7 @@ import org.springframework.boot.test.EnvironmentTestUtils;
...
@@ -24,6 +24,7 @@ import org.springframework.boot.test.EnvironmentTestUtils;
import
org.springframework.cloud.config.client.ConfigClientProperties
;
import
org.springframework.cloud.config.client.ConfigClientProperties
;
import
org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration
;
import
org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration
;
import
org.springframework.cloud.netflix.eureka.EurekaDiscoveryClientConfiguration
;
import
org.springframework.cloud.netflix.eureka.EurekaDiscoveryClientConfiguration
;
import
org.springframework.cloud.util.UtilAutoConfiguration
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
...
@@ -75,7 +76,8 @@ public class DiscoveryClientConfigServiceAutoConfigurationTests {
...
@@ -75,7 +76,8 @@ public class DiscoveryClientConfigServiceAutoConfigurationTests {
private
void
setup
(
String
...
env
)
{
private
void
setup
(
String
...
env
)
{
AnnotationConfigApplicationContext
parent
=
new
AnnotationConfigApplicationContext
();
AnnotationConfigApplicationContext
parent
=
new
AnnotationConfigApplicationContext
();
EnvironmentTestUtils
.
addEnvironment
(
parent
,
env
);
EnvironmentTestUtils
.
addEnvironment
(
parent
,
env
);
parent
.
register
(
PropertyPlaceholderAutoConfiguration
.
class
,
parent
.
register
(
UtilAutoConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
,
DiscoveryClientConfigServiceBootstrapConfiguration
.
class
,
DiscoveryClientConfigServiceBootstrapConfiguration
.
class
,
EnvironmentKnobbler
.
class
,
ConfigClientProperties
.
class
);
EnvironmentKnobbler
.
class
,
ConfigClientProperties
.
class
);
parent
.
refresh
();
parent
.
refresh
();
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/config/DiscoveryClientConfigServiceBootstrapConfigurationTests.java
View file @
94c73da9
...
@@ -27,6 +27,7 @@ import org.mockito.Mockito;
...
@@ -27,6 +27,7 @@ import org.mockito.Mockito;
import
org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration
;
import
org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration
;
import
org.springframework.boot.test.EnvironmentTestUtils
;
import
org.springframework.boot.test.EnvironmentTestUtils
;
import
org.springframework.cloud.config.client.ConfigClientProperties
;
import
org.springframework.cloud.config.client.ConfigClientProperties
;
import
org.springframework.cloud.util.UtilAutoConfiguration
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
com.netflix.appinfo.InstanceInfo
;
import
com.netflix.appinfo.InstanceInfo
;
...
@@ -124,7 +125,8 @@ public class DiscoveryClientConfigServiceBootstrapConfigurationTests {
...
@@ -124,7 +125,8 @@ public class DiscoveryClientConfigServiceBootstrapConfigurationTests {
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
env
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
env
);
this
.
context
.
getDefaultListableBeanFactory
().
registerSingleton
(
this
.
context
.
getDefaultListableBeanFactory
().
registerSingleton
(
"eurekaClient"
,
this
.
client
);
"eurekaClient"
,
this
.
client
);
this
.
context
.
register
(
PropertyPlaceholderAutoConfiguration
.
class
,
this
.
context
.
register
(
UtilAutoConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
,
DiscoveryClientConfigServiceBootstrapConfiguration
.
class
,
DiscoveryClientConfigServiceBootstrapConfiguration
.
class
,
ConfigClientProperties
.
class
);
ConfigClientProperties
.
class
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/eureka/EurekaClientAutoConfigurationTests.java
View file @
94c73da9
...
@@ -23,6 +23,7 @@ import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfigurati
...
@@ -23,6 +23,7 @@ import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfigurati
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.boot.test.EnvironmentTestUtils
;
import
org.springframework.boot.test.EnvironmentTestUtils
;
import
org.springframework.cloud.autoconfigure.RefreshAutoConfiguration
;
import
org.springframework.cloud.autoconfigure.RefreshAutoConfiguration
;
import
org.springframework.cloud.util.UtilAutoConfiguration
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Import
;
import
org.springframework.context.annotation.Import
;
...
@@ -66,8 +67,8 @@ public class EurekaClientAutoConfigurationTests {
...
@@ -66,8 +67,8 @@ public class EurekaClientAutoConfigurationTests {
@Test
@Test
public
void
nonSecurePort
()
{
public
void
nonSecurePort
()
{
testNonSecurePort
(
"PORT"
);
testNonSecurePort
(
"PORT"
);
assertEquals
(
"eurekaClient"
,
assertEquals
(
"eurekaClient"
,
this
.
context
.
getBeanDefinition
(
"eurekaClient"
)
this
.
context
.
getBeanDefinition
(
"eurekaClient"
)
.
getFactoryMethodName
());
.
getFactoryMethodName
());
}
}
@Test
@Test
...
@@ -77,8 +78,8 @@ public class EurekaClientAutoConfigurationTests {
...
@@ -77,8 +78,8 @@ public class EurekaClientAutoConfigurationTests {
setupContext
(
RefreshAutoConfiguration
.
class
);
setupContext
(
RefreshAutoConfiguration
.
class
);
EurekaInstanceConfigBean
instance
=
this
.
context
EurekaInstanceConfigBean
instance
=
this
.
context
.
getBean
(
EurekaInstanceConfigBean
.
class
);
.
getBean
(
EurekaInstanceConfigBean
.
class
);
assertTrue
(
"Wrong status page: "
+
instance
.
getStatusPageUrl
(),
assertTrue
(
"Wrong status page: "
+
instance
.
getStatusPageUrl
(),
instance
instance
.
getStatusPageUrl
().
contains
(
"9999"
));
.
getStatusPageUrl
().
contains
(
"9999"
));
}
}
@Test
@Test
...
@@ -88,15 +89,15 @@ public class EurekaClientAutoConfigurationTests {
...
@@ -88,15 +89,15 @@ public class EurekaClientAutoConfigurationTests {
setupContext
(
RefreshAutoConfiguration
.
class
);
setupContext
(
RefreshAutoConfiguration
.
class
);
EurekaInstanceConfigBean
instance
=
this
.
context
EurekaInstanceConfigBean
instance
=
this
.
context
.
getBean
(
EurekaInstanceConfigBean
.
class
);
.
getBean
(
EurekaInstanceConfigBean
.
class
);
assertTrue
(
"Wrong status page: "
+
instance
.
getStatusPageUrl
(),
assertTrue
(
"Wrong status page: "
+
instance
.
getStatusPageUrl
(),
instance
instance
.
getStatusPageUrl
().
contains
(
"foo"
));
.
getStatusPageUrl
().
contains
(
"foo"
));
}
}
@Test
@Test
public
void
refreshScopedBeans
()
{
public
void
refreshScopedBeans
()
{
setupContext
(
RefreshAutoConfiguration
.
class
);
setupContext
(
RefreshAutoConfiguration
.
class
);
assertEquals
(
ScopedProxyFactoryBean
.
class
.
getName
(),
assertEquals
(
ScopedProxyFactoryBean
.
class
.
getName
(),
this
.
context
this
.
context
.
getBeanDefinition
(
"eurekaClient"
).
getBeanClassName
());
.
getBeanDefinition
(
"eurekaClient"
).
getBeanClassName
());
assertEquals
(
ScopedProxyFactoryBean
.
class
.
getName
(),
this
.
context
assertEquals
(
ScopedProxyFactoryBean
.
class
.
getName
(),
this
.
context
.
getBeanDefinition
(
"eurekaApplicationInfoManager"
).
getBeanClassName
());
.
getBeanDefinition
(
"eurekaApplicationInfoManager"
).
getBeanClassName
());
}
}
...
@@ -113,7 +114,7 @@ public class EurekaClientAutoConfigurationTests {
...
@@ -113,7 +114,7 @@ public class EurekaClientAutoConfigurationTests {
@Configuration
@Configuration
@EnableConfigurationProperties
@EnableConfigurationProperties
@Import
(
EurekaClientAutoConfiguration
.
class
)
@Import
(
{
UtilAutoConfiguration
.
class
,
EurekaClientAutoConfiguration
.
class
}
)
protected
static
class
TestConfiguration
{
protected
static
class
TestConfiguration
{
}
}
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/eureka/EurekaInstanceConfigBeanTests.java
View file @
94c73da9
...
@@ -16,25 +16,28 @@
...
@@ -16,25 +16,28 @@
package
org
.
springframework
.
cloud
.
netflix
.
eureka
;
package
org
.
springframework
.
cloud
.
netflix
.
eureka
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
springframework
.
boot
.
test
.
EnvironmentTestUtils
.
addEnvironment
;
import
static
org
.
springframework
.
cloud
.
util
.
InetUtils
.
getFirstNonLoopbackHostInfo
;
import
org.junit.After
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.springframework.beans.factory.BeanCreationException
;
import
org.springframework.beans.factory.BeanCreationException
;
import
org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration
;
import
org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.cloud.util.InetUtils
;
import
org.springframework.cloud.util.InetUtilsProperties
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.test.util.ReflectionTestUtils
;
import
org.springframework.test.util.ReflectionTestUtils
;
import
com.netflix.appinfo.InstanceInfo.InstanceStatus
;
import
com.netflix.appinfo.InstanceInfo.InstanceStatus
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
springframework
.
boot
.
test
.
EnvironmentTestUtils
.
addEnvironment
;
/**
/**
* @author Dave Syer
* @author Dave Syer
* @author Spencer Gibb
*/
*/
public
class
EurekaInstanceConfigBeanTests
{
public
class
EurekaInstanceConfigBeanTests
{
...
@@ -43,7 +46,8 @@ public class EurekaInstanceConfigBeanTests {
...
@@ -43,7 +46,8 @@ public class EurekaInstanceConfigBeanTests {
@Before
@Before
public
void
init
()
{
public
void
init
()
{
this
.
hostName
=
getFirstNonLoopbackHostInfo
().
getHostname
();
this
.
hostName
=
new
InetUtils
(
new
InetUtilsProperties
())
.
findFirstNonLoopbackHostInfo
().
getHostname
();
}
}
@After
@After
...
@@ -148,8 +152,12 @@ public class EurekaInstanceConfigBeanTests {
...
@@ -148,8 +152,12 @@ public class EurekaInstanceConfigBeanTests {
}
}
@Configuration
@Configuration
@EnableConfigurationProperties
(
EurekaInstanceConfigBean
.
class
)
@EnableConfigurationProperties
protected
static
class
TestConfiguration
{
protected
static
class
TestConfiguration
{
@Bean
public
EurekaInstanceConfigBean
eurekaInstanceConfigBean
()
{
return
new
EurekaInstanceConfigBean
(
new
InetUtils
(
new
InetUtilsProperties
()));
}
}
}
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/eureka/InstanceInfoFactoryTests.java
View file @
94c73da9
package
org
.
springframework
.
cloud
.
netflix
.
eureka
;
package
org
.
springframework
.
cloud
.
netflix
.
eureka
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
springframework
.
boot
.
test
.
EnvironmentTestUtils
.
addEnvironment
;
import
static
org
.
springframework
.
cloud
.
util
.
InetUtils
.
getFirstNonLoopbackHostInfo
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration
;
import
org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.cloud.util.InetUtils
;
import
org.springframework.cloud.util.InetUtilsProperties
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
com.netflix.appinfo.InstanceInfo
;
import
com.netflix.appinfo.InstanceInfo
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
springframework
.
boot
.
test
.
EnvironmentTestUtils
.
addEnvironment
;
public
class
InstanceInfoFactoryTests
{
public
class
InstanceInfoFactoryTests
{
private
AnnotationConfigApplicationContext
context
=
new
AnnotationConfigApplicationContext
();
private
AnnotationConfigApplicationContext
context
=
new
AnnotationConfigApplicationContext
();
@Test
@Test
public
void
instanceIdIsHostNameByDefault
()
{
public
void
instanceIdIsHostNameByDefault
()
{
InstanceInfo
instanceInfo
=
setupInstance
();
InstanceInfo
instanceInfo
=
setupInstance
();
assertEquals
(
getFirstNonLoopbackHostInfo
().
getHostname
(),
assertEquals
(
new
InetUtils
(
new
InetUtilsProperties
())
instanceInfo
.
getId
());
.
findFirstNonLoopbackHostInfo
().
getHostname
(),
instanceInfo
.
getId
());
}
}
@Test
@Test
public
void
instanceIdIsIpWhenIpPreferred
()
throws
Exception
{
public
void
instanceIdIsIpWhenIpPreferred
()
throws
Exception
{
InstanceInfo
instanceInfo
=
setupInstance
(
"eureka.instance.preferIpAddress:true"
);
InstanceInfo
instanceInfo
=
setupInstance
(
"eureka.instance.preferIpAddress:true"
);
assertTrue
(
instanceInfo
.
getId
().
matches
(
assertTrue
(
instanceInfo
.
getId
().
matches
(
"(\\d+\\.){3}\\d+"
));
"(\\d+\\.){3}\\d+"
));
}
}
@Test
@Test
...
@@ -53,7 +54,11 @@ public class InstanceInfoFactoryTests {
...
@@ -53,7 +54,11 @@ public class InstanceInfoFactoryTests {
}
}
@Configuration
@Configuration
@EnableConfigurationProperties
(
EurekaInstanceConfigBean
.
class
)
@EnableConfigurationProperties
protected
static
class
TestConfiguration
{
protected
static
class
TestConfiguration
{
@Bean
public
EurekaInstanceConfigBean
eurekaInstanceConfigBean
()
{
return
new
EurekaInstanceConfigBean
(
new
InetUtils
(
new
InetUtilsProperties
()));
}
}
}
}
}
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/ribbon/RibbonClientPreprocessorOverridesIntegrationTests.java
View file @
94c73da9
...
@@ -27,6 +27,7 @@ import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfigurati
...
@@ -27,6 +27,7 @@ import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfigurati
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.cloud.netflix.archaius.ArchaiusAutoConfiguration
;
import
org.springframework.cloud.netflix.archaius.ArchaiusAutoConfiguration
;
import
org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration
;
import
org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration
;
import
org.springframework.cloud.util.UtilAutoConfiguration
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Import
;
import
org.springframework.context.annotation.Import
;
...
@@ -80,7 +81,7 @@ public class RibbonClientPreprocessorOverridesIntegrationTests {
...
@@ -80,7 +81,7 @@ public class RibbonClientPreprocessorOverridesIntegrationTests {
@RibbonClient
(
name
=
"foo"
,
configuration
=
FooConfiguration
.
class
),
@RibbonClient
(
name
=
"foo"
,
configuration
=
FooConfiguration
.
class
),
@RibbonClient
(
name
=
"bar"
,
configuration
=
BarConfiguration
.
class
)
@RibbonClient
(
name
=
"bar"
,
configuration
=
BarConfiguration
.
class
)
})
})
@Import
({
PropertyPlaceholderAutoConfiguration
.
class
,
@Import
({
UtilAutoConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
,
ArchaiusAutoConfiguration
.
class
,
EurekaClientAutoConfiguration
.
class
,
ArchaiusAutoConfiguration
.
class
,
EurekaClientAutoConfiguration
.
class
,
RibbonAutoConfiguration
.
class
})
RibbonAutoConfiguration
.
class
})
protected
static
class
TestConfiguration
{
protected
static
class
TestConfiguration
{
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/ribbon/RibbonClientsPreprocessorIntegrationTests.java
View file @
94c73da9
...
@@ -24,6 +24,7 @@ import org.springframework.boot.test.SpringApplicationConfiguration;
...
@@ -24,6 +24,7 @@ import org.springframework.boot.test.SpringApplicationConfiguration;
import
org.springframework.cloud.netflix.archaius.ArchaiusAutoConfiguration
;
import
org.springframework.cloud.netflix.archaius.ArchaiusAutoConfiguration
;
import
org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration
;
import
org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration
;
import
org.springframework.cloud.netflix.ribbon.RibbonClientsPreprocessorIntegrationTests.TestConfiguration
;
import
org.springframework.cloud.netflix.ribbon.RibbonClientsPreprocessorIntegrationTests.TestConfiguration
;
import
org.springframework.cloud.util.UtilAutoConfiguration
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Import
;
import
org.springframework.context.annotation.Import
;
...
@@ -67,7 +68,7 @@ public class RibbonClientsPreprocessorIntegrationTests {
...
@@ -67,7 +68,7 @@ public class RibbonClientsPreprocessorIntegrationTests {
@Configuration
@Configuration
@RibbonClients
(
@RibbonClient
(
name
=
"foo"
,
configuration
=
FooConfiguration
.
class
))
@RibbonClients
(
@RibbonClient
(
name
=
"foo"
,
configuration
=
FooConfiguration
.
class
))
@Import
({
PropertyPlaceholderAutoConfiguration
.
class
,
@Import
({
UtilAutoConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
,
ArchaiusAutoConfiguration
.
class
,
EurekaClientAutoConfiguration
.
class
,
ArchaiusAutoConfiguration
.
class
,
EurekaClientAutoConfiguration
.
class
,
RibbonAutoConfiguration
.
class
})
RibbonAutoConfiguration
.
class
})
protected
static
class
TestConfiguration
{
protected
static
class
TestConfiguration
{
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/ribbon/eureka/EurekaRibbonClientConfigurationTests.java
View file @
94c73da9
...
@@ -28,6 +28,8 @@ import org.junit.Test;
...
@@ -28,6 +28,8 @@ import org.junit.Test;
import
org.springframework.cloud.netflix.eureka.EurekaClientConfigBean
;
import
org.springframework.cloud.netflix.eureka.EurekaClientConfigBean
;
import
org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean
;
import
org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean
;
import
org.springframework.cloud.netflix.ribbon.SpringClientFactory
;
import
org.springframework.cloud.netflix.ribbon.SpringClientFactory
;
import
org.springframework.cloud.util.InetUtils
;
import
org.springframework.cloud.util.InetUtilsProperties
;
import
com.netflix.config.ConfigurationManager
;
import
com.netflix.config.ConfigurationManager
;
import
com.netflix.config.DeploymentContext.ContextKey
;
import
com.netflix.config.DeploymentContext.ContextKey
;
...
@@ -52,7 +54,7 @@ public class EurekaRibbonClientConfigurationTests {
...
@@ -52,7 +54,7 @@ public class EurekaRibbonClientConfigurationTests {
@Ignore
@Ignore
public
void
basicConfigurationCreatedForLoadBalancer
()
{
public
void
basicConfigurationCreatedForLoadBalancer
()
{
EurekaClientConfigBean
client
=
new
EurekaClientConfigBean
();
EurekaClientConfigBean
client
=
new
EurekaClientConfigBean
();
EurekaInstanceConfigBean
configBean
=
new
EurekaInstanceConfigBean
();
EurekaInstanceConfigBean
configBean
=
get
EurekaInstanceConfigBean
();
client
.
getAvailabilityZones
().
put
(
client
.
getRegion
(),
"foo"
);
client
.
getAvailabilityZones
().
put
(
client
.
getRegion
(),
"foo"
);
SpringClientFactory
clientFactory
=
new
SpringClientFactory
();
SpringClientFactory
clientFactory
=
new
SpringClientFactory
();
EurekaRibbonClientConfiguration
clientPreprocessor
=
new
EurekaRibbonClientConfiguration
(
EurekaRibbonClientConfiguration
clientPreprocessor
=
new
EurekaRibbonClientConfiguration
(
...
@@ -67,10 +69,14 @@ public class EurekaRibbonClientConfigurationTests {
...
@@ -67,10 +69,14 @@ public class EurekaRibbonClientConfigurationTests {
ConfigurationManager
.
getDeploymentContext
().
getValue
(
ContextKey
.
zone
));
ConfigurationManager
.
getDeploymentContext
().
getValue
(
ContextKey
.
zone
));
}
}
private
EurekaInstanceConfigBean
getEurekaInstanceConfigBean
()
{
return
new
EurekaInstanceConfigBean
(
new
InetUtils
(
new
InetUtilsProperties
()));
}
@Test
@Test
public
void
testSetProp
()
{
public
void
testSetProp
()
{
EurekaClientConfigBean
client
=
new
EurekaClientConfigBean
();
EurekaClientConfigBean
client
=
new
EurekaClientConfigBean
();
EurekaInstanceConfigBean
configBean
=
new
EurekaInstanceConfigBean
();
EurekaInstanceConfigBean
configBean
=
get
EurekaInstanceConfigBean
();
EurekaRibbonClientConfiguration
preprocessor
=
new
EurekaRibbonClientConfiguration
(
EurekaRibbonClientConfiguration
preprocessor
=
new
EurekaRibbonClientConfiguration
(
client
,
"myService"
,
configBean
,
false
);
client
,
"myService"
,
configBean
,
false
);
String
serviceId
=
"myService"
;
String
serviceId
=
"myService"
;
...
@@ -88,7 +94,7 @@ public class EurekaRibbonClientConfigurationTests {
...
@@ -88,7 +94,7 @@ public class EurekaRibbonClientConfigurationTests {
@Test
@Test
public
void
testDefaultZone
()
{
public
void
testDefaultZone
()
{
EurekaClientConfigBean
client
=
new
EurekaClientConfigBean
();
EurekaClientConfigBean
client
=
new
EurekaClientConfigBean
();
EurekaInstanceConfigBean
configBean
=
new
EurekaInstanceConfigBean
();
EurekaInstanceConfigBean
configBean
=
get
EurekaInstanceConfigBean
();
EurekaRibbonClientConfiguration
preprocessor
=
new
EurekaRibbonClientConfiguration
(
EurekaRibbonClientConfiguration
preprocessor
=
new
EurekaRibbonClientConfiguration
(
client
,
"myService"
,
configBean
,
false
);
client
,
"myService"
,
configBean
,
false
);
preprocessor
.
preprocess
();
preprocessor
.
preprocess
();
...
@@ -98,7 +104,7 @@ public class EurekaRibbonClientConfigurationTests {
...
@@ -98,7 +104,7 @@ public class EurekaRibbonClientConfigurationTests {
@Test
@Test
public
void
testApproximateZone
()
{
public
void
testApproximateZone
()
{
EurekaClientConfigBean
client
=
new
EurekaClientConfigBean
();
EurekaClientConfigBean
client
=
new
EurekaClientConfigBean
();
EurekaInstanceConfigBean
configBean
=
new
EurekaInstanceConfigBean
();
EurekaInstanceConfigBean
configBean
=
get
EurekaInstanceConfigBean
();
configBean
.
setHostname
(
"this.is.a.test.com"
);
configBean
.
setHostname
(
"this.is.a.test.com"
);
EurekaRibbonClientConfiguration
preprocessor
=
new
EurekaRibbonClientConfiguration
(
EurekaRibbonClientConfiguration
preprocessor
=
new
EurekaRibbonClientConfiguration
(
client
,
"myService"
,
configBean
,
true
);
client
,
"myService"
,
configBean
,
true
);
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/ribbon/eureka/EurekaRibbonClientPreprocessorIntegrationTests.java
View file @
94c73da9
...
@@ -28,6 +28,7 @@ import org.springframework.cloud.netflix.ribbon.RibbonClient;
...
@@ -28,6 +28,7 @@ import org.springframework.cloud.netflix.ribbon.RibbonClient;
import
org.springframework.cloud.netflix.ribbon.ServerIntrospector
;
import
org.springframework.cloud.netflix.ribbon.ServerIntrospector
;
import
org.springframework.cloud.netflix.ribbon.SpringClientFactory
;
import
org.springframework.cloud.netflix.ribbon.SpringClientFactory
;
import
org.springframework.cloud.netflix.ribbon.eureka.EurekaRibbonClientPreprocessorIntegrationTests.TestConfiguration
;
import
org.springframework.cloud.netflix.ribbon.eureka.EurekaRibbonClientPreprocessorIntegrationTests.TestConfiguration
;
import
org.springframework.cloud.util.UtilAutoConfiguration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Import
;
import
org.springframework.context.annotation.Import
;
import
org.springframework.test.annotation.DirtiesContext
;
import
org.springframework.test.annotation.DirtiesContext
;
...
@@ -77,7 +78,7 @@ public class EurekaRibbonClientPreprocessorIntegrationTests {
...
@@ -77,7 +78,7 @@ public class EurekaRibbonClientPreprocessorIntegrationTests {
@Configuration
@Configuration
@RibbonClient
(
"foo"
)
@RibbonClient
(
"foo"
)
@Import
({
PropertyPlaceholderAutoConfiguration
.
class
,
@Import
({
UtilAutoConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
,
ArchaiusAutoConfiguration
.
class
,
RibbonAutoConfiguration
.
class
,
ArchaiusAutoConfiguration
.
class
,
RibbonAutoConfiguration
.
class
,
EurekaClientAutoConfiguration
.
class
,
RibbonEurekaAutoConfiguration
.
class
})
EurekaClientAutoConfiguration
.
class
,
RibbonEurekaAutoConfiguration
.
class
})
protected
static
class
TestConfiguration
{
protected
static
class
TestConfiguration
{
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/ribbon/eureka/RibbonClientPreprocessorIntegrationTests.java
View file @
94c73da9
...
@@ -16,8 +16,6 @@
...
@@ -16,8 +16,6 @@
package
org
.
springframework
.
cloud
.
netflix
.
ribbon
.
eureka
;
package
org
.
springframework
.
cloud
.
netflix
.
ribbon
.
eureka
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -30,6 +28,8 @@ import org.springframework.cloud.netflix.ribbon.RibbonClient;
...
@@ -30,6 +28,8 @@ import org.springframework.cloud.netflix.ribbon.RibbonClient;
import
org.springframework.cloud.netflix.ribbon.SpringClientFactory
;
import
org.springframework.cloud.netflix.ribbon.SpringClientFactory
;
import
org.springframework.cloud.netflix.ribbon.ZonePreferenceServerListFilter
;
import
org.springframework.cloud.netflix.ribbon.ZonePreferenceServerListFilter
;
import
org.springframework.cloud.netflix.ribbon.eureka.RibbonClientPreprocessorIntegrationTests.TestConfiguration
;
import
org.springframework.cloud.netflix.ribbon.eureka.RibbonClientPreprocessorIntegrationTests.TestConfiguration
;
import
org.springframework.cloud.util.InetUtils
;
import
org.springframework.cloud.util.InetUtilsProperties
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Import
;
import
org.springframework.context.annotation.Import
;
...
@@ -40,6 +40,8 @@ import com.netflix.loadbalancer.Server;
...
@@ -40,6 +40,8 @@ import com.netflix.loadbalancer.Server;
import
com.netflix.loadbalancer.ZoneAvoidanceRule
;
import
com.netflix.loadbalancer.ZoneAvoidanceRule
;
import
com.netflix.loadbalancer.ZoneAwareLoadBalancer
;
import
com.netflix.loadbalancer.ZoneAwareLoadBalancer
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
/**
/**
* @author Dave Syer
* @author Dave Syer
*/
*/
...
@@ -87,7 +89,8 @@ public class RibbonClientPreprocessorIntegrationTests {
...
@@ -87,7 +89,8 @@ public class RibbonClientPreprocessorIntegrationTests {
@Configuration
@Configuration
@RibbonClient
(
name
=
"foo"
,
configuration
=
FooConfiguration
.
class
)
@RibbonClient
(
name
=
"foo"
,
configuration
=
FooConfiguration
.
class
)
@Import
({
PropertyPlaceholderAutoConfiguration
.
class
,
@Import
({
PropertyPlaceholderAutoConfiguration
.
class
,
ArchaiusAutoConfiguration
.
class
,
RibbonAutoConfiguration
.
class
,
RibbonEurekaAutoConfiguration
.
class
})
ArchaiusAutoConfiguration
.
class
,
RibbonAutoConfiguration
.
class
,
RibbonEurekaAutoConfiguration
.
class
})
protected
static
class
TestConfiguration
{
protected
static
class
TestConfiguration
{
}
}
...
@@ -99,10 +102,11 @@ public class RibbonClientPreprocessorIntegrationTests {
...
@@ -99,10 +102,11 @@ public class RibbonClientPreprocessorIntegrationTests {
filter
.
setZone
(
"myTestZone"
);
filter
.
setZone
(
"myTestZone"
);
return
filter
;
return
filter
;
}
}
@Bean
@Bean
public
EurekaInstanceConfigBean
getEurekaInstanceConfigBean
()
{
public
EurekaInstanceConfigBean
getEurekaInstanceConfigBean
()
{
EurekaInstanceConfigBean
bean
=
new
EurekaInstanceConfigBean
();
EurekaInstanceConfigBean
bean
=
new
EurekaInstanceConfigBean
(
new
InetUtils
(
new
InetUtilsProperties
()));
return
bean
;
return
bean
;
}
}
}
}
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/ribbon/test/RibbonClientDefaultConfigurationTestsConfig.java
View file @
94c73da9
...
@@ -16,32 +16,34 @@
...
@@ -16,32 +16,34 @@
package
org
.
springframework
.
cloud
.
netflix
.
ribbon
.
test
;
package
org
.
springframework
.
cloud
.
netflix
.
ribbon
.
test
;
import
com.netflix.client.config.IClientConfig
;
import
com.netflix.loadbalancer.BestAvailableRule
;
import
com.netflix.loadbalancer.ConfigurationBasedServerList
;
import
com.netflix.loadbalancer.IPing
;
import
com.netflix.loadbalancer.IRule
;
import
com.netflix.loadbalancer.PingUrl
;
import
com.netflix.loadbalancer.Server
;
import
com.netflix.loadbalancer.ServerList
;
import
com.netflix.loadbalancer.ServerListSubsetFilter
;
import
org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration
;
import
org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration
;
import
org.springframework.cloud.netflix.archaius.ArchaiusAutoConfiguration
;
import
org.springframework.cloud.netflix.archaius.ArchaiusAutoConfiguration
;
import
org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration
;
import
org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration
;
import
org.springframework.cloud.netflix.ribbon.RibbonAutoConfiguration
;
import
org.springframework.cloud.netflix.ribbon.RibbonAutoConfiguration
;
import
org.springframework.cloud.netflix.ribbon.RibbonClients
;
import
org.springframework.cloud.netflix.ribbon.RibbonClients
;
import
org.springframework.cloud.netflix.ribbon.eureka.RibbonEurekaAutoConfiguration
;
import
org.springframework.cloud.netflix.ribbon.eureka.RibbonEurekaAutoConfiguration
;
import
org.springframework.cloud.util.UtilAutoConfiguration
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Import
;
import
org.springframework.context.annotation.Import
;
import
com.netflix.client.config.IClientConfig
;
import
com.netflix.loadbalancer.BestAvailableRule
;
import
com.netflix.loadbalancer.ConfigurationBasedServerList
;
import
com.netflix.loadbalancer.IPing
;
import
com.netflix.loadbalancer.IRule
;
import
com.netflix.loadbalancer.PingUrl
;
import
com.netflix.loadbalancer.Server
;
import
com.netflix.loadbalancer.ServerList
;
import
com.netflix.loadbalancer.ServerListSubsetFilter
;
/**
/**
* @author Spencer Gibb
* @author Spencer Gibb
*/
*/
@Configuration
@Configuration
@Import
({
PropertyPlaceholderAutoConfiguration
.
class
,
@Import
({
PropertyPlaceholderAutoConfiguration
.
class
,
ArchaiusAutoConfiguration
.
class
,
Archaius
AutoConfiguration
.
class
,
EurekaClientAutoConfiguration
.
class
,
Util
AutoConfiguration
.
class
,
EurekaClientAutoConfiguration
.
class
,
RibbonAutoConfiguration
.
class
,
RibbonEurekaAutoConfiguration
.
class
})
RibbonAutoConfiguration
.
class
,
RibbonEurekaAutoConfiguration
.
class
})
@RibbonClients
(
defaultConfiguration
=
DefaultRibbonConfig
.
class
)
@RibbonClients
(
defaultConfiguration
=
DefaultRibbonConfig
.
class
)
public
class
RibbonClientDefaultConfigurationTestsConfig
{
public
class
RibbonClientDefaultConfigurationTestsConfig
{
...
@@ -52,7 +54,6 @@ public class RibbonClientDefaultConfigurationTestsConfig {
...
@@ -52,7 +54,6 @@ public class RibbonClientDefaultConfigurationTestsConfig {
}
}
}
}
@Configuration
@Configuration
class
DefaultRibbonConfig
{
class
DefaultRibbonConfig
{
...
...
spring-cloud-netflix-sidecar/src/main/java/org/springframework/cloud/netflix/sidecar/SidecarConfiguration.java
View file @
94c73da9
...
@@ -23,6 +23,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
...
@@ -23,6 +23,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.cloud.client.actuator.HasFeatures
;
import
org.springframework.cloud.client.actuator.HasFeatures
;
import
org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean
;
import
org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean
;
import
org.springframework.cloud.util.InetUtils
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
...
@@ -53,6 +54,9 @@ public class SidecarConfiguration {
...
@@ -53,6 +54,9 @@ public class SidecarConfiguration {
@Autowired
@Autowired
private
SidecarProperties
sidecarProperties
;
private
SidecarProperties
sidecarProperties
;
@Autowired
private
InetUtils
inetUtils
;
@Value
(
"${server.port:${SERVER_PORT:${PORT:8080}}}"
)
@Value
(
"${server.port:${SERVER_PORT:${PORT:8080}}}"
)
private
int
serverPort
=
8080
;
private
int
serverPort
=
8080
;
...
@@ -61,7 +65,7 @@ public class SidecarConfiguration {
...
@@ -61,7 +65,7 @@ public class SidecarConfiguration {
@Bean
@Bean
public
EurekaInstanceConfigBean
eurekaInstanceConfigBean
()
{
public
EurekaInstanceConfigBean
eurekaInstanceConfigBean
()
{
EurekaInstanceConfigBean
config
=
new
EurekaInstanceConfigBean
();
EurekaInstanceConfigBean
config
=
new
EurekaInstanceConfigBean
(
inetUtils
);
int
port
=
this
.
sidecarProperties
.
getPort
();
int
port
=
this
.
sidecarProperties
.
getPort
();
config
.
setNonSecurePort
(
port
);
config
.
setNonSecurePort
(
port
);
String
scheme
=
config
.
getSecurePortEnabled
()
?
"https"
:
"http"
;
String
scheme
=
config
.
getSecurePortEnabled
()
?
"https"
:
"http"
;
...
...
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