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

commit 2eac3a466822d29f272fe236337d18a987f0eb06
Author: liubao <[email protected]>
AuthorDate: Tue May 26 17:43:41 2020 +0800

    [SCB-1935]add a demo to show using local registry and service center 
together
---
 .../demo-multi-registries-client/pom.xml           |  78 ++++++++++++++++
 .../servicecomb/demo/registry/Application.java     |  67 ++++++++++++++
 .../demo/registry/IServiceCenterEndpoint.java      |  18 ++--
 .../demo/registry/ServiceCenterEndpoint.java       |  40 +++++++++
 .../src/main/resources/application.yml             |  34 +++++++
 .../src/main/resources/logback.xml                 |  50 +++++++++++
 .../ServiceCenterEndpoint.yaml                     |  59 ++++++++++++
 .../src/main/resources/registry.yaml               |  26 ++++++
 .../demo/registry/MultiRegistriesIT.java           |  23 +++--
 .../demo-multi-registries-server/pom.xml           | 100 +++++++++++++++++++++
 .../demo/registry/SelfServiceInvoker.java          |  27 ++++--
 .../demo/registry/ServerApplication.java           |  44 +++++++++
 .../servicecomb/demo/registry/ServerEndpoint.java  |  42 +++++++++
 .../src/main/resources/application.yml             |  32 +++++++
 .../src/main/resources/logback.xml                 |  50 +++++++++++
 demo/demo-multi-registries/pom.xml                 |  54 +++++++++++
 demo/pom.xml                                       |   1 +
 .../serviceregistry/DiscoveryManager.java          |   7 +-
 .../serviceregistry/RegistrationManager.java       |   1 +
 .../serviceregistry/{ => api}/Discovery.java       |  21 +++--
 .../serviceregistry/{ => api}/LifeCycle.java       |   2 +-
 .../serviceregistry/{ => api}/Registration.java    |   2 +-
 .../client/http/MicroserviceInstances.java         |  18 ++--
 .../servicecomb/localregistry/LocalDiscovery.java  |   4 +-
 .../localregistry/LocalRegistration.java           |   2 +-
 ...ache.servicecomb.serviceregistry.api.Discovery} |   0
 ...e.servicecomb.serviceregistry.api.Registration} |   0
 .../serviceregistry/ServiceCenterDiscovery.java    |   4 +-
 .../serviceregistry/ServiceCenterRegistration.java |   1 +
 .../client/http/ServiceRegistryClientImpl.java     |   1 +
 ...ache.servicecomb.serviceregistry.api.Discovery} |   0
 ...e.servicecomb.serviceregistry.api.Registration} |   0
 32 files changed, 772 insertions(+), 36 deletions(-)

diff --git a/demo/demo-multi-registries/demo-multi-registries-client/pom.xml 
b/demo/demo-multi-registries/demo-multi-registries-client/pom.xml
new file mode 100644
index 0000000..539ede0
--- /dev/null
+++ b/demo/demo-multi-registries/demo-multi-registries-client/pom.xml
@@ -0,0 +1,78 @@
+<?xml version="1.0"?>
+<!--
+  ~ 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.
+  -->
+
+<project
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";
+  xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>demo-multi-registries-client</artifactId>
+  <name>Java Chassis::Demo::Multi Registries client</name>
+  <parent>
+    <groupId>org.apache.servicecomb.demo</groupId>
+    <artifactId>demo-multi-registries</artifactId>
+    <version>2.1.0-SNAPSHOT</version>
+  </parent>
+
+  <properties>
+    <demo.main>org.apache.servicecomb.demo.registry.Application</demo.main>
+  </properties>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>java-chassis-spring-boot-starter-servlet</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb.demo</groupId>
+      <artifactId>demo-schema</artifactId>
+    </dependency>
+  </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>com.github.odavid.maven.plugins</groupId>
+        <artifactId>mixin-maven-plugin</artifactId>
+        <configuration>
+          <mixins>
+            <mixin>
+              <groupId>org.apache.servicecomb.demo</groupId>
+              <artifactId>docker-run-config</artifactId>
+              <version>${project.version}</version>
+            </mixin>
+          </mixins>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+  <profiles>
+    <profile>
+      <id>docker</id>
+      <properties>
+        <demo.service.name>demo-multi-registries-server</demo.service.name>
+      </properties>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>io.fabric8</groupId>
+            <artifactId>docker-maven-plugin</artifactId>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+  </profiles>
+</project>
diff --git 
a/demo/demo-multi-registries/demo-multi-registries-client/src/main/java/org/apache/servicecomb/demo/registry/Application.java
 
