You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by wu...@apache.org on 2018/01/09 06:54:23 UTC
[incubator-servicecomb-java-chassis] 06/06: fix DiscoveryTree is
serviceId level, can not share across services.
This is an automated email from the ASF dual-hosted git repository.
wujimin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-java-chassis.git
commit 36cd7d605e366cb263f3bb4d6fea0fbede08f1cc
Author: bao.liu <ba...@huawei.com>
AuthorDate: Tue Jan 9 09:33:50 2018 +0800
fix DiscoveryTree is serviceId level, can not share across services.
---
.../springboot/starter/discovery/CseDiscoveryClient.java | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/spring-boot-starter/spring-boot-starter-discovery/src/main/java/io/servicecomb/springboot/starter/discovery/CseDiscoveryClient.java b/spring-boot-starter/spring-boot-starter-discovery/src/main/java/io/servicecomb/springboot/starter/discovery/CseDiscoveryClient.java
index 0af0274..28b68f3 100644
--- a/spring-boot-starter/spring-boot-starter-discovery/src/main/java/io/servicecomb/springboot/starter/discovery/CseDiscoveryClient.java
+++ b/spring-boot-starter/spring-boot-starter-discovery/src/main/java/io/servicecomb/springboot/starter/discovery/CseDiscoveryClient.java
@@ -19,6 +19,7 @@ package io.servicecomb.springboot.starter.discovery;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
import org.springframework.cloud.client.DefaultServiceInstance;
import org.springframework.cloud.client.ServiceInstance;
@@ -35,7 +36,7 @@ import io.servicecomb.serviceregistry.discovery.DiscoveryContext;
import io.servicecomb.serviceregistry.discovery.DiscoveryTree;
public class CseDiscoveryClient implements DiscoveryClient {
- private DiscoveryTree discoveryTree = new DiscoveryTree();
+ private Map<String, DiscoveryTree> discoveryTrees = new ConcurrentHashMap<>();
@Override
public String description() {
@@ -46,6 +47,9 @@ public class CseDiscoveryClient implements DiscoveryClient {
public List<ServiceInstance> getInstances(final String serviceId) {
DiscoveryContext context = new DiscoveryContext();
context.setInputParameters(serviceId);
+ DiscoveryTree discoveryTree = discoveryTrees.computeIfAbsent(serviceId, key -> {
+ return new DiscoveryTree();
+ });
VersionedCache serversVersionedCache = discoveryTree.discovery(context,
RegistryUtils.getAppId(),
serviceId,
--
To stop receiving notification emails like this one, please contact
"commits@servicecomb.apache.org" <co...@servicecomb.apache.org>.