diff --git a/sds-delivery/pom.xml b/sds-delivery/pom.xml
index 8d75798..0b91c25 100644
--- a/sds-delivery/pom.xml
+++ b/sds-delivery/pom.xml
@@ -10,6 +10,15 @@
sds delivery framework
https://github.com/1991wangliang/sds
+
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 1.5.10.RELEASE
+
+
+
+
The Apache License, Version 2.0
@@ -51,12 +60,12 @@
yyyyMMddHHmmss
UTF-8
UTF-8
- 1.7
- 1.7
+ 1.8
+ 1.8
3.6.0
- Dalston.SR1
- 4.3.7.RELEASE
+ Edgware.SR3
+
@@ -82,19 +91,6 @@
-
- org.springframework
- spring-web
- ${org.springframework-version}
-
-
-
-
- javax.servlet
- javax.servlet-api
- 3.1.0
-
-
org.springframework.boot
@@ -104,26 +100,26 @@
org.springframework.cloud
- spring-cloud-starter-eureka
- 1.3.1.RELEASE
+ spring-cloud-starter-consul-discovery
-
-
+
+
+
+ org.springframework.cloud
+ spring-cloud-dependencies
+ ${spring-cloud.version}
+ pom
+ import
+
+
+
-
- org.apache.maven.plugins
- maven-compiler-plugin
-
- 1.7
- 1.7
-
-
org.apache.maven.plugins
maven-compiler-plugin
diff --git a/sds-delivery/src/main/java/com/lorne/sds/server/service/impl/DeliveryServiceImpl.java b/sds-delivery/src/main/java/com/lorne/sds/server/service/impl/DeliveryServiceImpl.java
index b2a5633..9dc51a7 100644
--- a/sds-delivery/src/main/java/com/lorne/sds/server/service/impl/DeliveryServiceImpl.java
+++ b/sds-delivery/src/main/java/com/lorne/sds/server/service/impl/DeliveryServiceImpl.java
@@ -8,7 +8,6 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
-import org.springframework.cloud.netflix.eureka.EurekaDiscoveryClient;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
@@ -61,7 +60,7 @@ public void channelInactive(ChannelHandlerContext ctx) {
private ServiceInstance getInstance(String ipPort) {
List instances = discoveryClient.getInstances(DeliveryServerService.SOCKET_SERVER_KEY);
for (ServiceInstance instance : instances) {
- String ip = ((EurekaDiscoveryClient.EurekaServiceInstance) instance).getInstanceInfo().getIPAddr();
+ String ip = instance.getHost();
int port = instance.getPort();
String instancesIpPort = String.format("%s:%d", ip, port);
if (instancesIpPort.equals(ipPort)) {
diff --git a/sds-delivery/src/main/java/com/lorne/sds/server/service/impl/SettingServiceImpl.java b/sds-delivery/src/main/java/com/lorne/sds/server/service/impl/SettingServiceImpl.java
index 796ff8c..9253a57 100644
--- a/sds-delivery/src/main/java/com/lorne/sds/server/service/impl/SettingServiceImpl.java
+++ b/sds-delivery/src/main/java/com/lorne/sds/server/service/impl/SettingServiceImpl.java
@@ -3,14 +3,11 @@
import com.lorne.sds.server.model.DeliveryModel;
import com.lorne.sds.server.service.RedisService;
import com.lorne.sds.server.service.SettingService;
-import com.netflix.appinfo.InstanceInfo;
-import com.netflix.discovery.EurekaClient;
-import com.netflix.discovery.shared.Application;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
-import org.springframework.cloud.netflix.eureka.serviceregistry.EurekaRegistration;
+import org.springframework.cloud.client.ServiceInstance;
+import org.springframework.cloud.client.discovery.DiscoveryClient;
+import org.springframework.cloud.client.serviceregistry.Registration;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
@@ -24,14 +21,16 @@
@Service
public class SettingServiceImpl implements SettingService{
- private Logger logger = LoggerFactory.getLogger(SettingServiceImpl.class);
@Autowired
- private EurekaRegistration registration;
+ private DiscoveryClient discoveryClient;
@Autowired
private RedisService redisService;
+ @Autowired
+ private Registration registration;
+
@Value("${delivery.port}")
private int deliveryPort;
@@ -41,22 +40,9 @@ public class SettingServiceImpl implements SettingService{
private int maxCheckTime;
- @Autowired
- private EurekaClient eurekaClient;
-
- public List getConfigServiceInstances(String key) {
- Application application = eurekaClient.getApplication(key);
- if (application == null) {
- logger.error("获取eureka服务失败!");
- }
- return application!=null?application.getInstances():new ArrayList();
- }
-
-
-
@Override
public String getDeliveryIp() {
- return registration.getInstanceConfig().getIpAddress();
+ return registration.getHost();
}
@Override
@@ -81,10 +67,10 @@ private boolean isIp(String ipAddress) {
private List getServices(String key){
List urls = new ArrayList<>();
- List instanceInfos =getConfigServiceInstances(key);
- for (InstanceInfo instanceInfo : instanceInfos) {
- String url = instanceInfo.getHomePageUrl();
- String address = instanceInfo.getIPAddr();
+ List serviceInstances = discoveryClient.getInstances(key);
+ for (ServiceInstance instanceInfo : serviceInstances) {
+ String url = instanceInfo.getUri().toString();
+ String address = instanceInfo.getHost();
if (isIp(address)) {
urls.add(url);
}else{
diff --git a/sds-socket/pom.xml b/sds-socket/pom.xml
index 8f32d91..3cb651c 100644
--- a/sds-socket/pom.xml
+++ b/sds-socket/pom.xml
@@ -10,6 +10,13 @@
sds socket framework
https://github.com/1991wangliang/sds
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 1.5.10.RELEASE
+
+
+
The Apache License, Version 2.0
@@ -55,7 +62,8 @@
1.7
3.6.0
- 1.3.1.RELEASE
+ Edgware.SR3
+
4.3.7.RELEASE
@@ -76,46 +84,33 @@
-
- org.springframework
- spring-web
- ${org.springframework-version}
-
-
-
-
- javax.servlet
- javax.servlet-api
- 3.1.0
-
-
-
org.springframework.cloud
- spring-cloud-starter-eureka
- ${spring-cloud.version}
+ spring-cloud-starter-consul-discovery
org.springframework.cloud
spring-cloud-starter-feign
- ${spring-cloud.version}
+
+
+
+ org.springframework.cloud
+ spring-cloud-dependencies
+ ${spring-cloud.version}
+ pom
+ import
+
+
+
-
- org.apache.maven.plugins
- maven-compiler-plugin
-
- 1.7
- 1.7
-
-
org.apache.maven.plugins
maven-compiler-plugin
diff --git a/sds-socket/src/main/java/com/lorne/sds/server/ServerConfiguration.java b/sds-socket/src/main/java/com/lorne/sds/server/ServerConfiguration.java
index b3124bb..63a6ce5 100644
--- a/sds-socket/src/main/java/com/lorne/sds/server/ServerConfiguration.java
+++ b/sds-socket/src/main/java/com/lorne/sds/server/ServerConfiguration.java
@@ -1,13 +1,13 @@
package com.lorne.sds.server;
-import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration
@ComponentScan
-@EnableEurekaClient
+@EnableDiscoveryClient
@EnableFeignClients
public class ServerConfiguration {
diff --git a/sds-socket/src/main/java/com/lorne/sds/server/service/impl/SocketControlImpl.java b/sds-socket/src/main/java/com/lorne/sds/server/service/impl/SocketControlImpl.java
index cfdb964..832bef1 100644
--- a/sds-socket/src/main/java/com/lorne/sds/server/service/impl/SocketControlImpl.java
+++ b/sds-socket/src/main/java/com/lorne/sds/server/service/impl/SocketControlImpl.java
@@ -9,7 +9,7 @@
import io.netty.util.Attribute;
import io.netty.util.AttributeKey;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.cloud.netflix.eureka.serviceregistry.EurekaRegistration;
+import org.springframework.cloud.client.serviceregistry.Registration;
import org.springframework.stereotype.Service;
import java.util.concurrent.TimeUnit;
@@ -20,22 +20,22 @@
@Service
public class SocketControlImpl implements SocketControl {
-
private AttributeKey attributeKey = AttributeKey.valueOf(SocketControlImpl.class.getName());
- @Autowired
- private EurekaRegistration registration;
@Autowired
private DeliveryClient deliveryClient;
+ @Autowired
+ private Registration registration;
+
private String ipPort = null;
@Override
public String getIpPort() {
if(ipPort==null) {
- String ipAddress = registration.getInstanceConfig().getIpAddress();
- int port = registration.getNonSecurePort();
+ String ipAddress = registration.getHost();
+ int port = registration.getPort();
ipPort = String.format("%s:%d", ipAddress, port);
}
return ipPort;
@@ -48,7 +48,7 @@ public String getServiceId() {
@Override
public String getInstanceId() {
- return registration.getInstanceConfig().getInstanceId();
+ return registration.getServiceId();
}
@Override