b/demo/demo-multi-registries/demo-multi-registries-client/src/main/java/org/apache/servicecomb/demo/registry/Application.java
new file mode 100644
index 0000000..2ef836c
--- /dev/null
+++ 
b/demo/demo-multi-registries/demo-multi-registries-client/src/main/java/org/apache/servicecomb/demo/registry/Application.java
@@ -0,0 +1,67 @@
+/*
+ * 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.demo.registry;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.servicecomb.demo.TestMgr;
+import org.apache.servicecomb.provider.pojo.RpcReference;
+import org.apache.servicecomb.provider.springmvc.reference.RestTemplateBuilder;
+import org.apache.servicecomb.springboot2.starter.EnableServiceComb;
+import org.springframework.boot.WebApplicationType;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+import org.springframework.stereotype.Component;
+import org.springframework.web.client.RestTemplate;
+
+@SpringBootApplication
+@EnableServiceComb
+@Component
+public class Application {
+  @RpcReference(microserviceName = "thirdParty-service-center", schemaId = 
"ServiceCenterEndpoint")
+  static IServiceCenterEndpoint serviceCenterEndpoint;
+
+  public static void main(final String[] args) throws Exception {
+    new 
SpringApplicationBuilder().sources(Application.class).web(WebApplicationType.SERVLET).build().run(args);
+
+    runTest();
+  }
+
+  public static void runTest() {
+    RestTemplate template = RestTemplateBuilder.create();
+
+    // invoke demo-multi-registries-server
+    TestMgr.check("2", template
+        
.getForObject("cse://demo-multi-registries-server/register/url/prefix/getName?name=2",
+            String.class));
+
+    // invoke service-center(3rd-parties)
+    @SuppressWarnings("unchecked")
+    Map<String, List<?>> result = (Map<String, List<?>>) 
serviceCenterEndpoint.getInstances("demo-multi-registries",
+        "demo-multi-registries-server",
+        "true",
+        "0.0.2",
+        "default");
+    TestMgr.check(result.get("instances").size(), 1);
+    TestMgr.summary();
+    if (!TestMgr.errors().isEmpty()) {
+      throw new IllegalStateException("tests failed");
+    }
+  }
+}
diff --git 
a/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/LifeCycle.java
 
b/demo/demo-multi-registries/demo-multi-registries-client/src/main/java/org/apache/servicecomb/demo/registry/IServiceCenterEndpoint.java
similarity index 54%
copy from 
foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/LifeCycle.java
copy to 
demo/demo-multi-registries/demo-multi-registries-client/src/main/java/org/apache/servicecomb/demo/registry/IServiceCenterEndpoint.java
index 2e0b4af..4287894 100644
--- 
a/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/LifeCycle.java
+++ 
b/demo/demo-multi-registries/demo-multi-registries-client/src/main/java/org/apache/servicecomb/demo/registry/IServiceCenterEndpoint.java
@@ -15,12 +15,18 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.serviceregistry;
+package org.apache.servicecomb.demo.registry;
 
-public interface LifeCycle {
-  void init();
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestHeader;
+import org.springframework.web.bind.annotation.RequestParam;
 
-  void run();
-
-  void destroy();
+public interface IServiceCenterEndpoint {
+  // java name can not be `x-domain-name`, so interfaces define all parameters.
+  @GetMapping(path = "/instances")
+  Object getInstances(@RequestParam(name = "appId") String appId,
+      @RequestParam(name = "serviceName") String serviceName,
+      @RequestParam(name = "global") String global,
+      @RequestParam(name = "version") String version,
+      @RequestHeader(name = "x-domain-name") String domain);
 }
diff --git 
a/demo/demo-multi-registries/demo-multi-registries-client/src/main/java/org/apache/servicecomb/demo/registry/ServiceCenterEndpoint.java
 
b/demo/demo-multi-registries/demo-multi-registries-client/src/main/java/org/apache/servicecomb/demo/registry/ServiceCenterEndpoint.java
new file mode 100644
index 0000000..ceba6f4
--- /dev/null
+++ 
b/demo/demo-multi-registries/demo-multi-registries-client/src/main/java/org/apache/servicecomb/demo/registry/ServiceCenterEndpoint.java
@@ -0,0 +1,40 @@
+/*
+ * 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.demo.registry;
+
+import javax.ws.rs.core.MediaType;
+
+import org.apache.servicecomb.provider.rest.common.RestSchema;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestHeader;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+// do not know how to write schemas? code first and generate it.
+@RestSchema(schemaId = "ServiceCenterEndpoint")
+@RequestMapping(path = "/v4/default/registry", produces = 
MediaType.APPLICATION_JSON)
+public class ServiceCenterEndpoint implements IServiceCenterEndpoint {
+  @GetMapping(path = "/instances")
+  public Object getInstances(@RequestParam(name = "appId") String appId,
+      @RequestParam(name = "serviceName") String serviceName,
+      @RequestParam(name = "global") String global,
+      @RequestParam(name = "version") String version,
+      @RequestHeader(name = "x-domain-name") String domain) {
+    return null;
+  }
+}
diff --git 
a/demo/demo-multi-registries/demo-multi-registries-client/src/main/resources/application.yml
 
b/demo/demo-multi-registries/demo-multi-registries-client/src/main/resources/application.yml
new file mode 100644
index 0000000..257e90b
--- /dev/null
+++ 
b/demo/demo-multi-registries/demo-multi-registries-client/src/main/resources/application.yml
@@ -0,0 +1,34 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+server:
+  port: 8082
+
+# java-chassis configurations
+
+APPLICATION_ID: demo-multi-registries
+service_description:
+  name: demo-multi-registries-client
+  version: 0.0.1
+servicecomb:
+  service:
+    registry:
+      address: http://127.0.0.1:30100
+  handler:
+    chain:
+      Consumer:
+        default: loadbalance
\ No newline at end of file
diff --git 
a/demo/demo-multi-registries/demo-multi-registries-client/src/main/resources/logback.xml
 
b/demo/demo-multi-registries/demo-multi-registries-client/src/main/resources/logback.xml
new file mode 100644
index 0000000..0d627f2
--- /dev/null
+++ 
b/demo/demo-multi-registries/demo-multi-registries-client/src/main/resources/logback.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+
+<configuration scan="true">
+  <appender name="STDOUT-TRACING" class="ch.qos.logback.core.ConsoleAppender">
+    <!-- If applicable, can use ch.qos.logback.classic.filter.MarkerFilter -->
+    <filter class="org.apache.servicecomb.foundation.logback.MarkerFilter">
+      <Marker>SERVICECOMB_MARKER</Marker>
+      <OnMismatch>DENY</OnMismatch>
+      <OnMatch>ACCEPT</OnMatch>
+    </filter>
+
+    <encoder>
+      <pattern>%d [%level] [%thread][%X{SERVICECOMB_TRACE_ID}] - %msg 
(%F:%L\)%n</pattern>
+    </encoder>
+  </appender>
+
+  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+    <!-- If applicable, can use ch.qos.logback.classic.filter.MarkerFilter -->
+    <filter class="org.apache.servicecomb.foundation.logback.MarkerFilter">
+      <Marker>SERVICECOMB_MARKER</Marker>
+      <OnMismatch>ACCEPT</OnMismatch>
+      <OnMatch>DENY</OnMatch>
+    </filter>
+
+    <encoder>
+      <pattern>%d [%level] [%thread] - %msg (%F:%L\)%n</pattern>
+    </encoder>
+  </appender>
+
+  <root level="info">
+    <appender-ref ref="STDOUT"/>
+    <appender-ref ref="STDOUT-TRACING"/>
+  </root>
+</configuration>
\ No newline at end of file
diff --git 
a/demo/demo-multi-registries/demo-multi-registries-client/src/main/resources/microservices/thirdParty-service-center/ServiceCenterEndpoint.yaml
 
b/demo/demo-multi-registries/demo-multi-registries-client/src/main/resources/microservices/thirdParty-service-center/ServiceCenterEndpoint.yaml
new file mode 100644
index 0000000..8ba87fa
--- /dev/null
+++ 
b/demo/demo-multi-registries/demo-multi-registries-client/src/main/resources/microservices/thirdParty-service-center/ServiceCenterEndpoint.yaml
@@ -0,0 +1,59 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+swagger: "2.0"
+info:
+  version: "1.0.0"
+  title: "swagger definition for 
org.apache.servicecomb.demo.registry.ServiceCenterEndpoint"
+  x-java-interface: "gen.swagger.ServiceCenterEndpointIntf"
+basePath: "/v4/default/registry"
+schemes:
+  - "http"
+consumes:
+  - "application/json"
+produces:
+  - "application/json"
+paths:
+  /instances:
+    get:
+      operationId: "getInstances"
+      parameters:
+        - name: "appId"
+          in: "query"
+          required: true
+          type: "string"
+        - name: "serviceName"
+          in: "query"
+          required: true
+          type: "string"
+        - name: "global"
+          in: "query"
+          required: true
+          type: "string"
+        - name: "version"
+          in: "query"
+          required: true
+          type: "string"
+        - name: "x-domain-name"
+          in: "header"
+          required: true
+          type: "string"
+      responses:
+        "200":
+          description: "response of 200"
+          schema:
+            type: "object"
\ No newline at end of file
diff --git 
a/demo/demo-multi-registries/demo-multi-registries-client/src/main/resources/registry.yaml
 
b/demo/demo-multi-registries/demo-multi-registries-client/src/main/resources/registry.yaml
new file mode 100644
index 0000000..00d4588
--- /dev/null
+++ 
b/demo/demo-multi-registries/demo-multi-registries-client/src/main/resources/registry.yaml
@@ -0,0 +1,26 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+thirdParty-service-center:
+  - id: "001"
+    version: "4.0.0"
+    appid: demo-multi-registries
+    schemaIds:
+      - ServiceCenterEndpoint
+    instances:
+      - endpoints:
+          - rest://localhost:30100
diff --git 
a/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/LifeCycle.java
 
b/demo/demo-multi-registries/demo-multi-registries-client/src/test/java/org/apache/servicecomb/demo/registry/MultiRegistriesIT.java
similarity index 61%
copy from 
foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/LifeCycle.java
copy to 
demo/demo-multi-registries/demo-multi-registries-client/src/test/java/org/apache/servicecomb/demo/registry/MultiRegistriesIT.java
index 2e0b4af..e50d92a 100644
--- 
a/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/LifeCycle.java
+++ 
b/demo/demo-multi-registries/demo-multi-registries-client/src/test/java/org/apache/servicecomb/demo/registry/MultiRegistriesIT.java
@@ -15,12 +15,25 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.serviceregistry;
+package org.apache.servicecomb.demo.registry;
 
-public interface LifeCycle {
-  void init();
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
 
-  void run();
+import org.apache.servicecomb.demo.TestMgr;
+import org.junit.Before;
+import org.junit.Test;
 
-  void destroy();
+public class MultiRegistriesIT {
+  @Before
+  public void setUp() throws Exception {
+    TestMgr.errors().clear();
+  }
+
+  @Test
+  public void clientGetsNoError() throws Exception {
+    Application.main(new String[0]);
+
+    assertThat(TestMgr.errors().isEmpty(), is(true));
+  }
 }
diff --git a/demo/demo-multi-registries/demo-multi-registries-server/pom.xml 
b/demo/demo-multi-registries/demo-multi-registries-server/pom.xml
new file mode 100644
index 0000000..41961ec
--- /dev/null
+++ b/demo/demo-multi-registries/demo-multi-registries-server/pom.xml
@@ -0,0 +1,100 @@
+<?xml version="1.0"?>
+<!--
+  ~ 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.
+  -->
+
+<project
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";
+  xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>demo-multi-registries-server</artifactId>
+  <name>Java Chassis::Demo::Multi Registries Server</name>
+  <parent>
+    <groupId>org.apache.servicecomb.demo</groupId>
+    <artifactId>demo-multi-registries</artifactId>
+    <version>2.1.0-SNAPSHOT</version>
+  </parent>
+
+  <properties>
+    
<demo.main>org.apache.servicecomb.demo.registry.ServerApplication</demo.main>
+  </properties>
+  <dependencies>
+    <dependency>
+      <groupId>org.springframework.cloud</groupId>
+      <artifactId>spring-cloud-commons</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework.cloud</groupId>
+      <artifactId>spring-cloud-context</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework.cloud</groupId>
+      <artifactId>spring-cloud-netflix-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>javax.ws.rs</groupId>
+      <artifactId>javax.ws.rs-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>java-chassis-spring-boot-starter-servlet</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb.demo</groupId>
+      <artifactId>demo-schema</artifactId>
+    </dependency>
+
+  </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-maven-plugin</artifactId>
+      </plugin>
+      <plugin>
+        <groupId>com.github.odavid.maven.plugins</groupId>
+        <artifactId>mixin-maven-plugin</artifactId>
+        <configuration>
+          <mixins>
+            <mixin>
+              <groupId>org.apache.servicecomb.demo</groupId>
+              <artifactId>docker-build-config</artifactId>
+              <version>${project.version}</version>
+            </mixin>
+          </mixins>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+  <profiles>
+    <profile>
+      <id>docker</id>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>io.fabric8</groupId>
+            <artifactId>docker-maven-plugin</artifactId>
+          </plugin>
+          <plugin>
+            <groupId>org.commonjava.maven.plugins</groupId>
+            <artifactId>directory-maven-plugin</artifactId>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+  </profiles>
+</project>
diff --git 
a/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/LifeCycle.java
 
b/demo/demo-multi-registries/demo-multi-registries-server/src/main/java/org/apache/servicecomb/demo/registry/SelfServiceInvoker.java
similarity index 52%
copy from 
foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/LifeCycle.java
copy to 
demo/demo-multi-registries/demo-multi-registries-server/src/main/java/org/apache/servicecomb/demo/registry/SelfServiceInvoker.java
index 2e0b4af..b15bb7c 100644
--- 
a/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/LifeCycle.java
+++ 
b/demo/demo-multi-registries/demo-multi-registries-server/src/main/java/org/apache/servicecomb/demo/registry/SelfServiceInvoker.java
@@ -15,12 +15,29 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.serviceregistry;
+package org.apache.servicecomb.demo.registry;
 
-public interface LifeCycle {
-  void init();
+import java.util.concurrent.CountDownLatch;
 
-  void run();
+import org.apache.servicecomb.core.BootListener;
+import org.apache.servicecomb.provider.pojo.RpcReference;
+import org.springframework.stereotype.Component;
 
-  void destroy();
+@Component("SelfServiceInvoker")
+public class SelfServiceInvoker implements BootListener {
+  interface IServerEndpoint {
+    String getName(String name);
+  }
+
+  @RpcReference(microserviceName = "demo-multi-registries-server", schemaId = 
"ServerEndpoint")
+  IServerEndpoint endpoint;
+
+  public CountDownLatch latch = new CountDownLatch(1);
+
+  public String result = "";
+
+  public void onAfterRegistry(BootEvent event) {
+    result = endpoint.getName("hello");
+    latch.countDown();
+  }
 }
diff --git 
a/demo/demo-multi-registries/demo-multi-registries-server/src/main/java/org/apache/servicecomb/demo/registry/ServerApplication.java
 
b/demo/demo-multi-registries/demo-multi-registries-server/src/main/java/org/apache/servicecomb/demo/registry/ServerApplication.java
new file mode 100644
index 0000000..7d53303
--- /dev/null
+++ 
b/demo/demo-multi-registries/demo-multi-registries-server/src/main/java/org/apache/servicecomb/demo/registry/ServerApplication.java
@@ -0,0 +1,44 @@
+/*
+ * 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.demo.registry;
+
+import java.util.concurrent.TimeUnit;
+
+import org.apache.servicecomb.demo.TestMgr;
+import org.apache.servicecomb.foundation.common.utils.BeanUtils;
+import org.apache.servicecomb.springboot2.starter.EnableServiceComb;
+import org.springframework.boot.WebApplicationType;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+
+@SpringBootApplication
+@EnableServiceComb
+public class ServerApplication {
+  public static void main(final String[] args) throws Exception {
+    new 
SpringApplicationBuilder().sources(ServerApplication.class).web(WebApplicationType.SERVLET).build().run(args);
+
+    SelfServiceInvoker invoker = BeanUtils.getBean("SelfServiceInvoker");
+    invoker.latch.await(10, TimeUnit.SECONDS);
+    TestMgr.check(invoker.result, "hello");
+
+    TestMgr.summary();
+    if (!TestMgr.errors().isEmpty()) {
+      System.exit(1);
+    }
+  }
+}
diff --git 
a/demo/demo-multi-registries/demo-multi-registries-server/src/main/java/org/apache/servicecomb/demo/registry/ServerEndpoint.java
 
b/demo/demo-multi-registries/demo-multi-registries-server/src/main/java/org/apache/servicecomb/demo/registry/ServerEndpoint.java
new file mode 100644
index 0000000..595997f
--- /dev/null
+++ 
b/demo/demo-multi-registries/demo-multi-registries-server/src/main/java/org/apache/servicecomb/demo/registry/ServerEndpoint.java
@@ -0,0 +1,42 @@
+/*
+ * 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.demo.registry;
+
+import javax.ws.rs.core.MediaType;
+
+import org.apache.servicecomb.core.Invocation;
+import org.apache.servicecomb.provider.rest.common.RestSchema;
+import org.apache.servicecomb.swagger.invocation.context.ContextUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+@RestSchema(schemaId = "ServerEndpoint")
+@RequestMapping(path = "/register/url/prefix", produces = 
MediaType.APPLICATION_JSON)
+public class ServerEndpoint {
+  private static final Logger LOGGER
+      = LoggerFactory.getLogger(ServerEndpoint.class);
+
+  @GetMapping(path = "/getName")
+  public String getName(@RequestParam(name = "name") String name) {
+    ((Invocation) 
ContextUtils.getInvocationContext()).getTraceIdLogger().info(LOGGER, "get name 
invoked.");
+    return name;
+  }
+}
diff --git 
a/demo/demo-multi-registries/demo-multi-registries-server/src/main/resources/application.yml
 
b/demo/demo-multi-registries/demo-multi-registries-server/src/main/resources/application.yml
new file mode 100644
index 0000000..7658315
--- /dev/null
+++ 
b/demo/demo-multi-registries/demo-multi-registries-server/src/main/resources/application.yml
@@ -0,0 +1,32 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+server:
+  port: 8080
+
+# java-chassis configurations
+
+APPLICATION_ID: demo-multi-registries
+service_description:
+  name: demo-multi-registries-server
+  version: 0.0.2
+servicecomb:
+  service:
+    registry:
+      address: http://127.0.0.1:30100
+  rest:
+    address: 0.0.0.0:8080
\ No newline at end of file
diff --git 
a/demo/demo-multi-registries/demo-multi-registries-server/src/main/resources/logback.xml
 
b/demo/demo-multi-registries/demo-multi-registries-server/src/main/resources/logback.xml
new file mode 100644
index 0000000..0d627f2
--- /dev/null
+++ 
b/demo/demo-multi-registries/demo-multi-registries-server/src/main/resources/logback.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+
+<configuration scan="true">
+  <appender name="STDOUT-TRACING" class="ch.qos.logback.core.ConsoleAppender">
+    <!-- If applicable, can use ch.qos.logback.classic.filter.MarkerFilter -->
+    <filter class="org.apache.servicecomb.foundation.logback.MarkerFilter">
+      <Marker>SERVICECOMB_MARKER</Marker>
+      <OnMismatch>DENY</OnMismatch>
+      <OnMatch>ACCEPT</OnMatch>
+    </filter>
+
+    <encoder>
+      <pattern>%d [%level] [%thread][%X{SERVICECOMB_TRACE_ID}] - %msg 
(%F:%L\)%n</pattern>
+    </encoder>
+  </appender>
+
+  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+    <!-- If applicable, can use ch.qos.logback.classic.filter.MarkerFilter -->
+    <filter class="org.apache.servicecomb.foundation.logback.MarkerFilter">
+      <Marker>SERVICECOMB_MARKER</Marker>
+      <OnMismatch>ACCEPT</OnMismatch>
+      <OnMatch>DENY</OnMatch>
+    </filter>
+
+    <encoder>
+      <pattern>%d [%level] [%thread] - %msg (%F:%L\)%n</pattern>
+    </encoder>
+  </appender>
+
+  <root level="info">
+    <appender-ref ref="STDOUT"/>
+    <appender-ref ref="STDOUT-TRACING"/>
+  </root>
+</configuration>
\ No newline at end of file
diff --git a/demo/demo-multi-registries/pom.xml 
b/demo/demo-multi-registries/pom.xml
new file mode 100644
index 0000000..d238442
--- /dev/null
+++ b/demo/demo-multi-registries/pom.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+
+<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>
+    <version>2.1.0-SNAPSHOT</version>
+  </parent>
+  <artifactId>demo-multi-registries</artifactId>
+  <name>Java Chassis::Demo::Multi Registry</name>
+  <packaging>pom</packaging>
+  <modules>
+    <module>demo-multi-registries-server</module>
+    <module>demo-multi-registries-client</module>
+  </modules>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>java-chassis-spring-boot-starter-servlet</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>registry-local</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>registry-service-center</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>foundation-test-scaffolding</artifactId>
+      <scope>compile</scope>
+    </dependency>
+  </dependencies>
+</project>
diff --git a/demo/pom.xml b/demo/pom.xml
index 68b912a..c0d40fc 100644
--- a/demo/pom.xml
+++ b/demo/pom.xml
@@ -42,6 +42,7 @@
     <module>demo-crossapp</module>
     <module>demo-register-url-prefix</module>
     <module>demo-local-registry</module>
+    <module>demo-multi-registries</module>
     <module>demo-spring-boot-provider</module>
     <module>demo-spring-boot-transport</module>
     <module>demo-edge</module>
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 474a9d9..f6439d1 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
@@ -23,6 +23,7 @@ import java.util.stream.Collectors;
 import org.apache.servicecomb.config.ConfigUtil;
 import org.apache.servicecomb.config.archaius.sources.MicroserviceConfigLoader;
 import org.apache.servicecomb.foundation.common.utils.SPIServiceUtils;
+import org.apache.servicecomb.serviceregistry.api.Discovery;
 import org.apache.servicecomb.serviceregistry.api.registry.Microservice;
 import 
org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance;
 import org.apache.servicecomb.serviceregistry.cache.InstanceCacheManager;
@@ -65,7 +66,9 @@ public class DiscoveryManager {
   public MicroserviceInstances findServiceInstances(String appId, String 
serviceName,
       String versionRule) {
     MicroserviceInstances result = new MicroserviceInstances();
-
+    // default values not suitable for aggregate, reset.
+    result.setNeedRefresh(false);
+    result.setMicroserviceNotExist(true);
     discoveryList
         .forEach(discovery -> {
           MicroserviceInstances microserviceInstances = 
discovery.findServiceInstances(appId, serviceName, versionRule);
@@ -86,7 +89,7 @@ public class DiscoveryManager {
 
   public MicroserviceInstance findMicroserviceInstance(String serviceId, 
String instanceId) {
     for (Discovery discovery : discoveryList) {
-      MicroserviceInstance microserviceInstance = 
discovery.findMicroserviceInstance(serviceId, instanceId);
+      MicroserviceInstance microserviceInstance = 
discovery.getMicroserviceInstance(serviceId, instanceId);
       if (microserviceInstance != null) {
         return microserviceInstance;
       }
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 dc50329..2ed54a5 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
@@ -28,6 +28,7 @@ import org.apache.http.client.utils.URIBuilder;
 import org.apache.servicecomb.foundation.common.net.IpPort;
 import org.apache.servicecomb.foundation.common.net.NetUtils;
 import org.apache.servicecomb.foundation.common.utils.SPIServiceUtils;
+import org.apache.servicecomb.serviceregistry.api.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;
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/api/Discovery.java
similarity index 74%
rename from 
foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/Discovery.java
rename to 
foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/api/Discovery.java
index f94ef33..3a74602 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/api/Discovery.java
@@ -15,24 +15,33 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.serviceregistry;
+package org.apache.servicecomb.serviceregistry.api;
 
 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;
 
+/**
+ * This is the core registry discovery interface. <br/>
+ */
 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);
 
