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
8ff3462a
Commit
8ff3462a
authored
Oct 25, 2014
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add bootstrap configuration for eureka-first
See gh-42
parent
dd967120
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
105 additions
and
19 deletions
+105
-19
pom.xml
pom.xml
+5
-0
pom.xml
spring-cloud-netflix-core/pom.xml
+5
-0
DiscoveryClientConfigServiceBootstrapConfiguration.java
...g/DiscoveryClientConfigServiceBootstrapConfiguration.java
+66
-0
EurekaClientAutoConfiguration.java
...k/cloud/netflix/eureka/EurekaClientAutoConfiguration.java
+24
-3
EurekaClientConfiguration.java
...ework/cloud/netflix/eureka/EurekaClientConfiguration.java
+0
-12
HystrixConfiguration.java
...framework/cloud/netflix/hystrix/HystrixConfiguration.java
+0
-2
spring.factories
...netflix-core/src/main/resources/META-INF/spring.factories
+5
-2
No files found.
pom.xml
View file @
8ff3462a
...
...
@@ -38,6 +38,11 @@
<dependencies>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-config-client
</artifactId>
<version>
1.0.0.BUILD-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-netflix-core
</artifactId>
<version>
1.0.0.BUILD-SNAPSHOT
</version>
</dependency>
...
...
spring-cloud-netflix-core/pom.xml
View file @
8ff3462a
...
...
@@ -25,6 +25,11 @@
<artifactId>
spring-boot-starter-actuator
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-config-client
</artifactId>
<optional>
true
</optional>
</dependency>
<dependency>
<groupId>
com.netflix.archaius
</groupId>
<artifactId>
archaius-core
</artifactId>
<optional>
true
</optional>
...
...
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/config/DiscoveryClientConfigServiceBootstrapConfiguration.java
0 → 100644
View file @
8ff3462a
/*
* Copyright 2013-2014 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
.
config
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnExpression
;
import
org.springframework.cloud.config.client.ConfigServicePropertySourceLocator
;
import
org.springframework.cloud.netflix.eureka.EnableEurekaClient
;
import
org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration
;
import
org.springframework.context.ApplicationListener
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Import
;
import
org.springframework.context.event.ContextRefreshedEvent
;
import
com.netflix.appinfo.InstanceInfo
;
import
com.netflix.discovery.DiscoveryClient
;
/**
* @author Dave Syer
*
*/
@ConditionalOnClass
({
DiscoveryClient
.
class
,
ConfigServicePropertySourceLocator
.
class
})
@ConditionalOnExpression
(
"${spring.cloud.bootstrap.config.useDiscovery:false}"
)
@Configuration
@EnableEurekaClient
@Import
(
EurekaClientAutoConfiguration
.
class
)
@Slf4j
public
class
DiscoveryClientConfigServiceBootstrapConfiguration
implements
ApplicationListener
<
ContextRefreshedEvent
>
{
private
static
final
String
DEFAULT_CONFIG_SERVER
=
"CONFIGSERVER"
;
@Autowired
private
DiscoveryClient
client
;
@Autowired
private
ConfigServicePropertySourceLocator
delegate
;
@Override
public
void
onApplicationEvent
(
ContextRefreshedEvent
event
)
{
try
{
log
.
info
(
"Locating configserver via discovery"
);
InstanceInfo
server
=
client
.
getNextServerFromEureka
(
DEFAULT_CONFIG_SERVER
,
false
);
delegate
.
setUri
(
server
.
getHomePageUrl
());
}
catch
(
Exception
e
)
{
log
.
warn
(
"Could not locate configserver via discovery"
,
e
);
}
}
}
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/eureka/EurekaClientAutoConfiguration.java
View file @
8ff3462a
...
...
@@ -16,15 +16,20 @@
package
org
.
springframework
.
cloud
.
netflix
.
eureka
;
import
javax.annotation.PostConstruct
;
import
javax.management.MBeanServer
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnExpression
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.cloud.netflix.servo.ServoMetricReader
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
com.netflix.appinfo.EurekaInstanceConfig
;
import
com.netflix.discovery.DiscoveryClient
;
import
com.netflix.discovery.EurekaClientConfig
;
import
com.netflix.discovery.converters.JsonXStream
;
import
com.netflix.discovery.converters.XmlXStream
;
...
...
@@ -38,11 +43,16 @@ import com.netflix.discovery.converters.XmlXStream;
@ConditionalOnClass
(
EurekaClientConfig
.
class
)
@ConditionalOnExpression
(
"${eureka.client.enabled:true}"
)
public
class
EurekaClientAutoConfiguration
{
@Autowired
private
DiscoveryClient
discoveryClient
;
@PostConstruct
public
void
init
()
{
XmlXStream
.
getInstance
().
setMarshallingStrategy
(
new
DataCenterAwareMarshallingStrategy
());
JsonXStream
.
getInstance
().
setMarshallingStrategy
(
new
DataCenterAwareMarshallingStrategy
());
XmlXStream
.
getInstance
().
setMarshallingStrategy
(
new
DataCenterAwareMarshallingStrategy
());
JsonXStream
.
getInstance
().
setMarshallingStrategy
(
new
DataCenterAwareMarshallingStrategy
());
}
@Bean
...
...
@@ -56,4 +66,15 @@ public class EurekaClientAutoConfiguration {
public
EurekaInstanceConfigBean
eurekaInstanceConfigBean
()
{
return
new
EurekaInstanceConfigBean
();
}
@Bean
@ConditionalOnMissingBean
@ConditionalOnBean
(
MBeanServer
.
class
)
@ConditionalOnExpression
(
"${spring.jmx.enabled:true}"
)
public
EurekaHealthIndicator
eurekaHealthIndicator
(
MBeanServer
server
,
EurekaInstanceConfig
config
)
{
return
new
EurekaHealthIndicator
(
discoveryClient
,
new
ServoMetricReader
(
server
),
config
);
}
}
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/eureka/EurekaClientConfiguration.java
View file @
8ff3462a
...
...
@@ -16,7 +16,6 @@
package
org
.
springframework
.
cloud
.
netflix
.
eureka
;
import
javax.annotation.PreDestroy
;
import
javax.management.MBeanServer
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -28,7 +27,6 @@ import org.springframework.boot.context.embedded.EmbeddedServletContainerInitial
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.cloud.client.discovery.DiscoveryClient
;
import
org.springframework.cloud.netflix.ribbon.SpringClientFactory
;
import
org.springframework.cloud.netflix.servo.ServoMetricReader
;
import
org.springframework.context.ApplicationListener
;
import
org.springframework.context.SmartLifecycle
;
import
org.springframework.context.annotation.Bean
;
...
...
@@ -39,7 +37,6 @@ import org.springframework.context.annotation.ScopedProxyMode;
import
org.springframework.core.Ordered
;
import
com.netflix.appinfo.ApplicationInfoManager
;
import
com.netflix.appinfo.EurekaInstanceConfig
;
import
com.netflix.appinfo.InstanceInfo.InstanceStatus
;
import
com.netflix.discovery.DiscoveryManager
;
import
com.netflix.discovery.EurekaClientConfig
;
...
...
@@ -149,15 +146,6 @@ public class EurekaClientConfiguration implements SmartLifecycle, Ordered {
}
@Bean
@ConditionalOnMissingBean
@ConditionalOnExpression
(
"${spring.jmx.enabled:true}"
)
public
EurekaHealthIndicator
eurekaHealthIndicator
(
MBeanServer
server
,
EurekaInstanceConfig
config
)
{
return
new
EurekaHealthIndicator
(
eurekaDiscoveryClient
(),
new
ServoMetricReader
(
server
),
config
);
}
@Bean
protected
ApplicationListener
<
EmbeddedServletContainerInitializedEvent
>
containerPortInitializer
()
{
return
new
ApplicationListener
<
EmbeddedServletContainerInitializedEvent
>()
{
...
...
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/hystrix/HystrixConfiguration.java
View file @
8ff3462a
...
...
@@ -17,7 +17,6 @@ package org.springframework.cloud.netflix.hystrix;
import
java.io.IOException
;
import
java.util.Arrays
;
import
java.util.Collection
;
import
java.util.HashSet
;
import
java.util.Map
;
import
java.util.Set
;
...
...
@@ -38,7 +37,6 @@ import org.springframework.core.Ordered;
import
org.springframework.core.annotation.AnnotationAttributes
;
import
org.springframework.core.type.AnnotationMetadata
;
import
org.springframework.util.Assert
;
import
org.springframework.util.CollectionUtils
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.netflix.hystrix.Hystrix
;
...
...
spring-cloud-netflix-core/src/main/resources/META-INF/spring.factories
View file @
8ff3462a
...
...
@@ -4,4 +4,7 @@ org.springframework.cloud.netflix.feign.FeignAutoConfiguration,\
org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration,\
org.springframework.cloud.netflix.ribbon.RibbonAutoConfiguration,\
org.springframework.cloud.netflix.ribbon.eureka.RibbonEurekaAutoConfiguration,\
org.springframework.cloud.netflix.servo.ServoMetricsAutoConfiguration
\ No newline at end of file
org.springframework.cloud.netflix.servo.ServoMetricsAutoConfiguration
org.springframework.cloud.bootstrap.BootstrapConfiguration=\
org.springframework.cloud.netflix.config.DiscoveryClientConfigServiceBootstrapConfiguration
\ No newline at end of file
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