This is an automated email from the ASF dual-hosted git repository.

liubao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-java-chassis.git


The following commit(s) were added to refs/heads/master by this push:
     new f44cd26  [SCB-1916]create a submodule for local registry
f44cd26 is described below

commit f44cd267ba0ecbe975dcac26488d354f57e0fa68
Author: liubao <[email protected]>
AuthorDate: Mon May 18 17:04:16 2020 +0800

    [SCB-1916]create a submodule for local registry
---
 demo/demo-crossapp/pom.xml                         |   4 +
 demo/demo-jaxrs/pom.xml                            |   4 +
 .../servicecomb/demo/registry/Application.java     |   3 -
 .../demo-local-registry-server/pom.xml             |   4 -
 .../demo/registry/ServerApplication.java           |   2 -
 demo/demo-local-registry/pom.xml                   |   4 +
 demo/demo-multiple/pom.xml                         |   8 +-
 demo/demo-pojo/pom.xml                             |   4 +
 demo/demo-register-url-prefix/pom.xml              |   4 +
 demo/demo-schema/pom.xml                           |   4 -
 demo/demo-signature/pom.xml                        |   4 +
 demo/demo-springmvc/pom.xml                        |   4 +
 demo/perf/pom.xml                                  |   4 +
 dependencies/bom/pom.xml                           |  10 ++
 distribution/pom.xml                               |  11 ++
 .../foundation/common/utils/SPIEnabled.java        |  17 +--
 .../servicecomb/serviceregistry/Discovery.java     |   3 +-
 .../serviceregistry/DiscoveryManager.java          |   6 +-
 .../servicecomb/serviceregistry/Registration.java  |   3 +-
 .../serviceregistry/RegistrationManager.java       |  18 ++-
 .../api/registry/MicroserviceFactory.java          |   0
 .../config/MicroservicePropertiesLoader.java       |   0
 ...rviceregistry.consumer.MicroserviceInstancePing |   0
 service-registry/pom.xml                           |   1 +
 .../registry-local}/pom.xml                        |  61 +++++----
 .../servicecomb/localregistry/LocalDiscovery.java} |  43 +++---
 .../localregistry/LocalDiscoveryStore.java         | 148 +++++++++++++++++++++
 .../localregistry/LocalRegistration.java}          |  59 ++++----
 .../localregistry/LocalRegistrationStore.java      |  58 ++++++++
 ...g.apache.servicecomb.serviceregistry.Discovery} |   2 +-
 ...pache.servicecomb.serviceregistry.Registration} |   2 +-
 .../serviceregistry/ServiceCenterDiscovery.java    |  13 +-
 .../serviceregistry/ServiceCenterRegistration.java |  12 +-
 33 files changed, 405 insertions(+), 115 deletions(-)

diff --git a/demo/demo-crossapp/pom.xml b/demo/demo-crossapp/pom.xml
index 635cf5d..0b4c9e8 100644
--- a/demo/demo-crossapp/pom.xml
+++ b/demo/demo-crossapp/pom.xml
@@ -35,6 +35,10 @@
 
   <dependencies>
     <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>registry-service-center</artifactId>
+    </dependency>
+    <dependency>
       <groupId>log4j</groupId>
       <artifactId>log4j</artifactId>
     </dependency>
diff --git a/demo/demo-jaxrs/pom.xml b/demo/demo-jaxrs/pom.xml
index b38ccc4..b1787b1 100644
--- a/demo/demo-jaxrs/pom.xml
+++ b/demo/demo-jaxrs/pom.xml
@@ -33,6 +33,10 @@
   </modules>
   <dependencies>
     <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>registry-service-center</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.apache.logging.log4j</groupId>
       <artifactId>log4j-slf4j-impl</artifactId>
     </dependency>
diff --git 
a/demo/demo-local-registry/demo-local-registry-client/src/main/java/org/apache/servicecomb/demo/registry/Application.java
 
b/demo/demo-local-registry/demo-local-registry-client/src/main/java/org/apache/servicecomb/demo/registry/Application.java
index a638e0f..82a7de6 100644
--- 
a/demo/demo-local-registry/demo-local-registry-client/src/main/java/org/apache/servicecomb/demo/registry/Application.java
+++ 
b/demo/demo-local-registry/demo-local-registry-client/src/main/java/org/apache/servicecomb/demo/registry/Application.java
@@ -19,7 +19,6 @@ package org.apache.servicecomb.demo.registry;
 
 import org.apache.servicecomb.demo.TestMgr;
 import org.apache.servicecomb.provider.springmvc.reference.RestTemplateBuilder;