-  // TODO: microservice id may be different in Discovery, maybe better to use 
appId, serviceName and version.
   String getSchema(String microserviceId, String schemaId);
 
-  MicroserviceInstance findMicroserviceInstance(String serviceId, String 
instanceId);
-
+  MicroserviceInstance getMicroserviceInstance(String serviceId, String 
instanceId);
+
+  /**
+   * Find all instances. Implementations can use <code>gerRevision</code> to 
retrieve the
+   * latest instances changed.
+   *
+   * @param appId application id
+   * @param serviceName microservice name
+   * @param versionRule literal version rule. e.g. 1.0.0, 1.0.0+, [1.0.0, 
2.0.0)
+   * @return all instances match the criteria.
+   */
   MicroserviceInstances findServiceInstances(String appId, String serviceName,
       String versionRule);
 
diff --git 
a/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/LifeCycle.java
 
b/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/api/LifeCycle.java
similarity index 94%
rename from 
foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/LifeCycle.java
rename to 
foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/api/LifeCycle.java
index 2e0b4af..f584dea 100644
--- 
a/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/LifeCycle.java
+++ 
b/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/api/LifeCycle.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.serviceregistry;
+package org.apache.servicecomb.serviceregistry.api;
 
 public interface LifeCycle {
   void init();
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/api/Registration.java
similarity index 97%
rename from 
foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/Registration.java
rename to 
foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/api/Registration.java
index 631ff01..3a925e6 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/api/Registration.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.serviceregistry;
+package org.apache.servicecomb.serviceregistry.api;
 
 import java.util.Collection;
 
diff --git 
a/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/http/MicroserviceInstances.java
 
b/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/http/MicroserviceInstances.java
index 218d555..86b8537 100644
--- 
a/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/http/MicroserviceInstances.java
+++ 
b/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/http/MicroserviceInstances.java
@@ -69,30 +69,38 @@ public class MicroserviceInstances {
   }
 
   private void mergeRevision(String revision) {
+    if (revision == null) {
+      return;
+    }
     if (this.revision == null || this.revision.compareTo(revision) < 0) {
       this.revision = revision;
     }
   }
 
   private void mergeMicroserviceNotExist(boolean microserviceNotExist) {
-    // if one of discovery not exist, all mark not exist
-    if (microserviceNotExist) {
+    // only is all not exists, set to not exits.
+    if (this.microserviceNotExist) {
       this.microserviceNotExist = microserviceNotExist;
     }
   }
 
   private void mergeNeedRefresh(boolean needRefresh) {
     // if one of discovery need refresh, all need refresh
-    if (needRefresh) {
+    if (!this.needRefresh) {
       this.needRefresh = needRefresh;
     }
   }
 
   private void mergeInstanceResponse(FindInstancesResponse instancesResponse) {
+    if (instancesResponse == null) {
+      return;
+    }
+
     if (this.instancesResponse == null) {
       this.instancesResponse = instancesResponse;
-    } else {
-      this.instancesResponse.mergeInstances(instancesResponse.getInstances());
+      return;
     }
+
+    this.instancesResponse.mergeInstances(instancesResponse.getInstances());
   }
 }
diff --git 
a/service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalDiscovery.java
 
b/service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalDiscovery.java
index 7750b03..b6ac786 100644
--- 
a/service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalDiscovery.java
+++ 
b/service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalDiscovery.java
@@ -17,7 +17,7 @@
 
 package org.apache.servicecomb.localregistry;
 
-import org.apache.servicecomb.serviceregistry.Discovery;
+import org.apache.servicecomb.serviceregistry.api.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;
@@ -64,7 +64,7 @@ public class LocalDiscovery implements Discovery {
   }
 
   @Override
-  public MicroserviceInstance findMicroserviceInstance(String serviceId, 
String instanceId) {
+  public MicroserviceInstance getMicroserviceInstance(String serviceId, String 
instanceId) {
     return localDiscoveryStore.findMicroserviceInstance(serviceId, instanceId);
   }
 
diff --git 
a/service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalRegistration.java
 
b/service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalRegistration.java
index 3d10844..912a9bd 100644
--- 
a/service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalRegistration.java
+++ 
b/service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalRegistration.java
@@ -20,7 +20,7 @@ package org.apache.servicecomb.localregistry;
 import java.util.Collection;
 
 import org.apache.servicecomb.foundation.common.event.EventManager;
-import org.apache.servicecomb.serviceregistry.Registration;
+import org.apache.servicecomb.serviceregistry.api.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;
diff --git 
a/service-registry/registry-local/src/main/resources/META-INF/services/org.apache.servicecomb.serviceregistry.Discovery
 
b/service-registry/registry-local/src/main/resources/META-INF/services/org.apache.servicecomb.serviceregistry.api.Discovery
similarity index 100%
rename from 
service-registry/registry-local/src/main/resources/META-INF/services/org.apache.servicecomb.serviceregistry.Discovery
rename to 
service-registry/registry-local/src/main/resources/META-INF/services/org.apache.servicecomb.serviceregistry.api.Discovery
diff --git 
a/service-registry/registry-local/src/main/resources/META-INF/services/org.apache.servicecomb.serviceregistry.Registration
 
b/service-registry/registry-local/src/main/resources/META-INF/services/org.apache.servicecomb.serviceregistry.api.Registration
similarity index 100%
rename from 
service-registry/registry-local/src/main/resources/META-INF/services/org.apache.servicecomb.serviceregistry.Registration
rename to 
service-registry/registry-local/src/main/resources/META-INF/services/org.apache.servicecomb.serviceregistry.api.Registration
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 797673b..7518512 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
@@ -17,10 +17,10 @@
 
 package org.apache.servicecomb.serviceregistry;
 
+import org.apache.servicecomb.serviceregistry.api.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;
 
 import com.netflix.config.DynamicPropertyFactory;
 
@@ -63,7 +63,7 @@ public class ServiceCenterDiscovery implements Discovery {
   }
 
   @Override
-  public MicroserviceInstance findMicroserviceInstance(String serviceId, 
String instanceId) {
+  public MicroserviceInstance getMicroserviceInstance(String serviceId, String 
instanceId) {
     return RegistryUtils.getResultFromFirstValidServiceRegistry(
         sr -> sr.getServiceRegistryClient().findServiceInstance(serviceId, 
instanceId));
   }
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 53de75c..305774d 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
@@ -20,6 +20,7 @@ package org.apache.servicecomb.serviceregistry;
 import java.util.Collection;
 
 import 
org.apache.servicecomb.foundation.common.concurrency.SuppressedRunnableWrapper;
+import org.apache.servicecomb.serviceregistry.api.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;
diff --git 
a/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/client/http/ServiceRegistryClientImpl.java
 
b/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/client/http/ServiceRegistryClientImpl.java
index 1201907..752b255 100644
--- 
a/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/client/http/ServiceRegistryClientImpl.java
+++ 
b/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/client/http/ServiceRegistryClientImpl.java
@@ -264,6 +264,7 @@ public final class ServiceRegistryClientImpl implements 
ServiceRegistryClient {
                 case 200:
                   mInstances
                       
.setInstancesResponse(JsonUtils.readValue(bodyBuffer.getBytes(), 
FindInstancesResponse.class));
+                  mInstances.setNeedRefresh(true);
                   break;
                 case 400: {
                   @SuppressWarnings("unchecked")
diff --git 
a/service-registry/registry-service-center/src/main/resources/META-INF/services/org.apache.servicecomb.serviceregistry.Discovery
 
b/service-registry/registry-service-center/src/main/resources/META-INF/services/org.apache.servicecomb.serviceregistry.api.Discovery
similarity index 100%
rename from 
service-registry/registry-service-center/src/main/resources/META-INF/services/org.apache.servicecomb.serviceregistry.Discovery
rename to 
service-registry/registry-service-center/src/main/resources/META-INF/services/org.apache.servicecomb.serviceregistry.api.Discovery
diff --git 
a/service-registry/registry-service-center/src/main/resources/META-INF/services/org.apache.servicecomb.serviceregistry.Registration
 
b/service-registry/registry-service-center/src/main/resources/META-INF/services/org.apache.servicecomb.serviceregistry.api.Registration
similarity index 100%
rename from 
service-registry/registry-service-center/src/main/resources/META-INF/services/org.apache.servicecomb.serviceregistry.Registration
rename to 
service-registry/registry-service-center/src/main/resources/META-INF/services/org.apache.servicecomb.serviceregistry.api.Registration

Reply via email to