Commit 0204978b by Spencer Gibb

Upgrade eureka to 1.2.5.

Change EurekaInstanceConfig.getSID to getInstanceId fixes gh-554
parent da04c537
...@@ -123,7 +123,7 @@ It's worth spending a bit of time understanding how the Eureka metadata works, s ...@@ -123,7 +123,7 @@ It's worth spending a bit of time understanding how the Eureka metadata works, s
==== Using Eureka on Cloudfoundry ==== Using Eureka on Cloudfoundry
Cloudfoundry has a global router so that all instances of the same app have the same hostname (it's the same in other PaaS solutions with a similar architecture). This isn't necessarily a barrier to using Eureka, but if you use the router (recommended, or even mandatory depending on the way your platform was set up), you need to explicitly set the hostname and port numbers (secure or non-secure) so that they use the router. You might also want to use instance metadata so you can distinguish between the instances on the client (e.g. in a custom load balancer). For example: Cloudfoundry has a global router so that all instances of the same app have the same hostname (it's the same in other PaaS solutions with a similar architecture). This isn't necessarily a barrier to using Eureka, but if you use the router (recommended, or even mandatory depending on the way your platform was set up), you need to explicitly set the hostname and port numbers (secure or non-secure) so that they use the router. You might also want to use instance metadata so you can distinguish between the instances on the client (e.g. in a custom load balancer). By default, the `eureka.instance.instanceId` is `vcap.application.instance_id`. For example:
.application.yml .application.yml
---- ----
...@@ -131,8 +131,6 @@ eureka: ...@@ -131,8 +131,6 @@ eureka:
instance: instance:
hostname: ${vcap.application.uris[0]} hostname: ${vcap.application.uris[0]}
nonSecurePort: 80 nonSecurePort: 80
metadataMap:
instanceId: ${vcap.application.instance_id:${spring.application.name}:${spring.application.instance_id:${server.port}}}
---- ----
Depending on the way the security rules are set up in your Cloudfoundry instance, you might be able to register and use the IP address of the host VM for direct service-to-service calls. This feature is not (yet) available on Pivotal Web Services (https://run.pivotal.io[PWS]). Depending on the way the security rules are set up in your Cloudfoundry instance, you might be able to register and use the IP address of the host VM for direct service-to-service calls. This feature is not (yet) available on Pivotal Web Services (https://run.pivotal.io[PWS]).
...@@ -153,16 +151,17 @@ public EurekaInstanceConfigBean eurekaInstanceConfig() { ...@@ -153,16 +151,17 @@ public EurekaInstanceConfigBean eurekaInstanceConfig() {
} }
---- ----
==== Making the Eureka Instance ID Unique ==== Changing the Eureka Instance ID
By default a eureka instance is registered with an ID that is equal to its host name (i.e. only one service per host). Using Spring Cloud you can override this by providing a unique identifier in `eureka.instance.metadataMap.instanceId`. For example: A vanilla Netflix Eureka instance is registered with an ID that is equal to its host name (i.e. only one service per host). Spring Cloud Eureka provides a sensible default that looks like this: `${spring.cloud.client.hostname}:${spring.application.name}:${spring.application.instance_id:${server.port}}}`. For example `myhost:myappname:8080`.
Using Spring Cloud you can override this by providing a unique identifier in `eureka.instance.instanceId`. For example:
.application.yml .application.yml
---- ----
eureka: eureka:
instance: instance:
metadataMap: instanceId: ${spring.application.name}:${spring.application.instance_id:${random.value}}
instanceId: ${spring.application.name}:${spring.application.instance_id:${random.value}}
---- ----
With this metadata, and multiple service instances deployed on With this metadata, and multiple service instances deployed on
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
<spring-cloud-stream.version>1.0.0.BUILD-SNAPSHOT</spring-cloud-stream.version> <spring-cloud-stream.version>1.0.0.BUILD-SNAPSHOT</spring-cloud-stream.version>
<main.basedir>${basedir}</main.basedir> <main.basedir>${basedir}</main.basedir>
<archaius.version>0.6.5</archaius.version> <archaius.version>0.6.5</archaius.version>
<eureka.version>1.2.5-rc.1</eureka.version> <eureka.version>1.2.5</eureka.version>
<feign.version>8.10.0</feign.version> <feign.version>8.10.0</feign.version>
<hystrix.version>1.4.15</hystrix.version> <hystrix.version>1.4.15</hystrix.version>
<ribbon.version>2.1.0</ribbon.version> <ribbon.version>2.1.0</ribbon.version>
......
...@@ -85,7 +85,7 @@ public class EurekaClientAutoConfiguration { ...@@ -85,7 +85,7 @@ public class EurekaClientAutoConfiguration {
public EurekaInstanceConfigBean eurekaInstanceConfigBean() { public EurekaInstanceConfigBean eurekaInstanceConfigBean() {
EurekaInstanceConfigBean instance = new EurekaInstanceConfigBean(); EurekaInstanceConfigBean instance = new EurekaInstanceConfigBean();
instance.setNonSecurePort(this.nonSecurePort); instance.setNonSecurePort(this.nonSecurePort);
instance.setSid(getDefaultInstanceId(env)); instance.setInstanceId(getDefaultInstanceId(env));
return instance; return instance;
} }
......
...@@ -73,7 +73,7 @@ public class EurekaInstanceConfigBean implements EurekaInstanceConfig { ...@@ -73,7 +73,7 @@ public class EurekaInstanceConfigBean implements EurekaInstanceConfig {
@Value("${spring.application.name:unknown}") @Value("${spring.application.name:unknown}")
private String virtualHostName; private String virtualHostName;
private String sid; private String instanceId;
private String secureVirtualHostName; private String secureVirtualHostName;
...@@ -112,11 +112,11 @@ public class EurekaInstanceConfigBean implements EurekaInstanceConfig { ...@@ -112,11 +112,11 @@ public class EurekaInstanceConfigBean implements EurekaInstanceConfig {
} }
@Override @Override
public String getSID() { public String getInstanceId() {
if (this.sid == null && this.metadataMap != null) { if (this.instanceId == null && this.metadataMap != null) {
return this.metadataMap.get("instanceId"); return this.metadataMap.get("instanceId");
} }
return sid; return instanceId;
} }
@Override @Override
......
...@@ -42,7 +42,7 @@ public class InstanceInfoFactory { ...@@ -42,7 +42,7 @@ public class InstanceInfoFactory {
builder.setNamespace(config.getNamespace()) builder.setNamespace(config.getNamespace())
.setAppName(config.getAppname()) .setAppName(config.getAppname())
.setSID(config.getSID()) .setInstanceId(config.getInstanceId())
.setAppGroupName(config.getAppGroupName()) .setAppGroupName(config.getAppGroupName())
.setDataCenterInfo(config.getDataCenterInfo()) .setDataCenterInfo(config.getDataCenterInfo())
.setIPAddr(config.getIpAddress()) .setIPAddr(config.getIpAddress())
......
...@@ -68,11 +68,11 @@ public class EurekaInstanceConfigBeanTests { ...@@ -68,11 +68,11 @@ public class EurekaInstanceConfigBeanTests {
} }
@Test @Test
public void sid() { public void instanceId() {
addEnvironment(this.context, "eureka.instance.sid:special"); addEnvironment(this.context, "eureka.instance.instanceId:special");
setupContext(); setupContext();
EurekaInstanceConfigBean instance = getInstanceConfig(); EurekaInstanceConfigBean instance = getInstanceConfig();
assertEquals("special", instance.getSID()); assertEquals("special", instance.getInstanceId());
} }
@Test @Test
......
...@@ -31,8 +31,8 @@ public class InstanceInfoFactoryTests { ...@@ -31,8 +31,8 @@ public class InstanceInfoFactoryTests {
} }
@Test @Test
public void instanceIdIsSidWhenSet() { public void instanceInfoIdIsInstanceIdWhenSet() {
InstanceInfo instanceInfo = setupInstance("eureka.instance.sid:special"); InstanceInfo instanceInfo = setupInstance("eureka.instance.instanceId:special");
assertEquals("special", instanceInfo.getId()); assertEquals("special", instanceInfo.getId());
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment