You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2020/02/27 16:04:09 UTC

[GitHub] [servicecomb-java-chassis] yhs0092 opened a new pull request #1600: [SCB-1691] Refactor registry module

yhs0092 opened a new pull request #1600: [SCB-1691] Refactor registry module
URL: https://github.com/apache/servicecomb-java-chassis/pull/1600
 
 
   main features:
   
   - one microservice instance can hold multiple `ServiceRegistry` instances, which are managed in `RegistryUtils`, so that one instance can connect to multiple service center clusters
   - when microservice instance is shutdown, the corresponding instance record in service center is switched to `DOWN` status and the shutdown precedure is blocked for a while, so that consumer can get enough time to get notified that this instance is stopping. The block period length is determined by the config item `servicecomb.boot.turnDown.waitInSeconds`
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] coveralls edited a comment on issue #1600: [SCB-1691] Refactor registry module

Posted by GitBox <gi...@apache.org>.
coveralls edited a comment on issue #1600: [SCB-1691] Refactor registry module
URL: https://github.com/apache/servicecomb-java-chassis/pull/1600#issuecomment-592710295
 
 
   
   [![Coverage Status](https://coveralls.io/builds/29036210/badge)](https://coveralls.io/builds/29036210)
   
   Coverage decreased (-0.05%) to 84.859% when pulling **4a925f798e67f45b4898558fc989eb83c291a9c7 on yhs0092:refactor-registry-module** into **908e20fdd30694d481b372fa178d3db7e39454bf on apache:master**.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] yhs0092 commented on a change in pull request #1600: [SCB-1691] Refactor registry module

Posted by GitBox <gi...@apache.org>.
yhs0092 commented on a change in pull request #1600: [SCB-1691] Refactor registry module
URL: https://github.com/apache/servicecomb-java-chassis/pull/1600#discussion_r389461813
 
 

 ##########
 File path: service-registry/src/main/java/org/apache/servicecomb/serviceregistry/RegistryUtils.java
 ##########
 @@ -20,62 +20,120 @@
 import java.net.InetSocketAddress;
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.function.Consumer;
+import java.util.function.Function;
+import java.util.regex.Matcher;
 
 import org.apache.http.client.utils.URIBuilder;
 import org.apache.servicecomb.config.ConfigUtil;
 import org.apache.servicecomb.config.archaius.sources.MicroserviceConfigLoader;
+import org.apache.servicecomb.foundation.common.Holder;
 import org.apache.servicecomb.foundation.common.event.EventManager;
 import org.apache.servicecomb.foundation.common.net.IpPort;
 import org.apache.servicecomb.foundation.common.net.NetUtils;
 import org.apache.servicecomb.serviceregistry.api.registry.Microservice;
 import org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance;
+import org.apache.servicecomb.serviceregistry.api.response.FindInstancesResponse;
 import org.apache.servicecomb.serviceregistry.cache.InstanceCacheManager;
+import org.apache.servicecomb.serviceregistry.cache.InstanceCacheManagerNew;
 import org.apache.servicecomb.serviceregistry.client.ServiceRegistryClient;
 import org.apache.servicecomb.serviceregistry.client.http.MicroserviceInstances;
 import org.apache.servicecomb.serviceregistry.config.ServiceRegistryConfig;
+import org.apache.servicecomb.serviceregistry.consumer.AppManager;
 import org.apache.servicecomb.serviceregistry.definition.MicroserviceDefinition;
 import org.apache.servicecomb.serviceregistry.registry.ServiceRegistryFactory;
+import org.apache.servicecomb.serviceregistry.registry.cache.AggregateServiceRegistryCache;
+import org.apache.servicecomb.serviceregistry.registry.cache.MicroserviceCache;
+import org.apache.servicecomb.serviceregistry.registry.cache.MicroserviceCache.MicroserviceCacheStatus;
+import org.apache.servicecomb.serviceregistry.registry.cache.MicroserviceCacheKey;
+import org.apache.servicecomb.serviceregistry.swagger.SwaggerLoader;
+import org.apache.servicecomb.serviceregistry.task.MicroserviceInstanceRegisterTask;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.util.StringUtils;
 
 import com.google.common.base.Charsets;
+import com.google.common.eventbus.Subscribe;
 import com.google.common.hash.Hashing;
 import com.netflix.config.DynamicPropertyFactory;
 
 public final class RegistryUtils {
   private static final Logger LOGGER = LoggerFactory.getLogger(RegistryUtils.class);
 
-  private static ServiceRegistry serviceRegistry;
+  /**
+   * The default ServiceRegistry instance
+   */
+  private static volatile ServiceRegistry serviceRegistry;
 
   // value is ip or {interface name}
   public static final String PUBLISH_ADDRESS = "servicecomb.service.publishAddress";
 
   private static final String PUBLISH_PORT = "servicecomb.{transport_name}.publishPort";
 
+  private static SwaggerLoader swaggerLoader = new SwaggerLoader();
+
+  private static AppManager appManager = new AppManager();
+
+  private static InstanceCacheManager instanceCacheManager = new InstanceCacheManagerNew(appManager);
+
+  private static final Map<String, ServiceRegistryConfig> EXTRA_SERVICE_REGISTRY_CONFIGS = new LinkedHashMap<>();
+
+  private static final Map<String, ServiceRegistry> EXTRA_SERVICE_REGISTRIES = new LinkedHashMap<>();
+
+  static AggregateServiceRegistryCache aggregateServiceRegistryCache;
 
 Review comment:
   Done, pls review it

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] coveralls commented on issue #1600: [SCB-1691] Refactor registry module

Posted by GitBox <gi...@apache.org>.
coveralls commented on issue #1600: [SCB-1691] Refactor registry module
URL: https://github.com/apache/servicecomb-java-chassis/pull/1600#issuecomment-592710295
 
 
   
   [![Coverage Status](https://coveralls.io/builds/29035363/badge)](https://coveralls.io/builds/29035363)
   
   Coverage decreased (-0.06%) to 84.854% when pulling **4a925f798e67f45b4898558fc989eb83c291a9c7 on yhs0092:refactor-registry-module** into **908e20fdd30694d481b372fa178d3db7e39454bf on apache:master**.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] GuoYL123 commented on a change in pull request #1600: [SCB-1691] Refactor registry module

Posted by GitBox <gi...@apache.org>.
GuoYL123 commented on a change in pull request #1600: [SCB-1691] Refactor registry module
URL: https://github.com/apache/servicecomb-java-chassis/pull/1600#discussion_r386245489
 
 

 ##########
 File path: service-registry/src/main/java/org/apache/servicecomb/serviceregistry/RegistryUtils.java
 ##########
 @@ -20,62 +20,120 @@
 import java.net.InetSocketAddress;
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.function.Consumer;
+import java.util.function.Function;
+import java.util.regex.Matcher;
 
 import org.apache.http.client.utils.URIBuilder;
 import org.apache.servicecomb.config.ConfigUtil;
 import org.apache.servicecomb.config.archaius.sources.MicroserviceConfigLoader;
+import org.apache.servicecomb.foundation.common.Holder;
 import org.apache.servicecomb.foundation.common.event.EventManager;
 import org.apache.servicecomb.foundation.common.net.IpPort;
 import org.apache.servicecomb.foundation.common.net.NetUtils;
 import org.apache.servicecomb.serviceregistry.api.registry.Microservice;
 import org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance;
+import org.apache.servicecomb.serviceregistry.api.response.FindInstancesResponse;
 import org.apache.servicecomb.serviceregistry.cache.InstanceCacheManager;
+import org.apache.servicecomb.serviceregistry.cache.InstanceCacheManagerNew;
 import org.apache.servicecomb.serviceregistry.client.ServiceRegistryClient;
 import org.apache.servicecomb.serviceregistry.client.http.MicroserviceInstances;
 import org.apache.servicecomb.serviceregistry.config.ServiceRegistryConfig;
+import org.apache.servicecomb.serviceregistry.consumer.AppManager;
 import org.apache.servicecomb.serviceregistry.definition.MicroserviceDefinition;
 import org.apache.servicecomb.serviceregistry.registry.ServiceRegistryFactory;
+import org.apache.servicecomb.serviceregistry.registry.cache.AggregateServiceRegistryCache;
+import org.apache.servicecomb.serviceregistry.registry.cache.MicroserviceCache;
+import org.apache.servicecomb.serviceregistry.registry.cache.MicroserviceCache.MicroserviceCacheStatus;
+import org.apache.servicecomb.serviceregistry.registry.cache.MicroserviceCacheKey;
+import org.apache.servicecomb.serviceregistry.swagger.SwaggerLoader;
+import org.apache.servicecomb.serviceregistry.task.MicroserviceInstanceRegisterTask;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.util.StringUtils;
 
 import com.google.common.base.Charsets;
+import com.google.common.eventbus.Subscribe;
 import com.google.common.hash.Hashing;
 import com.netflix.config.DynamicPropertyFactory;
 
 public final class RegistryUtils {
   private static final Logger LOGGER = LoggerFactory.getLogger(RegistryUtils.class);
 
-  private static ServiceRegistry serviceRegistry;
+  /**
+   * The default ServiceRegistry instance
+   */
+  private static volatile ServiceRegistry serviceRegistry;
 
   // value is ip or {interface name}
   public static final String PUBLISH_ADDRESS = "servicecomb.service.publishAddress";
 
   private static final String PUBLISH_PORT = "servicecomb.{transport_name}.publishPort";
 
+  private static SwaggerLoader swaggerLoader = new SwaggerLoader();
+
+  private static AppManager appManager = new AppManager();
+
+  private static InstanceCacheManager instanceCacheManager = new InstanceCacheManagerNew(appManager);
+
+  private static final Map<String, ServiceRegistryConfig> EXTRA_SERVICE_REGISTRY_CONFIGS = new LinkedHashMap<>();
+
+  private static final Map<String, ServiceRegistry> EXTRA_SERVICE_REGISTRIES = new LinkedHashMap<>();
+
+  static AggregateServiceRegistryCache aggregateServiceRegistryCache;
 
 Review comment:
    should be private?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] yhs0092 closed pull request #1600: [SCB-1691] Refactor registry module

Posted by GitBox <gi...@apache.org>.
yhs0092 closed pull request #1600: [SCB-1691] Refactor registry module
URL: https://github.com/apache/servicecomb-java-chassis/pull/1600
 
 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] coveralls edited a comment on issue #1600: [SCB-1691] Refactor registry module

Posted by GitBox <gi...@apache.org>.
coveralls edited a comment on issue #1600: [SCB-1691] Refactor registry module
URL: https://github.com/apache/servicecomb-java-chassis/pull/1600#issuecomment-592710295
 
 
   
   [![Coverage Status](https://coveralls.io/builds/29212079/badge)](https://coveralls.io/builds/29212079)
   
   Coverage decreased (-0.06%) to 84.853% when pulling **bcfe0714968a911d6ffe127b4bf53ae0cbd17271 on yhs0092:refactor-registry-module** into **908e20fdd30694d481b372fa178d3db7e39454bf on apache:master**.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] yhs0092 opened a new pull request #1600: [SCB-1691] Refactor registry module

Posted by GitBox <gi...@apache.org>.
yhs0092 opened a new pull request #1600: [SCB-1691] Refactor registry module
URL: https://github.com/apache/servicecomb-java-chassis/pull/1600
 
 
   main features:
   
   - one microservice instance can hold multiple `ServiceRegistry` instances, which are managed in `RegistryUtils`, so that one instance can connect to multiple service center clusters
   - when microservice instance is shutdown, the corresponding instance record in service center is switched to `DOWN` status and the shutdown precedure is blocked for a while, so that consumer can get enough time to get notified that this instance is stopping. The block period length is determined by the config item `servicecomb.boot.turnDown.waitInSeconds`
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] yhs0092 merged pull request #1600: [SCB-1691] Refactor registry module

Posted by GitBox <gi...@apache.org>.
yhs0092 merged pull request #1600: [SCB-1691] Refactor registry module
URL: https://github.com/apache/servicecomb-java-chassis/pull/1600
 
 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services