-import 
org.apache.servicecomb.serviceregistry.client.LocalServiceRegistryClientImpl;
 import org.apache.servicecomb.springboot2.starter.EnableServiceComb;
 import org.springframework.boot.WebApplicationType;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -30,8 +29,6 @@ import org.springframework.web.client.RestTemplate;
 @EnableServiceComb
 public class Application {
   public static void main(final String[] args) throws Exception {
-    System.setProperty(LocalServiceRegistryClientImpl.LOCAL_REGISTRY_FILE_KEY, 
"registry.yaml");
-
     new 
SpringApplicationBuilder().sources(Application.class).web(WebApplicationType.SERVLET).build().run(args);
 
     runTest();
diff --git a/demo/demo-local-registry/demo-local-registry-server/pom.xml 
b/demo/demo-local-registry/demo-local-registry-server/pom.xml
index dc3dee2..4c0a930 100644
--- a/demo/demo-local-registry/demo-local-registry-server/pom.xml
+++ b/demo/demo-local-registry/demo-local-registry-server/pom.xml
@@ -33,10 +33,6 @@
   </properties>
   <dependencies>
     <dependency>
-      <groupId>org.apache.servicecomb</groupId>
-      <artifactId>registry-service-center</artifactId>
-    </dependency>
-    <dependency>
       <groupId>org.springframework.cloud</groupId>
       <artifactId>spring-cloud-commons</artifactId>
     </dependency>
diff --git 
a/demo/demo-local-registry/demo-local-registry-server/src/main/java/org/apache/servicecomb/demo/registry/ServerApplication.java
 
b/demo/demo-local-registry/demo-local-registry-server/src/main/java/org/apache/servicecomb/demo/registry/ServerApplication.java
index c2dd825..bedc30a 100644
--- 
a/demo/demo-local-registry/demo-local-registry-server/src/main/java/org/apache/servicecomb/demo/registry/ServerApplication.java
+++ 
b/demo/demo-local-registry/demo-local-registry-server/src/main/java/org/apache/servicecomb/demo/registry/ServerApplication.java
@@ -17,7 +17,6 @@
 
 package org.apache.servicecomb.demo.registry;
 
-import 
org.apache.servicecomb.serviceregistry.client.LocalServiceRegistryClientImpl;
 import org.apache.servicecomb.springboot2.starter.EnableServiceComb;
 import org.springframework.boot.WebApplicationType;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -27,7 +26,6 @@ import 
org.springframework.boot.builder.SpringApplicationBuilder;
 @EnableServiceComb
 public class ServerApplication {
   public static void main(final String[] args) throws Exception {
-    System.setProperty(LocalServiceRegistryClientImpl.LOCAL_REGISTRY_FILE_KEY, 
"registry.yaml");
     new 
SpringApplicationBuilder().sources(ServerApplication.class).web(WebApplicationType.SERVLET).build().run(args);
   }
 }
diff --git a/demo/demo-local-registry/pom.xml b/demo/demo-local-registry/pom.xml
index 8b373c0..9c6c739 100644
--- a/demo/demo-local-registry/pom.xml
+++ b/demo/demo-local-registry/pom.xml
@@ -39,6 +39,10 @@
     </dependency>
     <dependency>
       <groupId>org.apache.servicecomb</groupId>
+      <artifactId>registry-local</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
       <artifactId>foundation-test-scaffolding</artifactId>
       <scope>compile</scope>
     </dependency>
diff --git a/demo/demo-multiple/pom.xml b/demo/demo-multiple/pom.xml
index 9bb8a85..7696aca 100644
--- a/demo/demo-multiple/pom.xml
+++ b/demo/demo-multiple/pom.xml
@@ -58,15 +58,15 @@
         <artifactId>b-client</artifactId>
         <version>${project.version}</version>
       </dependency>
-      <dependency>
-        <groupId>org.apache.servicecomb</groupId>
-        <artifactId>registry-service-center</artifactId>
-      </dependency>
     </dependencies>
   </dependencyManagement>
 
   <dependencies>
     <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>registry-service-center</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.apache.servicecomb.demo</groupId>
       <artifactId>demo-schema</artifactId>
     </dependency>
diff --git a/demo/demo-pojo/pom.xml b/demo/demo-pojo/pom.xml
index ee469a1..666fe4d 100644
--- a/demo/demo-pojo/pom.xml
+++ b/demo/demo-pojo/pom.xml
@@ -34,6 +34,10 @@
   </modules>
   <dependencies>
     <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>registry-service-center</artifactId>
+    </dependency>
+    <dependency>
       <groupId>log4j</groupId>
       <artifactId>log4j</artifactId>
     </dependency>
diff --git a/demo/demo-register-url-prefix/pom.xml 
b/demo/demo-register-url-prefix/pom.xml
index 9569311..8fe74ff 100644
--- a/demo/demo-register-url-prefix/pom.xml
+++ b/demo/demo-register-url-prefix/pom.xml
@@ -35,6 +35,10 @@
   <dependencies>
     <dependency>
       <groupId>org.apache.servicecomb</groupId>
+      <artifactId>registry-service-center</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
       <artifactId>java-chassis-spring-boot-starter-servlet</artifactId>
     </dependency>
     <dependency>
diff --git a/demo/demo-schema/pom.xml b/demo/demo-schema/pom.xml
index 56e808f..7d8e9d6 100644
--- a/demo/demo-schema/pom.xml
+++ b/demo/demo-schema/pom.xml
@@ -70,10 +70,6 @@
       <groupId>org.apache.servicecomb</groupId>
       <artifactId>inspector</artifactId>
     </dependency>
-    <dependency>
-      <groupId>org.apache.servicecomb</groupId>
-      <artifactId>registry-service-center</artifactId>
-    </dependency>
   </dependencies>
   <build>
     <plugins>
diff --git a/demo/demo-signature/pom.xml b/demo/demo-signature/pom.xml
index b78d15b..0f38700 100644
--- a/demo/demo-signature/pom.xml
+++ b/demo/demo-signature/pom.xml
@@ -32,5 +32,9 @@
       <groupId>org.apache.servicecomb</groupId>
       <artifactId>common-rest</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>registry-service-center</artifactId>
+    </dependency>
   </dependencies>
 </project>
diff --git a/demo/demo-springmvc/pom.xml b/demo/demo-springmvc/pom.xml
index 8543cb4..d8792ca 100644
--- a/demo/demo-springmvc/pom.xml
+++ b/demo/demo-springmvc/pom.xml
@@ -33,6 +33,10 @@
   </modules>
   <dependencies>
     <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>registry-service-center</artifactId>
+    </dependency>
+    <dependency>
       <groupId>log4j</groupId>
       <artifactId>log4j</artifactId>
     </dependency>
diff --git a/demo/perf/pom.xml b/demo/perf/pom.xml
index 4b90a4a..323d5cc 100644
--- a/demo/perf/pom.xml
+++ b/demo/perf/pom.xml
@@ -30,6 +30,10 @@
   <dependencies>
     <dependency>
       <groupId>org.apache.servicecomb</groupId>
+      <artifactId>registry-service-center</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
       <artifactId>provider-pojo</artifactId>
     </dependency>
     <dependency>
diff --git a/dependencies/bom/pom.xml b/dependencies/bom/pom.xml
index faf9808..9780df5 100644
--- a/dependencies/bom/pom.xml
+++ b/dependencies/bom/pom.xml
@@ -247,9 +247,19 @@
       <!-- ServiceComb: service registry -->
       <dependency>
         <groupId>org.apache.servicecomb</groupId>
+        <artifactId>registry-local</artifactId>
+        <version>${project.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.servicecomb</groupId>
         <artifactId>registry-service-center</artifactId>
         <version>${project.version}</version>
       </dependency>
+      <dependency>
+        <groupId>org.apache.servicecomb</groupId>
+        <artifactId>registry-zero-config</artifactId>
+        <version>${project.version}</version>
+      </dependency>
       <!-- ServiceComb: solutions -->
       <dependency>
         <groupId>org.apache.servicecomb</groupId>
diff --git a/distribution/pom.xml b/distribution/pom.xml
index d0307e3..8720061 100644
--- a/distribution/pom.xml
+++ b/distribution/pom.xml
@@ -208,7 +208,18 @@
     <!-- service registry -->
     <dependency>
       <groupId>org.apache.servicecomb</groupId>
+      <artifactId>registry-local</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
       <artifactId>registry-service-center</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>registry-zero-config</artifactId>
+      <version>${project.version}</version>
     </dependency>
 
     <!-- solutions -->
diff --git 
a/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/config/MicroservicePropertiesLoader.java
 
b/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/utils/SPIEnabled.java
similarity index 61%
copy from 
service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/config/MicroservicePropertiesLoader.java
copy to 
foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/utils/SPIEnabled.java
index 0eef433..adab60a 100644
--- 
a/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/config/MicroservicePropertiesLoader.java
+++ 
b/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/utils/SPIEnabled.java
@@ -15,19 +15,8 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.serviceregistry.config;
+package org.apache.servicecomb.foundation.common.utils;
 
-import static 
org.apache.servicecomb.foundation.common.base.ServiceCombConstants.CONFIG_SERVICE_DESCRIPTION_KEY;
-
-public final class MicroservicePropertiesLoader extends 
AbstractPropertiesLoader {
-
-  public static final MicroservicePropertiesLoader INSTANCE = new 
MicroservicePropertiesLoader();
-
-  private MicroservicePropertiesLoader() {
-  }
-
-  @Override
-  protected String getConfigOptionPrefix() {
-    return CONFIG_SERVICE_DESCRIPTION_KEY;
-  }
+public interface SPIEnabled {
+  boolean enabled();
 }
diff --git 
a/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/Discovery.java
 
b/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/Discovery.java
index ed914b7..f94ef33 100644
--- 
a/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/Discovery.java
+++ 
b/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/Discovery.java
@@ -17,13 +17,14 @@
 
 package org.apache.servicecomb.serviceregistry;
 
+import org.apache.servicecomb.foundation.common.utils.SPIEnabled;
 import org.apache.servicecomb.foundation.common.utils.SPIOrder;
 import org.apache.servicecomb.serviceregistry.api.registry.Microservice;
 import 
org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance;
 import 
org.apache.servicecomb.serviceregistry.client.http.MicroserviceInstances;
 import org.apache.servicecomb.serviceregistry.consumer.MicroserviceVersions;
 
-public interface Discovery extends SPIOrder, LifeCycle {
+public interface Discovery extends SPIEnabled, SPIOrder, LifeCycle {
   // TODO: microservice id may be different in Discovery, maybe better to use 
appId, serviceName and version.
   Microservice getMicroservice(String microserviceId);
 
diff --git 
a/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/DiscoveryManager.java
 
b/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/DiscoveryManager.java
index b6804f6..474a9d9 100644
--- 
a/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/DiscoveryManager.java
+++ 
b/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/DiscoveryManager.java
@@ -18,6 +18,7 @@
 package org.apache.servicecomb.serviceregistry;
 
 import java.util.List;
+import java.util.stream.Collectors;
 
 import org.apache.servicecomb.config.ConfigUtil;
 import org.apache.servicecomb.config.archaius.sources.MicroserviceConfigLoader;
@@ -47,7 +48,10 @@ public class DiscoveryManager {
   private DiscoveryManager() {
     appManager = new AppManager();
     instanceCacheManager = new InstanceCacheManagerNew(appManager);
-    discoveryList = SPIServiceUtils.getOrLoadSortedService(Discovery.class);
+    discoveryList = SPIServiceUtils.getOrLoadSortedService(Discovery.class)
+        .stream()
+        .filter((discovery -> discovery.enabled()))
+        .collect(Collectors.toList());
 
     MicroserviceConfigLoader loader = ConfigUtil.getMicroserviceConfigLoader();
     microserviceDefinition = new 
MicroserviceDefinition(loader.getConfigModels());
diff --git 
a/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/Registration.java
 
b/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/Registration.java
index a860d8d..631ff01 100644
--- 
a/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/Registration.java
+++ 
b/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/Registration.java
@@ -19,13 +19,14 @@ package org.apache.servicecomb.serviceregistry;
 
 import java.util.Collection;
 
+import org.apache.servicecomb.foundation.common.utils.SPIEnabled;
 import org.apache.servicecomb.foundation.common.utils.SPIOrder;
 import org.apache.servicecomb.serviceregistry.api.registry.BasePath;
 import org.apache.servicecomb.serviceregistry.api.registry.Microservice;
 import 
org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance;
 import 
org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstanceStatus;
 
-public interface Registration extends SPIOrder, LifeCycle {
+public interface Registration extends SPIEnabled, SPIOrder, LifeCycle {
   String name();
 
   MicroserviceInstance getMicroserviceInstance();
diff --git 
a/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/RegistrationManager.java
 
b/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/RegistrationManager.java
index 3309568..dc50329 100644
--- 
a/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/RegistrationManager.java
+++ 
b/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/RegistrationManager.java
@@ -22,6 +22,7 @@ import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.Collection;
 import java.util.List;
+import java.util.stream.Collectors;
 
 import org.apache.http.client.utils.URIBuilder;
 import org.apache.servicecomb.foundation.common.net.IpPort;
@@ -47,12 +48,25 @@ public class RegistrationManager {
 
   public static RegistrationManager INSTANCE = new RegistrationManager();
 
-  private List<Registration> registrationList = 
SPIServiceUtils.getOrLoadSortedService(Registration.class);
+  private final List<Registration> registrationList;
 
-  private Registration primary = 
SPIServiceUtils.getPriorityHighestService(Registration.class);
+  private final Registration primary;
 
   private static SwaggerLoader swaggerLoader = new SwaggerLoader();
 
+  private RegistrationManager() {
+    registrationList = 
SPIServiceUtils.getOrLoadSortedService(Registration.class)
+        .stream()
+        .filter((registration -> registration.enabled()))
+        .collect(Collectors.toList());
+    if (registrationList.isEmpty()) {
+      LOGGER.warn("No registration is enabled. Fix this if only in unit 
tests.");
+      primary = null;
+    } else {
+      primary = registrationList.get(0);
+    }
+  }
+
   public MicroserviceInstance getMicroserviceInstance() {
     return primary.getMicroserviceInstance();
   }
diff --git 
a/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/api/registry/MicroserviceFactory.java
 
b/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/api/registry/MicroserviceFactory.java
similarity index 100%
rename from 
service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/api/registry/MicroserviceFactory.java
rename to 
foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/api/registry/MicroserviceFactory.java
diff --git 
a/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/config/MicroservicePropertiesLoader.java
 
b/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/config/MicroservicePropertiesLoader.java
similarity index 100%
rename from 
service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/config/MicroservicePropertiesLoader.java
rename to 
foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/config/MicroservicePropertiesLoader.java
diff --git 
a/service-registry/registry-service-center/src/main/resources/META-INF/services/org.apache.servicecomb.serviceregistry.consumer.MicroserviceInstancePing
 
b/foundations/foundation-registry/src/main/resources/META-INF/services/org.apache.servicecomb.serviceregistry.consumer.MicroserviceInstancePing
similarity index 100%
copy from 
service-registry/registry-service-center/src/main/resources/META-INF/services/org.apache.servicecomb.serviceregistry.consumer.MicroserviceInstancePing
copy to 
foundations/foundation-registry/src/main/resources/META-INF/services/org.apache.servicecomb.serviceregistry.consumer.MicroserviceInstancePing
diff --git a/service-registry/pom.xml b/service-registry/pom.xml
index b4752e2..488f81a 100644
--- a/service-registry/pom.xml
+++ b/service-registry/pom.xml
@@ -32,6 +32,7 @@
 
   <modules>
     <module>registry-service-center</module>
+    <module>registry-local</module>
     <module>registry-zero-config</module>
   </modules>
 </project>
diff --git a/demo/perf/pom.xml b/service-registry/registry-local/pom.xml
similarity index 62%
copy from demo/perf/pom.xml
copy to service-registry/registry-local/pom.xml
index 4b90a4a..e5a7a3b 100644
--- a/demo/perf/pom.xml
+++ b/service-registry/registry-local/pom.xml
@@ -18,62 +18,67 @@
 
 <project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
-  <modelVersion>4.0.0</modelVersion>
   <parent>
-    <groupId>org.apache.servicecomb.demo</groupId>
-    <artifactId>demo-parent</artifactId>
+    <groupId>org.apache.servicecomb</groupId>
+    <artifactId>service-registry-parent</artifactId>
     <version>2.1.0-SNAPSHOT</version>
   </parent>
-  <artifactId>perf</artifactId>
-  <name>Java Chassis::Demo::Perf</name>
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>registry-local</artifactId>
+  <name>Java Chassis::Registry Service Center</name>
 
   <dependencies>
     <dependency>
       <groupId>org.apache.servicecomb</groupId>
-      <artifactId>provider-pojo</artifactId>
+      <artifactId>deployment</artifactId>
     </dependency>
     <dependency>
       <groupId>org.apache.servicecomb</groupId>
-      <artifactId>provider-springmvc</artifactId>
+      <artifactId>foundation-vertx</artifactId>
     </dependency>
     <dependency>
       <groupId>org.apache.servicecomb</groupId>
-      <artifactId>transport-rest-vertx</artifactId>
+      <artifactId>foundation-config</artifactId>
     </dependency>
     <dependency>
       <groupId>org.apache.servicecomb</groupId>
-      <artifactId>transport-highway</artifactId>
+      <artifactId>foundation-common</artifactId>
     </dependency>
     <dependency>
       <groupId>org.apache.servicecomb</groupId>
-      <artifactId>inspector</artifactId>
+      <artifactId>swagger-generator-core</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>foundation-registry</artifactId>
     </dependency>
 
     <dependency>
-      <groupId>ch.qos.logback</groupId>
-      <artifactId>logback-classic</artifactId>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-lang3</artifactId>
     </dependency>
 
     <dependency>
       <groupId>io.vertx</groupId>
-      <artifactId>vertx-redis-client</artifactId>
-      <version>${vertx.version}</version>
+      <artifactId>vertx-codegen</artifactId>
+      <scope>provided</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-log4j12</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>log4j</groupId>
+      <artifactId>log4j</artifactId>
+      <scope>test</scope>
     </dependency>
     <dependency>
       <groupId>org.apache.servicecomb</groupId>
-      <artifactId>metrics-core</artifactId>
+      <artifactId>foundation-test-scaffolding</artifactId>
     </dependency>
   </dependencies>
-
-  <properties>
-    <demo.main>org.apache.servicecomb.demo.perf.PerfMain</demo.main>
-  </properties>
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-dependency-plugin</artifactId>
-      </plugin>
-    </plugins>
-  </build>
-</project>
\ No newline at end of file
+</project>
diff --git 
a/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/ServiceCenterDiscovery.java
 
b/service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalDiscovery.java
similarity index 64%
copy from 
service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/ServiceCenterDiscovery.java
copy to 
service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalDiscovery.java
index eef2a82..8c04c66 100644
--- 
a/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/ServiceCenterDiscovery.java
+++ 
b/service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalDiscovery.java
@@ -15,62 +15,63 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.serviceregistry;
+package org.apache.servicecomb.localregistry;
 
+import org.apache.servicecomb.serviceregistry.Discovery;
 import org.apache.servicecomb.serviceregistry.api.registry.Microservice;
 import 
org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance;
 import 
org.apache.servicecomb.serviceregistry.client.http.MicroserviceInstances;
-import org.apache.servicecomb.serviceregistry.definition.DefinitionConst;
 
-public class ServiceCenterDiscovery implements Discovery {
-  public static final String NAME = "service center discovery";
+import com.netflix.config.DynamicPropertyFactory;
+
+public class LocalDiscovery implements Discovery {
+  public static final String NAME = "local discovery";
+
+  public static final String ENABLED = 
"servicecomb.local.registry.discovery.enabled";
+
+  private LocalDiscoveryStore localDiscoveryStore;
 
   private String revision;
 
   @Override
   public void init() {
-    // ServiceCenterRegistration has already done it
+    localDiscoveryStore = new LocalDiscoveryStore();
+    localDiscoveryStore.init();
   }
 
   @Override
   public void run() {
-    // ServiceCenterRegistration has already done it
+    localDiscoveryStore.run();
   }
 
   @Override
   public void destroy() {
-    // ServiceCenterRegistration has already done it
+    localDiscoveryStore = null;
   }
 
   @Override
   public int getOrder() {
-    return 0;
+    return 100;
   }
 
   @Override
   public Microservice getMicroservice(String microserviceId) {
-    return RegistryUtils.getMicroservice(microserviceId);
+    return localDiscoveryStore.getMicroservice(microserviceId);
   }
 
   @Override
   public String getSchema(String microserviceId, String schemaId) {
-    ;
-    return RegistryUtils
-        .getAggregatedSchema(microserviceId, schemaId);
+    return localDiscoveryStore.getSchema(microserviceId, schemaId);
   }
 
   @Override
   public MicroserviceInstance findMicroserviceInstance(String serviceId, 
String instanceId) {
-    return RegistryUtils.getResultFromFirstValidServiceRegistry(
-        sr -> sr.getServiceRegistryClient().findServiceInstance(serviceId, 
instanceId));
+    return localDiscoveryStore.findMicroserviceInstance(serviceId, instanceId);
   }
 
   @Override
   public MicroserviceInstances findServiceInstances(String appId, String 
serviceName, String versionRule) {
-    return RegistryUtils.findServiceInstances(appId,
-        serviceName,
-        DefinitionConst.VERSION_RULE_ALL,
-        revision);
+    return localDiscoveryStore.findServiceInstances(appId, serviceName, 
versionRule);
   }
 
   @Override
@@ -87,4 +88,10 @@ public class ServiceCenterDiscovery implements Discovery {
   public String name() {
     return NAME;
   }
+
+  @Override
+  public boolean enabled() {
+    return DynamicPropertyFactory.getInstance()
+        .getBooleanProperty(ENABLED, true).get();
+  }
 }
diff --git 
a/service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalDiscoveryStore.java
 
b/service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalDiscoveryStore.java
new file mode 100644
index 0000000..fd25eee
--- /dev/null
+++ 
b/service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalDiscoveryStore.java
@@ -0,0 +1,148 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.servicecomb.localregistry;
+
+import static 
org.apache.servicecomb.serviceregistry.definition.DefinitionConst.DEFAULT_APPLICATION_ID;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.stream.Collectors;
+
+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.client.http.MicroserviceInstances;
+import org.yaml.snakeyaml.Yaml;
+
+public class LocalDiscoveryStore {
+  private static final String REGISTRY_FILE_NAME = "registry.yaml";
+
+  // key is microservice id
+  private Map<String, Microservice> microserviceMap = new 
ConcurrentHashMap<>();
+
+  // first key is microservice id
+  // second key is instance id
+  private Map<String, Map<String, MicroserviceInstance>> 
microserviceInstanceMap = new ConcurrentHashMap<>();
+
+  public LocalDiscoveryStore() {
+
+  }
+
+  public void init() {
+
+  }
+
+  public void run() {
+    InputStream is = 
this.getClass().getClassLoader().getResourceAsStream(REGISTRY_FILE_NAME);
+    if (is == null) {
+      return;
+    }
+    initFromData(is);
+  }
+
+  private void initFromData(InputStream is) {
+    Yaml yaml = new Yaml();
+    @SuppressWarnings("unchecked")
+    Map<String, Object> data = yaml.loadAs(is, Map.class);
+    initFromData(data);
+  }
+
+  private void initFromData(Map<String, Object> data) {
+    for (Entry<String, Object> entry : data.entrySet()) {
+      String name = entry.getKey();
+      @SuppressWarnings("unchecked")
+      List<Map<String, Object>> serviceConfigs = (List<Map<String, Object>>) 
entry.getValue();
+      for (Map<String, Object> serviceConfig : serviceConfigs) {
+        @SuppressWarnings("unchecked")
+        List<Map<String, Object>> instancesConfig =
+            (List<Map<String, Object>>) serviceConfig.get("instances");
+
+        String appId = (String) serviceConfig.get("appid");
+        String version = (String) serviceConfig.get("version");
+        String serviceId = (String) serviceConfig.get("id");
+        @SuppressWarnings("unchecked")
+        List<String> schemas = (List<String>) serviceConfig.get("schemaIds");
+
+        Microservice microservice = new Microservice();
+        microservice.setAppId(appId == null ? DEFAULT_APPLICATION_ID : appId);
+        microservice.setServiceName(name);
+        microservice.setVersion(version);
+        microservice.setServiceId(serviceId == null ? 
UUID.randomUUID().toString() : serviceId);
+        microserviceMap.put(microservice.getServiceId(), microservice);
+        if (schemas != null) {
+          microservice.setSchemas(schemas);
+        }
+
+        Map<String, MicroserviceInstance> instanceMap = new 
ConcurrentHashMap<>();
+        for (Map<String, Object> instanceConfig : instancesConfig) {
+          @SuppressWarnings("unchecked")
+          List<String> endpoints = (List<String>) 
instanceConfig.get("endpoints");
+
+          MicroserviceInstance instance = new MicroserviceInstance();
+          instance.setInstanceId(UUID.randomUUID().toString());
+          instance.setEndpoints(endpoints);
+          instance.setServiceId(microservice.getServiceId());
+
+          instanceMap.put(instance.getInstanceId(), instance);
+        }
+        microserviceInstanceMap.put(microservice.getServiceId(), instanceMap);
+      }
+    }
+  }
+
+  public Microservice getMicroservice(String microserviceId) {
+    return microserviceMap.get(microserviceId);
+  }
+
+  public String getSchema(String microserviceId, String schemaId) {
+    return microserviceMap.get(microserviceId).getSchemaMap().get(schemaId);
+  }
+
+  public MicroserviceInstance findMicroserviceInstance(String serviceId, 
String instanceId) {
+    return microserviceInstanceMap.get(serviceId).get(instanceId);
+  }
+
+  // local registry do not care about version and revision
+  public MicroserviceInstances findServiceInstances(String appId, String 
serviceName, String versionRule) {
+    MicroserviceInstances microserviceInstances = new MicroserviceInstances();
+    FindInstancesResponse findInstancesResponse = new FindInstancesResponse();
+    List<MicroserviceInstance> instances = new ArrayList<>();
+
+    Collectors.toList();
+    microserviceInstanceMap.values().forEach(
+        allInstances -> allInstances.values().stream().filter(
+            aInstance -> {
+              Microservice service = 
microserviceMap.get(aInstance.getServiceId());
+              return service.getAppId().equals(appId) && 
service.getServiceName().equals(serviceName);
+            }
+        ).forEach(item -> instances.add(item)));
+    if (instances.isEmpty()) {
+      microserviceInstances.setMicroserviceNotExist(true);
+    } else {
+      findInstancesResponse.setInstances(instances);
+      microserviceInstances.setMicroserviceNotExist(false);
+      microserviceInstances.setInstancesResponse(findInstancesResponse);
+    }
+    return microserviceInstances;
+  }
+}
diff --git 
a/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/ServiceCenterRegistration.java
 
b/service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalRegistration.java
similarity index 56%
copy from 
service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/ServiceCenterRegistration.java
copy to 
service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalRegistration.java
index b7f3318..1811b10 100644
--- 
a/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/ServiceCenterRegistration.java
+++ 
b/service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalRegistration.java
@@ -15,37 +15,47 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.serviceregistry;
+package org.apache.servicecomb.localregistry;
 
 import java.util.Collection;
 
-import 
org.apache.servicecomb.foundation.common.concurrency.SuppressedRunnableWrapper;
+import org.apache.servicecomb.foundation.common.event.EventManager;
+import org.apache.servicecomb.serviceregistry.Registration;
 import org.apache.servicecomb.serviceregistry.api.registry.BasePath;
 import org.apache.servicecomb.serviceregistry.api.registry.Microservice;
 import 
org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance;
 import 
org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstanceStatus;
+import 
org.apache.servicecomb.serviceregistry.event.MicroserviceInstanceRegisteredEvent;
 
-public class ServiceCenterRegistration implements Registration {
-  public static final String NAME = "service center registration";
+import com.netflix.config.DynamicPropertyFactory;
+
+public class LocalRegistration implements Registration {
+  public static final String NAME = "local registration";
+
+  public static final String ENABLED = 
"servicecomb.local.registry.registration.enabled";
+
+  private LocalRegistrationStore localRegistrationStore;
 
   @Override
   public void init() {
-    RegistryUtils.init();
+    localRegistrationStore = new LocalRegistrationStore();
+    localRegistrationStore.init();
   }
 
   @Override
   public void run() {
-    RegistryUtils.run();
+    localRegistrationStore.run();
+    EventManager.getEventBus().post(new MicroserviceInstanceRegisteredEvent());
   }
 
   @Override
   public void destroy() {
-    RegistryUtils.destroy();
+    localRegistrationStore = null;
   }
 
   @Override
   public int getOrder() {
-    return 0;
+    return 100;
   }
 
   @Override
@@ -55,50 +65,43 @@ public class ServiceCenterRegistration implements 
Registration {
 
   @Override
   public MicroserviceInstance getMicroserviceInstance() {
-    return RegistryUtils.getMicroserviceInstance();
+    return localRegistrationStore.getMicroserviceInstance();
   }
 
   @Override
   public Microservice getMicroservice() {
-    return RegistryUtils.getMicroservice();
+    return localRegistrationStore.getMicroservice();
   }
 
   @Override
   public String getAppId() {
-    return RegistryUtils.getAppId();
+    return localRegistrationStore.getMicroservice().getAppId();
   }
 
   @Override
   public boolean updateMicroserviceInstanceStatus(MicroserviceInstanceStatus 
status) {
-    RegistryUtils.executeOnEachServiceRegistry(sr -> new 
SuppressedRunnableWrapper(() -> {
-      MicroserviceInstance selfInstance = sr.getMicroserviceInstance();
-      sr.getServiceRegistryClient().updateMicroserviceInstanceStatus(
-          selfInstance.getServiceId(),
-          selfInstance.getInstanceId(),
-          MicroserviceInstanceStatus.DOWN);
-    }).run());
+    localRegistrationStore.getMicroserviceInstance().setStatus(status);
     return true;
   }
 
   @Override
   public void addSchema(String schemaId, String content) {
-    RegistryUtils.executeOnEachServiceRegistry(sr -> {
-      sr.getMicroservice().addSchema(schemaId, content);
-    });
+    localRegistrationStore.getMicroservice().addSchema(schemaId, content);
   }
 
   @Override
   public void addEndpoint(String endpoint) {
-    RegistryUtils.executeOnEachServiceRegistry(sr -> {
-      Microservice microservice = sr.getMicroservice();
-      microservice.getInstance().getEndpoints().add(endpoint);
-    });
+    
localRegistrationStore.getMicroserviceInstance().getEndpoints().add(endpoint);
   }
 
   @Override
   public void addBasePath(Collection<BasePath> basePaths) {
-    RegistryUtils.executeOnEachServiceRegistry(sr -> {
-      sr.getMicroservice().getPaths().addAll(basePaths);
-    });
+    localRegistrationStore.getMicroservice().getPaths().addAll(basePaths);
+  }
+
+  @Override
+  public boolean enabled() {
+    return DynamicPropertyFactory.getInstance()
+        .getBooleanProperty(ENABLED, true).get();
   }
 }
diff --git 
a/service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalRegistrationStore.java
 
b/service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalRegistrationStore.java
new file mode 100644
index 0000000..e9f3a05
--- /dev/null
+++ 
b/service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalRegistrationStore.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.servicecomb.localregistry;
+
+import org.apache.servicecomb.config.ConfigUtil;
+import org.apache.servicecomb.config.archaius.sources.MicroserviceConfigLoader;
+import org.apache.servicecomb.serviceregistry.api.registry.Microservice;
+import org.apache.servicecomb.serviceregistry.api.registry.MicroserviceFactory;
+import 
org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance;
+import 
org.apache.servicecomb.serviceregistry.definition.MicroserviceDefinition;
+
+public class LocalRegistrationStore {
+  private Microservice microservice;
+
+  private MicroserviceInstance microserviceInstance;
+
+  public LocalRegistrationStore() {
+
+  }
+
+  public void init() {
+    MicroserviceConfigLoader loader = ConfigUtil.getMicroserviceConfigLoader();
+    MicroserviceDefinition microserviceDefinition = new 
MicroserviceDefinition(loader.getConfigModels());
+    MicroserviceFactory microserviceFactory = new MicroserviceFactory();
+    microservice = microserviceFactory.create(microserviceDefinition);
+    microserviceInstance = microservice.getInstance();
+  }
+
+  public void run() {
+    microservice.setServiceId("[local]-[" + microservice.getAppId()
+        + "]-[" + microservice.getServiceName() + "]");
+    microserviceInstance.setInstanceId(microservice.getServiceId());
+    microserviceInstance.setServiceId(microservice.getServiceId());
+  }
+
+  public Microservice getMicroservice() {
+    return microservice;
+  }
+
+  public MicroserviceInstance getMicroserviceInstance() {
+    return microserviceInstance;
+  }
+}
diff --git 
a/service-registry/registry-service-center/src/main/resources/META-INF/services/org.apache.servicecomb.serviceregistry.consumer.MicroserviceInstancePing
 
b/service-registry/registry-local/src/main/resources/META-INF/services/org.apache.servicecomb.serviceregistry.Discovery
similarity index 90%
copy from 
service-registry/registry-service-center/src/main/resources/META-INF/services/org.apache.servicecomb.serviceregistry.consumer.MicroserviceInstancePing
copy to 
service-registry/registry-local/src/main/resources/META-INF/services/org.apache.servicecomb.serviceregistry.Discovery
index ce06621..194c3dc 100644
--- 
a/service-registry/registry-service-center/src/main/resources/META-INF/services/org.apache.servicecomb.serviceregistry.consumer.MicroserviceInstancePing
+++ 
b/service-registry/registry-local/src/main/resources/META-INF/services/org.apache.servicecomb.serviceregistry.Discovery
@@ -15,4 +15,4 @@
 # limitations under the License.
 #
 
-org.apache.servicecomb.serviceregistry.consumer.SimpleMicroserviceInstancePing
\ No newline at end of file
+org.apache.servicecomb.localregistry.LocalDiscovery
\ No newline at end of file
diff --git 
a/service-registry/registry-service-center/src/main/resources/META-INF/services/org.apache.servicecomb.serviceregistry.consumer.MicroserviceInstancePing
 
b/service-registry/registry-local/src/main/resources/META-INF/services/org.apache.servicecomb.serviceregistry.Registration
similarity index 90%
rename from 
service-registry/registry-service-center/src/main/resources/META-INF/services/org.apache.servicecomb.serviceregistry.consumer.MicroserviceInstancePing
rename to 
service-registry/registry-local/src/main/resources/META-INF/services/org.apache.servicecomb.serviceregistry.Registration
index ce06621..6eebc32 100644
--- 
a/service-registry/registry-service-center/src/main/resources/META-INF/services/org.apache.servicecomb.serviceregistry.consumer.MicroserviceInstancePing
+++ 
b/service-registry/registry-local/src/main/resources/META-INF/services/org.apache.servicecomb.serviceregistry.Registration
@@ -15,4 +15,4 @@
 # limitations under the License.
 #
 
-org.apache.servicecomb.serviceregistry.consumer.SimpleMicroserviceInstancePing
\ No newline at end of file
+org.apache.servicecomb.localregistry.LocalRegistration
\ No newline at end of file
diff --git 
a/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/ServiceCenterDiscovery.java
 
b/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/ServiceCenterDiscovery.java
index eef2a82..797673b 100644
--- 
a/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/ServiceCenterDiscovery.java
+++ 
b/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/ServiceCenterDiscovery.java
@@ -22,9 +22,13 @@ import 
org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance;
 import 
org.apache.servicecomb.serviceregistry.client.http.MicroserviceInstances;
 import org.apache.servicecomb.serviceregistry.definition.DefinitionConst;
 
+import com.netflix.config.DynamicPropertyFactory;
+
 public class ServiceCenterDiscovery implements Discovery {
   public static final String NAME = "service center discovery";
 
+  public static final String ENABLED = 
"servicecomb.service.registry.discovery.enabled";
+
   private String revision;
 
   @Override
@@ -54,7 +58,6 @@ public class ServiceCenterDiscovery implements Discovery {
 
   @Override
   public String getSchema(String microserviceId, String schemaId) {
-    ;
     return RegistryUtils
         .getAggregatedSchema(microserviceId, schemaId);
   }
@@ -69,7 +72,7 @@ public class ServiceCenterDiscovery implements Discovery {
   public MicroserviceInstances findServiceInstances(String appId, String 
serviceName, String versionRule) {
     return RegistryUtils.findServiceInstances(appId,
         serviceName,
-        DefinitionConst.VERSION_RULE_ALL,
+        versionRule,
         revision);
   }
 
@@ -87,4 +90,10 @@ public class ServiceCenterDiscovery implements Discovery {
   public String name() {
     return NAME;
   }
+
+  @Override
+  public boolean enabled() {
+    return DynamicPropertyFactory.getInstance()
+        .getBooleanProperty(ENABLED, true).get();
+  }
 }
diff --git 
a/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/ServiceCenterRegistration.java
 
b/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/ServiceCenterRegistration.java
index b7f3318..53de75c 100644
--- 
a/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/ServiceCenterRegistration.java
+++ 
b/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/ServiceCenterRegistration.java
@@ -25,9 +25,13 @@ import 
org.apache.servicecomb.serviceregistry.api.registry.Microservice;
 import 
org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance;
 import 
org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstanceStatus;
 
+import com.netflix.config.DynamicPropertyFactory;
+
 public class ServiceCenterRegistration implements Registration {
   public static final String NAME = "service center registration";
 
+  public static final String ENABLED = 
"servicecomb.service.registry.registration.enabled";
+
   @Override
   public void init() {
     RegistryUtils.init();
@@ -75,7 +79,7 @@ public class ServiceCenterRegistration implements 
Registration {
       sr.getServiceRegistryClient().updateMicroserviceInstanceStatus(
           selfInstance.getServiceId(),
           selfInstance.getInstanceId(),
-          MicroserviceInstanceStatus.DOWN);
+          status);
     }).run());
     return true;
   }
@@ -101,4 +105,10 @@ public class ServiceCenterRegistration implements 
Registration {
       sr.getMicroservice().getPaths().addAll(basePaths);
     });
   }
+
+  @Override
+  public boolean enabled() {
+    return DynamicPropertyFactory.getInstance()
+        .getBooleanProperty(ENABLED, true).get();
+  }
 }

Reply via email to