diff --git a/docs/pom.xml b/docs/pom.xml
index 750a06999..baa750767 100644
--- a/docs/pom.xml
+++ b/docs/pom.xml
@@ -5,7 +5,7 @@
org.springframework.cloud
spring-cloud-netflix
- 1.2.1.BUILD-SNAPSHOT
+ 1.2.3.BUILD-SNAPSHOT
spring-cloud-netflix-docs
pom
diff --git a/docs/src/main/asciidoc/spring-cloud-netflix.adoc b/docs/src/main/asciidoc/spring-cloud-netflix.adoc
index 539611160..129b47dd3 100644
--- a/docs/src/main/asciidoc/spring-cloud-netflix.adoc
+++ b/docs/src/main/asciidoc/spring-cloud-netflix.adoc
@@ -970,6 +970,45 @@ This replaces the `SpringMvcContract` with `feign.Contract.Default` and adds a `
Default configurations can be specified in the `@EnableFeignClients` attribute `defaultConfiguration` in a similar manner as described above. The difference is that this configuration will apply to _all_ feign clients.
+=== Creating Feign Clients Manually
+
+In some cases it might be necessary to customize your Feign Clients in a way that is not
+possible using the methods above. In this case you can create Clients using the
+https://github.com/OpenFeign/feign/#basics[Feign Builder API]. Below is an example
+which creates two Feign Clients with the same interface but configures each one with
+a separate request interceptor.
+
+[source,java,indent=0]
+----
+@Import(FeignClientsConfiguration.class)
+class FooController {
+
+ private FooClient fooClient;
+
+ private FooClient adminClient;
+
+ @Autowired
+ public FooController(
+ ResponseEntityDecoder decoder, SpringEncoder encoder, Client client) {
+ this.fooClient = Feign.builder().client(client)
+ .encoder(encoder)
+ .decoder(decoder)
+ .requestInterceptor(new BasicAuthRequestInterceptor("user", "user"))
+ .target(FooClient.class, "http://PROD-SVC");
+ this.adminClient = Feign.builder().client(client)
+ .encoder(encoder)
+ .decoder(decoder)
+ .requestInterceptor(new BasicAuthRequestInterceptor("admin", "admin"))
+ .target(FooClient.class, "http://PROD-SVC");
+ }
+}
+----
+
+NOTE: In the above example `FeignClientsConfiguration.class` is the default configuration
+provided by Spring Cloud Netflix.
+
+NOTE: `PROD-SVC` is the name of the service the Clients will be making requests to.
+
[[spring-cloud-feign-hystrix]]
=== Feign Hystrix Support
@@ -1012,6 +1051,30 @@ static class HystrixClientFallback implements HystrixClient {
}
----
+If one needs access to the cause that made the fallback trigger, one can use the `fallbackFactory` attribute inside `@FeignClient`.
+
+[source,java,indent=0]
+----
+@FeignClient(name = "hello", fallbackFactory = HystrixClientFallbackFactory.class)
+protected interface HystrixClient {
+ @RequestMapping(method = RequestMethod.GET, value = "/hello")
+ Hello iFailSometimes();
+}
+
+@Component
+static class HystrixClientFallbackFactory implements FallbackFactory {
+ @Override
+ public HystrixClient create(Throwable cause) {
+ return new HystrixClientWithFallBackFactory() {
+ @Override
+ public Hello iFailSometimes() {
+ return new Hello("fallback; reason was: " + cause.getMessage());
+ }
+ };
+ }
+}
+----
+
WARNING: There is a limitation with the implementation of fallbacks in Feign and how Hystrix fallbacks work. Fallbacks are currently not supported for methods that return `com.netflix.hystrix.HystrixCommand` and `rx.Observable`.
[[spring-cloud-feign-inheritance]]
@@ -1173,7 +1236,8 @@ To enable it, annotate a Spring Boot main class with
service. By convention, a service with the ID "users", will
receive requests from the proxy located at `/users` (with the prefix
stripped). The proxy uses Ribbon to locate an instance to forward to
-via discovery, and all requests are executed in a hystrix command, so
+via discovery, and all requests are executed in a
+<>, so
failures will show up in Hystrix metrics, and once the circuit is open
the proxy will not try to contact the service.
@@ -1363,7 +1427,7 @@ path rendering the `users` path unreachable.
=== Zuul Http Client
The default HTTP client used by zuul is now backed by the Apache HTTP Client instead of the
-deprecated Ribbon `RestClient. To use `RestClient` or to use the `okhttp3.OkHttpClient` set
+deprecated Ribbon `RestClient`. To use `RestClient` or to use the `okhttp3.OkHttpClient` set
`ribbon.restclient.enabled=true` or `ribbon.okhttp.enabled=true` respectively.
=== Cookies and Sensitive Headers
@@ -1541,6 +1605,70 @@ possible filters that are enabled. If you want to disable one, simply set
`org.springframework.cloud.netflix.zuul.filters.post.SendResponseFilter` set
`zuul.SendResponseFilter.post.disable=true`.
+[[hystrix-fallbacks-for-routes]]
+=== Providing Hystrix Fallbacks For Routes
+
+When a circuit for a given route in Zuul is tripped you can provide a fallback response
+by creating a bean of type `ZuulFallbackProvider`. Within this bean you need to specify
+the route ID the fallback is for and provide a `ClientHttpResponse` to return
+as a fallback. Here is a very simple `ZuulFallbackProvider` implementation.
+
+[source,java]
+----
+class MyFallbackProvider implements ZuulFallbackProvider {
+ @Override
+ public String getRoute() {
+ return "customers";
+ }
+
+ @Override
+ public ClientHttpResponse fallbackResponse() {
+ return new ClientHttpResponse() {
+ @Override
+ public HttpStatus getStatusCode() throws IOException {
+ return HttpStatus.OK;
+ }
+
+ @Override
+ public int getRawStatusCode() throws IOException {
+ return 200;
+ }
+
+ @Override
+ public String getStatusText() throws IOException {
+ return "OK";
+ }
+
+ @Override
+ public void close() {
+
+ }
+
+ @Override
+ public InputStream getBody() throws IOException {
+ return new ByteArrayInputStream("fallback".getBytes());
+ }
+
+ @Override
+ public HttpHeaders getHeaders() {
+ HttpHeaders headers = new HttpHeaders();
+ headers.setContentType(MediaType.APPLICATION_JSON);
+ return headers;
+ }
+ };
+ }
+}
+----
+
+And here is what the route configuration would look like.
+
+[source,yaml]
+----
+zuul:
+ routes:
+ customers: /customers/**
+----
+
=== Polyglot support with Sidecar
Do you have non-jvm languages you want to take advantage of Eureka, Ribbon and
@@ -1734,6 +1862,18 @@ If Spring AOP is enabled and `org.aspectj:aspectjweaver` is present on your runt
3. URI, sanitized for Atlas
4. Client name
+WARNING: Avoid using hardcoded url parameters within `RestTemplate`. When targeting dynamic endpoints use URL variables. This will avoid potential "GC Overhead Limit Reached" issues where `ServoMonitorCache` treats each url as a unique key.
+
+[source,java,indent=0]
+----
+// recommended
+String orderid = "1";
+restTemplate.getForObject("http://testeurekabrixtonclient/orders/{orderid}", String.class, orderid)
+
+// avoid
+restTemplate.getForObject("http://testeurekabrixtonclient/orders/1", String.class)
+----
+
[[netflix-metrics-spectator]]
=== Metrics Collection: Spectator
diff --git a/pom.xml b/pom.xml
index b0994d49a..ca7de3596 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,14 +3,14 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
spring-cloud-netflix
- 1.2.1.BUILD-SNAPSHOT
+ 1.2.3.BUILD-SNAPSHOT
pom
Spring Cloud Netflix
Spring Cloud Netflix
org.springframework.cloud
spring-cloud-build
- 1.2.1.BUILD-SNAPSHOT
+ 1.2.2.BUILD-SNAPSHOT
@@ -24,8 +24,8 @@
${basedir}
4.0.27.Final
2.7.3
- 1.1.4.BUILD-SNAPSHOT
- 1.2.1.BUILD-SNAPSHOT
+ 1.1.6.BUILD-SNAPSHOT
+ 1.2.2.BUILD-SNAPSHOT
Brooklyn.BUILD-SNAPSHOT
@@ -79,6 +79,13 @@
pom
import
+
+ org.springframework.cloud
+ spring-cloud-commons
+ test-jar
+ test
+ ${spring-cloud-commons.version}
+
org.springframework.cloud
spring-cloud-config-dependencies
diff --git a/spring-cloud-netflix-core/pom.xml b/spring-cloud-netflix-core/pom.xml
index 8f6985cc3..681bde90d 100644
--- a/spring-cloud-netflix-core/pom.xml
+++ b/spring-cloud-netflix-core/pom.xml
@@ -5,7 +5,7 @@
org.springframework.cloud
spring-cloud-netflix
- 1.2.1.BUILD-SNAPSHOT
+ 1.2.3.BUILD-SNAPSHOT
..
spring-cloud-netflix-core
@@ -44,6 +44,16 @@
spring-boot-starter-web
true
+
+ org.springframework.boot
+ spring-boot-starter-aop
+ true
+
+
+ org.springframework.retry
+ spring-retry
+ true
+
org.springframework.cloud
spring-cloud-commons
@@ -183,6 +193,12 @@
spring-boot-starter-test
test
+
+ org.springframework.cloud
+ spring-cloud-commons
+ test-jar
+ test
+
org.aspectj
aspectjweaver
diff --git a/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/feign/DefaultFeignLoggerFactory.java b/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/feign/DefaultFeignLoggerFactory.java
new file mode 100644
index 000000000..d7ca25d18
--- /dev/null
+++ b/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/feign/DefaultFeignLoggerFactory.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 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.feign;
+
+import feign.Logger;
+import feign.slf4j.Slf4jLogger;
+
+/**
+ * @author Venil Noronha
+ */
+public class DefaultFeignLoggerFactory implements FeignLoggerFactory {
+
+ private Logger logger;
+
+ public DefaultFeignLoggerFactory(Logger logger) {
+ this.logger = logger;
+ }
+
+ @Override
+ public Logger create(Class> type) {
+ return this.logger != null ? this.logger : new Slf4jLogger(type);
+ }
+
+}
diff --git a/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/feign/FeignClient.java b/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/feign/FeignClient.java
index 8c2e361f6..1dc139a16 100644
--- a/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/feign/FeignClient.java
+++ b/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/feign/FeignClient.java
@@ -90,6 +90,16 @@ public @interface FeignClient {
*/
Class> fallback() default void.class;
+ /**
+ * Define a fallback factory for the specified Feign client interface. The fallback
+ * factory must produce instances of fallback classes that implement the interface
+ * annotated by {@link FeignClient}. The fallback factory must be a valid spring
+ * bean.
+ *
+ * @see feign.hystrix.FallbackFactory for details.
+ */
+ Class> fallbackFactory() default void.class;
+
/**
* Path prefix to be used by all method-level mappings. Can be used with or without
* @RibbonClient.
diff --git a/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/feign/FeignClientFactoryBean.java b/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/feign/FeignClientFactoryBean.java
index fa345d88c..bf21845f3 100644
--- a/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/feign/FeignClientFactoryBean.java
+++ b/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/feign/FeignClientFactoryBean.java
@@ -39,7 +39,6 @@ import feign.Target.HardCodedTarget;
import feign.codec.Decoder;
import feign.codec.Encoder;
import feign.codec.ErrorDecoder;
-import feign.slf4j.Slf4jLogger;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -51,9 +50,9 @@ import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = false)
class FeignClientFactoryBean implements FactoryBean
diff --git a/spring-cloud-netflix-eureka-client/pom.xml b/spring-cloud-netflix-eureka-client/pom.xml
index 6d6bdcd9c..e43ee8ec8 100644
--- a/spring-cloud-netflix-eureka-client/pom.xml
+++ b/spring-cloud-netflix-eureka-client/pom.xml
@@ -5,7 +5,7 @@
org.springframework.cloud
spring-cloud-netflix
- 1.2.1.BUILD-SNAPSHOT
+ 1.2.3.BUILD-SNAPSHOT
..
spring-cloud-netflix-eureka-client
diff --git a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/EurekaClientAutoConfiguration.java b/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/EurekaClientAutoConfiguration.java
index 9f6e5c26c..d8b6205bb 100644
--- a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/EurekaClientAutoConfiguration.java
+++ b/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/EurekaClientAutoConfiguration.java
@@ -64,6 +64,7 @@ import static org.springframework.cloud.commons.util.IdUtils.getDefaultInstanceI
* @author Spencer Gibb
* @author Jon Schneider
* @author Matt Jenkins
+ * @author Ryan Baxter
*/
@Configuration
@EnableConfigurationProperties
@@ -106,14 +107,15 @@ public class EurekaClientAutoConfiguration {
@Bean
@ConditionalOnMissingBean(value = EurekaInstanceConfig.class, search = SearchStrategy.CURRENT)
public EurekaInstanceConfigBean eurekaInstanceConfigBean(InetUtils inetUtils) {
- RelaxedPropertyResolver relaxedPropertyResolver = new RelaxedPropertyResolver(env, "eureka.instance.");
EurekaInstanceConfigBean instance = new EurekaInstanceConfigBean(inetUtils);
instance.setNonSecurePort(this.nonSecurePort);
instance.setInstanceId(getDefaultInstanceId(this.env));
+
if (this.managementPort != this.nonSecurePort && this.managementPort != 0) {
if (StringUtils.hasText(this.hostname)) {
instance.setHostname(this.hostname);
}
+ RelaxedPropertyResolver relaxedPropertyResolver = new RelaxedPropertyResolver(env, "eureka.instance.");
String statusPageUrlPath = relaxedPropertyResolver.getProperty("statusPageUrlPath");
String healthCheckUrlPath = relaxedPropertyResolver.getProperty("healthCheckUrlPath");
if (StringUtils.hasText(statusPageUrlPath)) {
diff --git a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/EurekaInstanceConfigBean.java b/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/EurekaInstanceConfigBean.java
index cf4cc1854..4bf14cd41 100644
--- a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/EurekaInstanceConfigBean.java
+++ b/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/EurekaInstanceConfigBean.java
@@ -19,10 +19,14 @@ package org.springframework.cloud.netflix.eureka;
import java.util.HashMap;
import java.util.Map;
-import org.springframework.beans.factory.annotation.Value;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.boot.bind.RelaxedPropertyResolver;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.commons.util.InetUtils;
import org.springframework.cloud.commons.util.InetUtils.HostInfo;
+import org.springframework.context.EnvironmentAware;
+import org.springframework.core.env.Environment;
+import org.springframework.util.StringUtils;
import com.netflix.appinfo.DataCenterInfo;
import com.netflix.appinfo.InstanceInfo.InstanceStatus;
@@ -36,10 +40,13 @@ import lombok.Setter;
/**
* @author Dave Syer
* @author Spencer Gibb
+ * @author Ryan Baxter
*/
@Data
@ConfigurationProperties("eureka.instance")
-public class EurekaInstanceConfigBean implements CloudEurekaInstanceConfig {
+public class EurekaInstanceConfigBean implements CloudEurekaInstanceConfig, EnvironmentAware, InitializingBean {
+
+ private static final String UNKNOWN = "unknown";
@Getter(AccessLevel.PRIVATE)
@Setter(AccessLevel.PRIVATE)
@@ -52,8 +59,7 @@ public class EurekaInstanceConfigBean implements CloudEurekaInstanceConfig {
/**
* Get the name of the application to be registered with eureka.
*/
- @Value("${spring.application.name:unknown}")
- private String appname = "unknown";
+ private String appname = UNKNOWN;
/**
* Get the name of the application group to be registered with eureka.
@@ -119,8 +125,7 @@ public class EurekaInstanceConfigBean implements CloudEurekaInstanceConfig {
* virtual host name.Think of this as similar to the fully qualified domain name, that
* the users of your services will need to find this instance.
*/
- @Value("${spring.application.name:unknown}")
- private String virtualHostName;
+ private String virtualHostName = UNKNOWN;
/**
* Get the unique Id (within the scope of the appName) of this instance to be
@@ -135,8 +140,7 @@ public class EurekaInstanceConfigBean implements CloudEurekaInstanceConfig {
* secure virtual host name.Think of this as similar to the fully qualified domain
* name, that the users of your services will need to find this instance.
*/
- @Value("${spring.application.name:unknown}")
- private String secureVirtualHostName;
+ private String secureVirtualHostName = UNKNOWN;
/**
* Gets the AWS autoscaling group name associated with this instance. This information
@@ -275,6 +279,7 @@ public class EurekaInstanceConfigBean implements CloudEurekaInstanceConfig {
private InstanceStatus initialStatus = InstanceStatus.UP;
private String[] defaultAddressResolutionOrder = new String[0];
+ private Environment environment;
public String getHostname() {
return getHostName(false);
@@ -322,4 +327,20 @@ public class EurekaInstanceConfigBean implements CloudEurekaInstanceConfig {
}
return this.preferIpAddress ? this.ipAddress : this.hostname;
}
+
+ @Override
+ public void setEnvironment(Environment environment) {
+ this.environment = environment;
+ }
+
+ @Override
+ public void afterPropertiesSet() throws Exception {
+ RelaxedPropertyResolver springPropertyResolver = new RelaxedPropertyResolver(this.environment, "spring.application.");
+ String springAppName = springPropertyResolver.getProperty("name");
+ if(StringUtils.hasText(springAppName)) {
+ setAppname(springAppName);
+ setVirtualHostName(springAppName);
+ setSecureVirtualHostName(springAppName);
+ }
+ }
}
diff --git a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/EurekaClientAutoConfigurationTests.java b/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/EurekaClientAutoConfigurationTests.java
index c1a159150..be8145d69 100644
--- a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/EurekaClientAutoConfigurationTests.java
+++ b/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/EurekaClientAutoConfigurationTests.java
@@ -189,6 +189,32 @@ public class EurekaClientAutoConfigurationTests {
// Mockito.verify(http).addFilter(Matchers.any(HTTPBasicAuthFilter.class));
}
+ @Test
+ public void testDefaultAppName() throws Exception {
+ setupContext();
+ assertEquals("unknown", getInstanceConfig().getAppname());
+ assertEquals("unknown", getInstanceConfig().getVirtualHostName());
+ assertEquals("unknown", getInstanceConfig().getSecureVirtualHostName());
+ }
+
+ @Test
+ public void testAppName() throws Exception {
+ EnvironmentTestUtils.addEnvironment(this.context, "spring.application.name=mytest");
+ setupContext();
+ assertEquals("mytest", getInstanceConfig().getAppname());
+ assertEquals("mytest", getInstanceConfig().getVirtualHostName());
+ assertEquals("mytest", getInstanceConfig().getSecureVirtualHostName());
+ }
+
+ @Test
+ public void testAppNameUpper() throws Exception {
+ EnvironmentTestUtils.addEnvironment(this.context, "SPRING_APPLICATION_NAME=mytestupper");
+ setupContext();
+ assertEquals("mytestupper", getInstanceConfig().getAppname());
+ assertEquals("mytestupper", getInstanceConfig().getVirtualHostName());
+ assertEquals("mytestupper", getInstanceConfig().getSecureVirtualHostName());
+ }
+
private void testNonSecurePort(String propName) {
addEnvironment(this.context, propName + ":8888");
setupContext();
diff --git a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/EurekaInstanceConfigBeanTests.java b/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/EurekaInstanceConfigBeanTests.java
index 0f3f99b62..284388dd5 100644
--- a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/EurekaInstanceConfigBeanTests.java
+++ b/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/EurekaInstanceConfigBeanTests.java
@@ -20,15 +20,18 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.BeanCreationException;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
+import org.springframework.boot.bind.RelaxedPropertyResolver;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.commons.util.InetUtils;
import org.springframework.cloud.commons.util.InetUtilsProperties;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
+import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.test.util.ReflectionTestUtils;
-
+import org.springframework.util.StringUtils;
import com.netflix.appinfo.InstanceInfo.InstanceStatus;
import static org.junit.Assert.assertEquals;
@@ -38,6 +41,7 @@ import static org.springframework.boot.test.util.EnvironmentTestUtils.addEnviron
/**
* @author Dave Syer
* @author Spencer Gibb
+ * @author Ryan Baxter
*/
public class EurekaInstanceConfigBeanTests {
@@ -185,6 +189,14 @@ public class EurekaInstanceConfigBeanTests {
}
+ @Test
+ public void testDefaultAppName() throws Exception {
+ setupContext();
+ assertEquals("default app name is wrong", "unknown", getInstanceConfig().getAppname());
+ assertEquals("default virtual hostname is wrong", "unknown", getInstanceConfig().getVirtualHostName());
+ assertEquals("default secure virtual hostname is wrong", "unknown", getInstanceConfig().getSecureVirtualHostName());
+ }
+
private void setupContext() {
this.context.register(PropertyPlaceholderAutoConfiguration.class,
TestConfiguration.class);
@@ -198,9 +210,19 @@ public class EurekaInstanceConfigBeanTests {
@Configuration
@EnableConfigurationProperties
protected static class TestConfiguration {
+ @Autowired
+ ConfigurableEnvironment env;
@Bean
public EurekaInstanceConfigBean eurekaInstanceConfigBean() {
- return new EurekaInstanceConfigBean(new InetUtils(new InetUtilsProperties()));
+ EurekaInstanceConfigBean configBean = new EurekaInstanceConfigBean(new InetUtils(new InetUtilsProperties()));
+ RelaxedPropertyResolver springPropertyResolver = new RelaxedPropertyResolver(env, "spring.application.");
+ String springAppName = springPropertyResolver.getProperty("name");
+ if(StringUtils.hasText(springAppName)) {
+ configBean.setSecureVirtualHostName(springAppName);
+ configBean.setVirtualHostName(springAppName);
+ configBean.setAppname(springAppName);
+ }
+ return configBean;
}
}
diff --git a/spring-cloud-netflix-eureka-server/pom.xml b/spring-cloud-netflix-eureka-server/pom.xml
index 74b41f126..9ee12b8a4 100644
--- a/spring-cloud-netflix-eureka-server/pom.xml
+++ b/spring-cloud-netflix-eureka-server/pom.xml
@@ -5,7 +5,7 @@
org.springframework.cloud
spring-cloud-netflix
- 1.2.1.BUILD-SNAPSHOT
+ 1.2.3.BUILD-SNAPSHOT
..
spring-cloud-netflix-eureka-server
diff --git a/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EurekaServerConfiguration.java b/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EurekaServerConfiguration.java
index 0e2f81edf..8a19354a0 100644
--- a/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EurekaServerConfiguration.java
+++ b/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EurekaServerConfiguration.java
@@ -28,7 +28,6 @@ import javax.ws.rs.ext.Provider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
@@ -71,7 +70,7 @@ import com.sun.jersey.spi.container.servlet.ServletContainer;
@Configuration
@Import(EurekaServerInitializerConfiguration.class)
@EnableDiscoveryClient
-@EnableConfigurationProperties(EurekaDashboardProperties.class)
+@EnableConfigurationProperties({ EurekaDashboardProperties.class, InstanceRegistryProperties.class })
@PropertySource("classpath:/eureka/server.properties")
public class EurekaServerConfiguration extends WebMvcConfigurerAdapter {
/**
@@ -92,17 +91,9 @@ public class EurekaServerConfiguration extends WebMvcConfigurerAdapter {
@Autowired
private EurekaClient eurekaClient;
- /*
- * Setting expectedNumberOfRenewsPerMin to non-zero to ensure that even an isolated
- * server can adjust its eviction policy to the number of registrations (when it's
- * zero, even a successful registration won't reset the rate threshold in
- * InstanceRegistry.register()).
- */
- @Value("${eureka.server.expectedNumberOfRenewsPerMin:1}")
- private int expectedNumberOfRenewsPerMin;
+ @Autowired
+ private InstanceRegistryProperties instanceRegistryProperties;
- @Value("${eureka.server.defaultOpenForTrafficCount:1}")
- private int defaultOpenForTrafficCount;
public static final CloudJacksonJson JACKSON_JSON = new CloudJacksonJson();
@Bean
@@ -166,8 +157,9 @@ public class EurekaServerConfiguration extends WebMvcConfigurerAdapter {
ServerCodecs serverCodecs) {
this.eurekaClient.getApplications(); // force initialization
return new InstanceRegistry(this.eurekaServerConfig, this.eurekaClientConfig,
- serverCodecs, this.eurekaClient, this.expectedNumberOfRenewsPerMin,
- this.defaultOpenForTrafficCount);
+ serverCodecs, this.eurekaClient,
+ this.instanceRegistryProperties.getExpectedNumberOfRenewsPerMin(),
+ this.instanceRegistryProperties.getDefaultOpenForTrafficCount());
}
@Bean
diff --git a/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/InstanceRegistry.java b/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/InstanceRegistry.java
index 05c5676f7..3faaef7ee 100644
--- a/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/InstanceRegistry.java
+++ b/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/InstanceRegistry.java
@@ -18,6 +18,7 @@ package org.springframework.cloud.netflix.eureka.server;
import java.util.List;
+import com.netflix.eureka.lease.Lease;
import org.springframework.beans.BeansException;
import org.springframework.cloud.netflix.eureka.server.event.EurekaInstanceCanceledEvent;
import org.springframework.cloud.netflix.eureka.server.event.EurekaInstanceRegisteredEvent;
@@ -35,6 +36,7 @@ import com.netflix.eureka.registry.PeerAwareInstanceRegistryImpl;
import com.netflix.eureka.resources.ServerCodecs;
import lombok.extern.apachecommons.CommonsLog;
+import org.springframework.context.ApplicationEvent;
/**
* @author Spencer Gibb
@@ -64,8 +66,8 @@ public class InstanceRegistry extends PeerAwareInstanceRegistryImpl
/**
* If
* {@link PeerAwareInstanceRegistryImpl#openForTraffic(ApplicationInfoManager, int)}
- * is called with a zero * argument, it means that leases are not automatically *
- * cancelled if the instance * hasn't sent any renewals recently. This happens for a
+ * is called with a zero argument, it means that leases are not automatically
+ * cancelled if the instance hasn't sent any renewals recently. This happens for a
* standalone server. It seems like a bad default, so we set it to the smallest
* non-zero value we can, so that any instances that subsequently register can bump up
* the threshold.
@@ -78,37 +80,27 @@ public class InstanceRegistry extends PeerAwareInstanceRegistryImpl
@Override
public void register(InstanceInfo info, int leaseDuration, boolean isReplication) {
- if (log.isDebugEnabled()) {
- log.debug("register " + info.getAppName() + ", vip " + info.getVIPAddress()
- + ", leaseDuration " + leaseDuration + ", isReplication "
- + isReplication);
- }
- // TODO: what to publish from info (whole object?)
- this.ctxt.publishEvent(new EurekaInstanceRegisteredEvent(this, info,
- leaseDuration, isReplication));
-
+ handleRegistration(info, leaseDuration, isReplication);
super.register(info, leaseDuration, isReplication);
}
@Override
- public boolean cancel(String appName, String serverId, boolean isReplication) {
- if (log.isDebugEnabled()) {
- log.debug("cancel " + appName + " serverId " + serverId + ", isReplication {}"
- + isReplication);
- }
- this.ctxt.publishEvent(
- new EurekaInstanceCanceledEvent(this, appName, serverId, isReplication));
+ public void register(final InstanceInfo info, final boolean isReplication) {
+ handleRegistration(info, resolveInstanceLeaseDuration(info), isReplication);
+ super.register(info, isReplication);
+ }
+ @Override
+ public boolean cancel(String appName, String serverId, boolean isReplication) {
+ handleCancelation(appName, serverId, isReplication);
return super.cancel(appName, serverId, isReplication);
}
@Override
public boolean renew(final String appName, final String serverId,
boolean isReplication) {
- if (log.isDebugEnabled()) {
- log.debug("renew " + appName + " serverId " + serverId + ", isReplication {}"
- + isReplication);
- }
+ log("renew " + appName + " serverId " + serverId + ", isReplication {}"
+ + isReplication);
List applications = getSortedApplications();
for (Application input : applications) {
if (input.getName().equals(appName)) {
@@ -119,11 +111,49 @@ public class InstanceRegistry extends PeerAwareInstanceRegistryImpl
break;
}
}
- this.ctxt.publishEvent(new EurekaInstanceRenewedEvent(this, appName,
- serverId, instance, isReplication));
+ publishEvent(new EurekaInstanceRenewedEvent(this, appName, serverId,
+ instance, isReplication));
break;
}
}
return super.renew(appName, serverId, isReplication);
}
+
+ @Override
+ protected boolean internalCancel(String appName, String id, boolean isReplication) {
+ handleCancelation(appName, id, isReplication);
+ return super.internalCancel(appName, id, isReplication);
+ }
+
+ private void handleCancelation(String appName, String id, boolean isReplication) {
+ log("cancel " + appName + ", serverId " + id + ", isReplication " + isReplication);
+ publishEvent(new EurekaInstanceCanceledEvent(this, appName, id, isReplication));
+ }
+
+ private void handleRegistration(InstanceInfo info, int leaseDuration,
+ boolean isReplication) {
+ log("register " + info.getAppName() + ", vip " + info.getVIPAddress()
+ + ", leaseDuration " + leaseDuration + ", isReplication "
+ + isReplication);
+ publishEvent(new EurekaInstanceRegisteredEvent(this, info, leaseDuration,
+ isReplication));
+ }
+
+ private void log(String message) {
+ if (log.isDebugEnabled()) {
+ log.debug(message);
+ }
+ }
+
+ private void publishEvent(ApplicationEvent applicationEvent) {
+ this.ctxt.publishEvent(applicationEvent);
+ }
+
+ private int resolveInstanceLeaseDuration(final InstanceInfo info) {
+ int leaseDuration = Lease.DEFAULT_DURATION_IN_SECS;
+ if (info.getLeaseInfo() != null && info.getLeaseInfo().getDurationInSecs() > 0) {
+ leaseDuration = info.getLeaseInfo().getDurationInSecs();
+ }
+ return leaseDuration;
+ }
}
diff --git a/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/InstanceRegistryProperties.java b/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/InstanceRegistryProperties.java
new file mode 100644
index 000000000..87a0ebaca
--- /dev/null
+++ b/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/InstanceRegistryProperties.java
@@ -0,0 +1,63 @@
+/*
+ * 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.eureka.server;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+
+import static org.springframework.cloud.netflix.eureka.server.InstanceRegistryProperties.PREFIX;
+
+/**
+ * @author Spencer Gibb
+ */
+@ConfigurationProperties(PREFIX)
+public class InstanceRegistryProperties {
+
+ public static final String PREFIX = "eureka.instance.registry";
+
+
+ /* Default number of expected renews per minute, defaults to 1.
+ * Setting expectedNumberOfRenewsPerMin to non-zero to ensure that even an isolated
+ * server can adjust its eviction policy to the number of registrations (when it's
+ * zero, even a successful registration won't reset the rate threshold in
+ * InstanceRegistry.register()).
+ */
+ @Value("${eureka.server.expectedNumberOfRenewsPerMin:1}") // for backwards compatibility
+ private int expectedNumberOfRenewsPerMin = 1;
+
+ /** Value used in determining when leases are cancelled, default to 1 for standalone.
+ * Should be set to 0 for peer replicated eurekas */
+ @Value("${eureka.server.defaultOpenForTrafficCount:1}") // for backwards compatibility
+ private int defaultOpenForTrafficCount = 1;
+
+ public int getExpectedNumberOfRenewsPerMin() {
+ return expectedNumberOfRenewsPerMin;
+ }
+
+ public void setExpectedNumberOfRenewsPerMin(int expectedNumberOfRenewsPerMin) {
+ this.expectedNumberOfRenewsPerMin = expectedNumberOfRenewsPerMin;
+ }
+
+ public int getDefaultOpenForTrafficCount() {
+ return defaultOpenForTrafficCount;
+ }
+
+ public void setDefaultOpenForTrafficCount(int defaultOpenForTrafficCount) {
+ this.defaultOpenForTrafficCount = defaultOpenForTrafficCount;
+ }
+}
diff --git a/spring-cloud-netflix-eureka-server/src/test/java/org/springframework/cloud/netflix/eureka/server/InstanceRegistryTest.java b/spring-cloud-netflix-eureka-server/src/test/java/org/springframework/cloud/netflix/eureka/server/InstanceRegistryTest.java
new file mode 100644
index 000000000..9689e7795
--- /dev/null
+++ b/spring-cloud-netflix-eureka-server/src/test/java/org/springframework/cloud/netflix/eureka/server/InstanceRegistryTest.java
@@ -0,0 +1,186 @@
+package org.springframework.cloud.netflix.eureka.server;
+
+import static org.junit.Assert.*;
+import static org.mockito.Matchers.isA;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.doReturn;
+
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+
+import com.netflix.discovery.shared.Application;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.boot.test.mock.mockito.SpyBean;
+import org.springframework.cloud.netflix.eureka.server.InstanceRegistryTest.TestApplication;
+import org.springframework.cloud.netflix.eureka.server.event.EurekaInstanceCanceledEvent;
+import org.springframework.cloud.netflix.eureka.server.event.EurekaInstanceRegisteredEvent;
+import org.springframework.cloud.netflix.eureka.server.event.EurekaInstanceRenewedEvent;
+import org.springframework.context.ApplicationEvent;
+import org.springframework.context.ApplicationListener;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import com.netflix.appinfo.InstanceInfo;
+import com.netflix.appinfo.LeaseInfo;
+import com.netflix.eureka.registry.PeerAwareInstanceRegistry;
+
+/**
+ * @author Bartlomiej Slota
+ */
+@RunWith(SpringJUnit4ClassRunner.class)
+@SpringBootTest(classes = TestApplication.class,
+ webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
+ value = {"spring.application.name=eureka", "logging.level.org.springframework."
+ + "cloud.netflix.eureka.server.InstanceRegistry=DEBUG"})
+public class InstanceRegistryTest {
+
+ private final List applicationEvents = new LinkedList<>();
+ private static final String APP_NAME = "MY-APP-NAME";
+ private static final String HOST_NAME = "my-host-name";
+
+ @SpyBean(PeerAwareInstanceRegistry.class)
+ private InstanceRegistry instanceRegistry;
+
+ @MockBean
+ private ApplicationListener
+ instanceRegisteredEventListenerMock;
+
+ @MockBean
+ private ApplicationListener
+ instanceCanceledEventListenerMock;
+
+ @MockBean
+ private ApplicationListener instanceRenewedEventListener;
+
+ @Before
+ public void setup() {
+ applicationEvents.clear();
+ Answer applicationListenerAnswer = prepareListenerMockAnswer();
+ doAnswer(applicationListenerAnswer).when(instanceRegisteredEventListenerMock)
+ .onApplicationEvent(isA(EurekaInstanceRegisteredEvent.class));
+ doAnswer(applicationListenerAnswer).when(instanceCanceledEventListenerMock)
+ .onApplicationEvent(isA(EurekaInstanceCanceledEvent.class));
+ doAnswer(applicationListenerAnswer).when(instanceRenewedEventListener)
+ .onApplicationEvent(isA(EurekaInstanceRenewedEvent.class));
+ }
+
+
+ @Test
+ public void testRegister() throws Exception {
+ // creating instance info
+ final LeaseInfo leaseInfo = getLeaseInfo();
+ final InstanceInfo instanceInfo = getInstanceInfo(leaseInfo);
+ // calling tested method
+ instanceRegistry.register(instanceInfo, false);
+ // event of proper type is registered
+ assertEquals(1, applicationEvents.size());
+ assertTrue(applicationEvents.get(0) instanceof EurekaInstanceRegisteredEvent);
+ // event details are correct
+ final EurekaInstanceRegisteredEvent registeredEvent =
+ (EurekaInstanceRegisteredEvent) (applicationEvents.get(0));
+ assertEquals(instanceInfo, registeredEvent.getInstanceInfo());
+ assertEquals(leaseInfo.getDurationInSecs(), registeredEvent.getLeaseDuration());
+ assertEquals(instanceRegistry, registeredEvent.getSource());
+ assertFalse(registeredEvent.isReplication());
+ }
+
+ @Test
+ public void testDefaultLeaseDurationRegisterEvent() throws Exception {
+ // creating instance info
+ final InstanceInfo instanceInfo = getInstanceInfo(null);
+ // calling tested method
+ instanceRegistry.register(instanceInfo, false);
+ // instance info duration is set to default
+ final EurekaInstanceRegisteredEvent registeredEvent =
+ (EurekaInstanceRegisteredEvent) (applicationEvents.get(0));
+ assertEquals(LeaseInfo.DEFAULT_LEASE_DURATION,
+ registeredEvent.getLeaseDuration());
+ }
+
+ @Test
+ public void testInternalCancel() throws Exception {
+ // calling tested method
+ instanceRegistry.internalCancel(APP_NAME, HOST_NAME, false);
+ // event of proper type is registered
+ assertEquals(1, applicationEvents.size());
+ assertTrue(applicationEvents.get(0) instanceof EurekaInstanceCanceledEvent);
+ // event details are correct
+ final EurekaInstanceCanceledEvent registeredEvent =
+ (EurekaInstanceCanceledEvent) (applicationEvents.get(0));
+ assertEquals(APP_NAME, registeredEvent.getAppName());
+ assertEquals(HOST_NAME, registeredEvent.getServerId());
+ assertEquals(instanceRegistry, registeredEvent.getSource());
+ assertFalse(registeredEvent.isReplication());
+ }
+
+ @Test
+ public void testRenew() throws Exception {
+ // creating application list
+ final LeaseInfo leaseInfo = getLeaseInfo();
+ final InstanceInfo instanceInfo = getInstanceInfo(leaseInfo);
+ final List instances = new ArrayList<>();
+ instances.add(instanceInfo);
+ final Application application = new Application(APP_NAME, instances);
+ final List applications = new ArrayList<>();
+ applications.add(application);
+ // stubbing applications list
+ doReturn(applications).when(instanceRegistry).getSortedApplications();
+ // calling tested method
+ instanceRegistry.renew(APP_NAME, HOST_NAME, false);
+ // event of proper type is registered
+ assertEquals(1, applicationEvents.size());
+ assertTrue(applicationEvents.get(0) instanceof EurekaInstanceRenewedEvent);
+ // event details are correct
+ final EurekaInstanceRenewedEvent registeredEvent = (EurekaInstanceRenewedEvent)
+ (applicationEvents.get(0));
+ assertEquals(APP_NAME, registeredEvent.getAppName());
+ assertEquals(HOST_NAME, registeredEvent.getServerId());
+ assertEquals(instanceRegistry, registeredEvent.getSource());
+ assertEquals(instanceInfo, registeredEvent.getInstanceInfo());
+ assertFalse(registeredEvent.isReplication());
+ }
+
+ @Configuration
+ @EnableAutoConfiguration
+ @EnableEurekaServer
+ protected static class TestApplication {
+ public static void main(String[] args) {
+ new SpringApplicationBuilder(TestApplication.class).run(args);
+ }
+ }
+
+ private LeaseInfo getLeaseInfo() {
+ LeaseInfo.Builder leaseBuilder = LeaseInfo.Builder.newBuilder();
+ leaseBuilder.setRenewalIntervalInSecs(10);
+ leaseBuilder.setDurationInSecs(15);
+ return leaseBuilder.build();
+ }
+
+ private InstanceInfo getInstanceInfo(LeaseInfo leaseInfo) {
+ InstanceInfo.Builder builder = InstanceInfo.Builder.newBuilder();
+ builder.setAppName(APP_NAME);
+ builder.setHostName(HOST_NAME);
+ builder.setPort(8008);
+ builder.setLeaseInfo(leaseInfo);
+ return builder.build();
+ }
+
+ private Answer prepareListenerMockAnswer() {
+ return new Answer() {
+ @Override
+ public Object answer(InvocationOnMock invocation) throws Throwable {
+ return applicationEvents
+ .add((ApplicationEvent) invocation.getArguments()[0]);
+ }
+ };
+ }
+}
\ No newline at end of file
diff --git a/spring-cloud-netflix-hystrix-amqp/pom.xml b/spring-cloud-netflix-hystrix-amqp/pom.xml
index b3dcd0375..1155ec05d 100644
--- a/spring-cloud-netflix-hystrix-amqp/pom.xml
+++ b/spring-cloud-netflix-hystrix-amqp/pom.xml
@@ -5,7 +5,7 @@
org.springframework.cloud
spring-cloud-netflix
- 1.2.1.BUILD-SNAPSHOT
+ 1.2.3.BUILD-SNAPSHOT
..
spring-cloud-netflix-hystrix-amqp
diff --git a/spring-cloud-netflix-hystrix-dashboard/pom.xml b/spring-cloud-netflix-hystrix-dashboard/pom.xml
index 64d5f7198..e300272cb 100644
--- a/spring-cloud-netflix-hystrix-dashboard/pom.xml
+++ b/spring-cloud-netflix-hystrix-dashboard/pom.xml
@@ -8,7 +8,7 @@
org.springframework.cloud
spring-cloud-netflix
- 1.2.1.BUILD-SNAPSHOT
+ 1.2.3.BUILD-SNAPSHOT
..
diff --git a/spring-cloud-netflix-hystrix-dashboard/src/main/java/org/springframework/cloud/netflix/hystrix/dashboard/HystrixDashboardConfiguration.java b/spring-cloud-netflix-hystrix-dashboard/src/main/java/org/springframework/cloud/netflix/hystrix/dashboard/HystrixDashboardConfiguration.java
index 38569b633..4431463f1 100644
--- a/spring-cloud-netflix-hystrix-dashboard/src/main/java/org/springframework/cloud/netflix/hystrix/dashboard/HystrixDashboardConfiguration.java
+++ b/spring-cloud-netflix-hystrix-dashboard/src/main/java/org/springframework/cloud/netflix/hystrix/dashboard/HystrixDashboardConfiguration.java
@@ -53,7 +53,6 @@ import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;
* @author Dave Syer
* @author Roy Clarkson
*/
-@SuppressWarnings("deprecation")
@Configuration
@EnableConfigurationProperties(HystrixDashboardProperties.class)
public class HystrixDashboardConfiguration {
@@ -263,6 +262,7 @@ public class HystrixDashboardConfiguration {
}
}
+ @SuppressWarnings("deprecation")
private static class ProxyConnectionManager {
private final static PoolingClientConnectionManager threadSafeConnectionManager = new PoolingClientConnectionManager();
diff --git a/spring-cloud-netflix-hystrix-stream/pom.xml b/spring-cloud-netflix-hystrix-stream/pom.xml
index dd4c8f517..852cc61ad 100644
--- a/spring-cloud-netflix-hystrix-stream/pom.xml
+++ b/spring-cloud-netflix-hystrix-stream/pom.xml
@@ -5,7 +5,7 @@
org.springframework.cloud
spring-cloud-netflix
- 1.2.1.BUILD-SNAPSHOT
+ 1.2.3.BUILD-SNAPSHOT
..
spring-cloud-netflix-hystrix-stream
diff --git a/spring-cloud-netflix-sidecar/pom.xml b/spring-cloud-netflix-sidecar/pom.xml
index c39d4005f..01f838d71 100644
--- a/spring-cloud-netflix-sidecar/pom.xml
+++ b/spring-cloud-netflix-sidecar/pom.xml
@@ -5,7 +5,7 @@
org.springframework.cloud
spring-cloud-netflix
- 1.2.1.BUILD-SNAPSHOT
+ 1.2.3.BUILD-SNAPSHOT
..
spring-cloud-netflix-sidecar
diff --git a/spring-cloud-netflix-sidecar/src/main/java/org/springframework/cloud/netflix/sidecar/SidecarConfiguration.java b/spring-cloud-netflix-sidecar/src/main/java/org/springframework/cloud/netflix/sidecar/SidecarConfiguration.java
index 52357293b..17db83f53 100644
--- a/spring-cloud-netflix-sidecar/src/main/java/org/springframework/cloud/netflix/sidecar/SidecarConfiguration.java
+++ b/spring-cloud-netflix-sidecar/src/main/java/org/springframework/cloud/netflix/sidecar/SidecarConfiguration.java
@@ -16,10 +16,13 @@
package org.springframework.cloud.netflix.sidecar;
+import static org.springframework.cloud.commons.util.IdUtils.getDefaultInstanceId;
+
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.boot.bind.RelaxedPropertyResolver;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.client.actuator.HasFeatures;
import org.springframework.cloud.commons.util.InetUtils;
@@ -32,10 +35,9 @@ import org.springframework.util.StringUtils;
import com.netflix.appinfo.HealthCheckHandler;
import com.netflix.discovery.EurekaClientConfig;
-import static org.springframework.cloud.commons.util.IdUtils.getDefaultInstanceId;
-
/**
* @author Spencer Gibb
+ * @author Ryan Baxter
*/
@Configuration
@EnableConfigurationProperties
@@ -73,9 +75,16 @@ public class SidecarConfiguration {
@Bean
public EurekaInstanceConfigBean eurekaInstanceConfigBean() {
EurekaInstanceConfigBean config = new EurekaInstanceConfigBean(inetUtils);
+ RelaxedPropertyResolver springPropertyResolver = new RelaxedPropertyResolver(env, "spring.application.");
+ String springAppName = springPropertyResolver.getProperty("name");
int port = this.sidecarProperties.getPort();
config.setNonSecurePort(port);
config.setInstanceId(getDefaultInstanceId(this.env));
+ if(StringUtils.hasText(springAppName)) {
+ config.setAppname(springAppName);
+ config.setVirtualHostName(springAppName);
+ config.setSecureVirtualHostName(springAppName);
+ }
if (StringUtils.hasText(this.hostname)) {
config.setHostname(this.hostname);
}
diff --git a/spring-cloud-netflix-spectator/pom.xml b/spring-cloud-netflix-spectator/pom.xml
index 55715ac68..5c9f16c84 100644
--- a/spring-cloud-netflix-spectator/pom.xml
+++ b/spring-cloud-netflix-spectator/pom.xml
@@ -6,7 +6,7 @@
org.springframework.cloud
spring-cloud-netflix
- 1.2.1.BUILD-SNAPSHOT
+ 1.2.3.BUILD-SNAPSHOT
..
spring-cloud-netflix-spectator
diff --git a/spring-cloud-netflix-turbine-stream/pom.xml b/spring-cloud-netflix-turbine-stream/pom.xml
index 7fdeef11d..73d7fcba0 100644
--- a/spring-cloud-netflix-turbine-stream/pom.xml
+++ b/spring-cloud-netflix-turbine-stream/pom.xml
@@ -5,7 +5,7 @@
org.springframework.cloud
spring-cloud-netflix
- 1.2.1.BUILD-SNAPSHOT
+ 1.2.3.BUILD-SNAPSHOT
..
spring-cloud-netflix-turbine-stream
diff --git a/spring-cloud-netflix-turbine/pom.xml b/spring-cloud-netflix-turbine/pom.xml
index f4ba02b16..9d1a39e0b 100644
--- a/spring-cloud-netflix-turbine/pom.xml
+++ b/spring-cloud-netflix-turbine/pom.xml
@@ -5,7 +5,7 @@
org.springframework.cloud
spring-cloud-netflix
- 1.2.1.BUILD-SNAPSHOT
+ 1.2.3.BUILD-SNAPSHOT
..
spring-cloud-netflix-turbine
diff --git a/spring-cloud-starter-archaius/pom.xml b/spring-cloud-starter-archaius/pom.xml
index 29c05ed3a..1a9d18879 100644
--- a/spring-cloud-starter-archaius/pom.xml
+++ b/spring-cloud-starter-archaius/pom.xml
@@ -5,7 +5,7 @@
org.springframework.cloud
spring-cloud-netflix
- 1.2.1.BUILD-SNAPSHOT
+ 1.2.3.BUILD-SNAPSHOT
..
spring-cloud-starter-archaius
diff --git a/spring-cloud-starter-atlas/pom.xml b/spring-cloud-starter-atlas/pom.xml
index ef07240ef..f35598d00 100644
--- a/spring-cloud-starter-atlas/pom.xml
+++ b/spring-cloud-starter-atlas/pom.xml
@@ -5,7 +5,7 @@
org.springframework.cloud
spring-cloud-netflix
- 1.2.1.BUILD-SNAPSHOT
+ 1.2.3.BUILD-SNAPSHOT
..
spring-cloud-starter-atlas
diff --git a/spring-cloud-starter-eureka-server/pom.xml b/spring-cloud-starter-eureka-server/pom.xml
index 281d6840b..239c6d1f5 100644
--- a/spring-cloud-starter-eureka-server/pom.xml
+++ b/spring-cloud-starter-eureka-server/pom.xml
@@ -5,7 +5,7 @@
org.springframework.cloud
spring-cloud-netflix
- 1.2.1.BUILD-SNAPSHOT
+ 1.2.3.BUILD-SNAPSHOT
..
spring-cloud-starter-eureka-server
diff --git a/spring-cloud-starter-eureka/pom.xml b/spring-cloud-starter-eureka/pom.xml
index 5db347ea8..dfe0cba5b 100644
--- a/spring-cloud-starter-eureka/pom.xml
+++ b/spring-cloud-starter-eureka/pom.xml
@@ -5,7 +5,7 @@
org.springframework.cloud
spring-cloud-netflix
- 1.2.1.BUILD-SNAPSHOT
+ 1.2.3.BUILD-SNAPSHOT
..
spring-cloud-starter-eureka
diff --git a/spring-cloud-starter-feign/pom.xml b/spring-cloud-starter-feign/pom.xml
index cfced5bb3..d24c79f4c 100644
--- a/spring-cloud-starter-feign/pom.xml
+++ b/spring-cloud-starter-feign/pom.xml
@@ -5,7 +5,7 @@
org.springframework.cloud
spring-cloud-netflix
- 1.2.1.BUILD-SNAPSHOT
+ 1.2.3.BUILD-SNAPSHOT
..
spring-cloud-starter-feign
diff --git a/spring-cloud-starter-hystrix-dashboard/pom.xml b/spring-cloud-starter-hystrix-dashboard/pom.xml
index ef126ed61..b78098b66 100644
--- a/spring-cloud-starter-hystrix-dashboard/pom.xml
+++ b/spring-cloud-starter-hystrix-dashboard/pom.xml
@@ -5,7 +5,7 @@
org.springframework.cloud
spring-cloud-netflix
- 1.2.1.BUILD-SNAPSHOT
+ 1.2.3.BUILD-SNAPSHOT
..
spring-cloud-starter-hystrix-dashboard
diff --git a/spring-cloud-starter-hystrix/pom.xml b/spring-cloud-starter-hystrix/pom.xml
index 220ad2e3b..4034e8b46 100644
--- a/spring-cloud-starter-hystrix/pom.xml
+++ b/spring-cloud-starter-hystrix/pom.xml
@@ -5,7 +5,7 @@
org.springframework.cloud
spring-cloud-netflix
- 1.2.1.BUILD-SNAPSHOT
+ 1.2.3.BUILD-SNAPSHOT
..
spring-cloud-starter-hystrix
diff --git a/spring-cloud-starter-ribbon/pom.xml b/spring-cloud-starter-ribbon/pom.xml
index 533583c0e..e2937c5f4 100644
--- a/spring-cloud-starter-ribbon/pom.xml
+++ b/spring-cloud-starter-ribbon/pom.xml
@@ -5,7 +5,7 @@
org.springframework.cloud
spring-cloud-netflix
- 1.2.1.BUILD-SNAPSHOT
+ 1.2.3.BUILD-SNAPSHOT
..
spring-cloud-starter-ribbon
@@ -20,6 +20,14 @@
${basedir}/../..
+
+ org.springframework.boot
+ spring-boot-starter-aop
+
+
+ org.springframework.retry
+ spring-retry
+
org.springframework.cloud
spring-cloud-starter
diff --git a/spring-cloud-starter-spectator/pom.xml b/spring-cloud-starter-spectator/pom.xml
index ee66b0eb2..56927535c 100644
--- a/spring-cloud-starter-spectator/pom.xml
+++ b/spring-cloud-starter-spectator/pom.xml
@@ -5,7 +5,7 @@
org.springframework.cloud
spring-cloud-netflix
- 1.2.1.BUILD-SNAPSHOT
+ 1.2.3.BUILD-SNAPSHOT
..
spring-cloud-starter-spectator
diff --git a/spring-cloud-starter-turbine-amqp/pom.xml b/spring-cloud-starter-turbine-amqp/pom.xml
index 15e5a043a..f7da82435 100644
--- a/spring-cloud-starter-turbine-amqp/pom.xml
+++ b/spring-cloud-starter-turbine-amqp/pom.xml
@@ -5,7 +5,7 @@
org.springframework.cloud
spring-cloud-netflix
- 1.2.1.BUILD-SNAPSHOT
+ 1.2.3.BUILD-SNAPSHOT
..
spring-cloud-starter-turbine-amqp
diff --git a/spring-cloud-starter-turbine-stream/pom.xml b/spring-cloud-starter-turbine-stream/pom.xml
index ef45f8330..fa71b1d2b 100644
--- a/spring-cloud-starter-turbine-stream/pom.xml
+++ b/spring-cloud-starter-turbine-stream/pom.xml
@@ -5,7 +5,7 @@
org.springframework.cloud
spring-cloud-netflix
- 1.2.1.BUILD-SNAPSHOT
+ 1.2.3.BUILD-SNAPSHOT
..
spring-cloud-starter-turbine-stream
diff --git a/spring-cloud-starter-turbine/pom.xml b/spring-cloud-starter-turbine/pom.xml
index 3639be91c..03ec13466 100644
--- a/spring-cloud-starter-turbine/pom.xml
+++ b/spring-cloud-starter-turbine/pom.xml
@@ -5,7 +5,7 @@
org.springframework.cloud
spring-cloud-netflix
- 1.2.1.BUILD-SNAPSHOT
+ 1.2.3.BUILD-SNAPSHOT
..
spring-cloud-starter-turbine
diff --git a/spring-cloud-starter-zuul/pom.xml b/spring-cloud-starter-zuul/pom.xml
index 8b664ac84..55436f6b2 100644
--- a/spring-cloud-starter-zuul/pom.xml
+++ b/spring-cloud-starter-zuul/pom.xml
@@ -5,7 +5,7 @@
org.springframework.cloud
spring-cloud-netflix
- 1.2.1.BUILD-SNAPSHOT
+ 1.2.3.BUILD-SNAPSHOT
..
spring-cloud-starter-zuul