Commit 541947ec by Nepxion

重构类结构

parent f224878d
...@@ -32,6 +32,7 @@ import org.springframework.web.bind.annotation.RequestMethod; ...@@ -32,6 +32,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import com.nepxion.discovery.common.constant.DiscoveryConstant;
import com.nepxion.discovery.common.entity.InstanceEntity; import com.nepxion.discovery.common.entity.InstanceEntity;
import com.nepxion.discovery.console.remote.ConfigAdapter; import com.nepxion.discovery.console.remote.ConfigAdapter;
import com.nepxion.discovery.console.rest.ConfigClearRestInvoker; import com.nepxion.discovery.console.rest.ConfigClearRestInvoker;
...@@ -138,11 +139,11 @@ public class ConsoleEndpoint { ...@@ -138,11 +139,11 @@ public class ConsoleEndpoint {
List<ServiceInstance> serviceInstances = getInstances(service); List<ServiceInstance> serviceInstances = getInstances(service);
List<InstanceEntity> instanceEntityList = new ArrayList<InstanceEntity>(serviceInstances.size()); List<InstanceEntity> instanceEntityList = new ArrayList<InstanceEntity>(serviceInstances.size());
for (ServiceInstance serviceInstance : serviceInstances) { for (ServiceInstance serviceInstance : serviceInstances) {
Map<String, String> metadata = serviceInstance.getMetadata();
String serviceId = serviceInstance.getServiceId().toLowerCase(); String serviceId = serviceInstance.getServiceId().toLowerCase();
String version = serviceInstance.getMetadata().get("version"); String version = metadata.get(DiscoveryConstant.VERSION);
String host = serviceInstance.getHost(); String host = serviceInstance.getHost();
int port = serviceInstance.getPort(); int port = serviceInstance.getPort();
Map<String, String> metadata = serviceInstance.getMetadata();
InstanceEntity instanceEntity = new InstanceEntity(); InstanceEntity instanceEntity = new InstanceEntity();
instanceEntity.setServiceId(serviceId); instanceEntity.setServiceId(serviceId);
......
...@@ -123,8 +123,9 @@ public class RouterEndpoint { ...@@ -123,8 +123,9 @@ public class RouterEndpoint {
List<RouterEntity> routerEntityList = new ArrayList<RouterEntity>(); List<RouterEntity> routerEntityList = new ArrayList<RouterEntity>();
for (ServiceInstance instance : instanceList) { for (ServiceInstance instance : instanceList) {
Map<String, String> metadata = instance.getMetadata();
String serviceId = instance.getServiceId().toLowerCase(); String serviceId = instance.getServiceId().toLowerCase();
String version = instance.getMetadata().get(DiscoveryConstant.VERSION); String version = metadata.get(DiscoveryConstant.VERSION);
String host = instance.getHost(); String host = instance.getHost();
int port = instance.getPort(); int port = instance.getPort();
...@@ -157,8 +158,9 @@ public class RouterEndpoint { ...@@ -157,8 +158,9 @@ public class RouterEndpoint {
List<RouterEntity> routerEntityList = new ArrayList<RouterEntity>(); List<RouterEntity> routerEntityList = new ArrayList<RouterEntity>();
for (Map<String, ?> instance : instanceList) { for (Map<String, ?> instance : instanceList) {
Map<String, String> metadata = (Map<String, String>) instance.get(DiscoveryConstant.METADATA);
String serviceId = instance.get(DiscoveryConstant.SERVICE_ID).toString().toLowerCase(); String serviceId = instance.get(DiscoveryConstant.SERVICE_ID).toString().toLowerCase();
String version = ((Map<String, String>) instance.get(DiscoveryConstant.METADATA)).get(DiscoveryConstant.VERSION); String version = metadata.get(DiscoveryConstant.VERSION);
String host = instance.get(DiscoveryConstant.HOST).toString(); String host = instance.get(DiscoveryConstant.HOST).toString();
Integer port = (Integer) instance.get(DiscoveryConstant.PORT); Integer port = (Integer) instance.get(DiscoveryConstant.PORT);
......
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