You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by vi...@apache.org on 2019/08/16 09:55:18 UTC

[dubbo] branch cloud-native updated (870782e -> 21e75e0)

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

victory pushed a change to branch cloud-native
in repository https://gitbox.apache.org/repos/asf/dubbo.git.


    from 870782e  [Enhancement] Sync the Metadata storage type into ApplicationConfig (#4858)
     new 5232971  test
     new 3d5f358  Merge branch 'cloud-native' of github.com:apache/incubator-dubbo into cloud-native
     new 790de74  etcd test
     new 80d0c99  Merge branch 'cloud-native' of github.com:apache/incubator-dubbo into cloud-native
     new 572ee93  etcd test
     new 21e75e0  etcd test

The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 dubbo-bootstrap/pom.xml                            |  21 +++-
 .../bootstrap/DubboServiceConsumerBootstrap.java   |   3 +-
 ...java => EtcdDubboServiceConsumerBootstrap.java} |  10 +-
 ...java => EtcdDubboServiceProviderBootstrap.java} |   9 +-
 ...ava => NacosDubboServiceConsumerBootstrap.java} |   6 +-
 ...ava => NacosDubboServiceProviderBootstrap.java} |   2 +-
 dubbo-dependencies-bom/pom.xml                     |   5 +
 .../dubbo/registry/etcd/EtcdServiceDiscovery.java  |  26 +++++
 ...g.apache.dubbo.registry.client.ServiceDiscovery |   2 +-
 dubbo-remoting/dubbo-remoting-etcd3/pom.xml        |  15 +++
 .../dubbo/remoting/etcd/jetcd/JEtcdClient.java     |   2 +-
 .../dubbo/remoting/etcd/jetcd/LeaseTest.java       | 122 +++++++++++++++++++++
 12 files changed, 207 insertions(+), 16 deletions(-)
 copy dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/{DubboServiceConsumerBootstrap.java => EtcdDubboServiceConsumerBootstrap.java} (84%)
 copy dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/{DubboServiceProviderBootstrap.java => EtcdDubboServiceProviderBootstrap.java} (91%)
 copy dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/{DubboServiceConsumerBootstrap.java => NacosDubboServiceConsumerBootstrap.java} (88%)
 rename dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/{DubboServiceProvider2Bootstrap.java => NacosDubboServiceProviderBootstrap.java} (97%)
 create mode 100644 dubbo-remoting/dubbo-remoting-etcd3/src/test/java/org/apache/dubbo/remoting/etcd/jetcd/LeaseTest.java


[dubbo] 01/06: test

Posted by vi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

victory pushed a commit to branch cloud-native
in repository https://gitbox.apache.org/repos/asf/dubbo.git

commit 52329719844abfd2cc84a8c8b37f78264b7dcfcd
Author: cvictory <sh...@gmail.com>
AuthorDate: Fri Aug 16 11:11:34 2019 +0800

    test
---
 dubbo-bootstrap/pom.xml                            | 21 ++++-
 .../EtcdDubboServiceConsumerBootstrap.java         | 58 +++++++++++++
 .../EtcdDubboServiceProviderBootstrap.java         | 95 ++++++++++++++++++++++
 .../NacosDubboServiceConsumerBootstrap.java        | 58 +++++++++++++
 ...ava => NacosDubboServiceProviderBootstrap.java} |  2 +-
 .../dubbo/registry/etcd/EtcdServiceDiscovery.java  | 26 ++++++
 6 files changed, 258 insertions(+), 2 deletions(-)

diff --git a/dubbo-bootstrap/pom.xml b/dubbo-bootstrap/pom.xml
index 2566294..7cac061 100644
--- a/dubbo-bootstrap/pom.xml
+++ b/dubbo-bootstrap/pom.xml
@@ -35,6 +35,18 @@
         </dependency>
         <dependency>
             <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo-registry-etcd3</artifactId>
+            <version>${project.parent.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+            <version>20.0</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
             <artifactId>dubbo-registry-consul</artifactId>
             <version>${project.parent.version}</version>
             <scope>test</scope>
@@ -49,6 +61,13 @@
 
         <dependency>
             <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo-metadata-report-etcd</artifactId>
+            <version>${project.parent.version}</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
             <artifactId>dubbo-configcenter-zookeeper</artifactId>
             <version>${project.parent.version}</version>
             <scope>test</scope>
@@ -110,4 +129,4 @@
 
     </dependencies>
 
-</project>
\ No newline at end of file
+</project>
diff --git a/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/EtcdDubboServiceConsumerBootstrap.java b/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/EtcdDubboServiceConsumerBootstrap.java
new file mode 100644
index 0000000..db4e152
--- /dev/null
+++ b/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/EtcdDubboServiceConsumerBootstrap.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.dubbo.bootstrap;
+
+import org.apache.dubbo.bootstrap.rest.UserService;
+import org.apache.dubbo.config.MetadataReportConfig;
+import org.apache.dubbo.config.ReferenceConfig;
+import org.apache.dubbo.config.context.ConfigManager;
+
+/**
+ * Dubbo Provider Bootstrap
+ *
+ * @since 2.7.4
+ */
+public class EtcdDubboServiceConsumerBootstrap {
+
+    public static void main(String[] args) throws Exception {
+
+        new DubboBootstrap()
+                .application("dubbo-consumer-demo")
+                // Zookeeper
+                .registry("zookeeper", builder -> builder.address("etcd3://127.0.0.1:2379?registry.type=service&subscribed.services=dubbo-provider-demo"))
+                .metadataReport(new MetadataReportConfig("etcd://127.0.0.1:2379"))
+                // Nacos
+//                .registry("consul", builder -> builder.address("consul://127.0.0.1:8500?registry.type=service&subscribed.services=dubbo-provider-demo").group("namespace1"))
+                .reference("echo", builder -> builder.interfaceClass(EchoService.class).protocol("dubbo"))
+                .reference("user", builder -> builder.interfaceClass(UserService.class).protocol("rest"))
+                .onlyRegisterProvider(true)
+                .start()
+                .await();
+
+        ConfigManager configManager = ConfigManager.getInstance();
+
+        ReferenceConfig<EchoService> referenceConfig = configManager.getReference("echo");
+
+        EchoService echoService = referenceConfig.get();
+
+        for (int i = 0; i < 500; i++) {
+            Thread.sleep(2000L);
+            System.out.println(echoService.echo("Hello,World"));
+        }
+
+    }
+}
diff --git a/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/EtcdDubboServiceProviderBootstrap.java b/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/EtcdDubboServiceProviderBootstrap.java
new file mode 100644
index 0000000..d488ec6
--- /dev/null
+++ b/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/EtcdDubboServiceProviderBootstrap.java
@@ -0,0 +1,95 @@
+/*
+ * 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.dubbo.bootstrap;
+
+import org.apache.dubbo.bootstrap.rest.UserService;
+import org.apache.dubbo.bootstrap.rest.UserServiceImpl;
+import org.apache.dubbo.config.ApplicationConfig;
+import org.apache.dubbo.config.MetadataReportConfig;
+import org.apache.dubbo.config.ProtocolConfig;
+import org.apache.dubbo.config.RegistryConfig;
+import org.apache.dubbo.config.ServiceConfig;
+
+import java.util.Arrays;
+
+/**
+ * Dubbo Provider Bootstrap
+ *
+ * @since 2.7.4
+ */
+public class EtcdDubboServiceProviderBootstrap {
+
+    public static void main(String[] args) {
+        multipleRegistries();
+    }
+
+    private static void multipleRegistries() {
+        ProtocolConfig restProtocol = new ProtocolConfig();
+        restProtocol.setName("rest");
+        restProtocol.setId("rest");
+        restProtocol.setPort(-1);
+
+        RegistryConfig interfaceRegistry = new RegistryConfig();
+        interfaceRegistry.setId("interfaceRegistry");
+        interfaceRegistry.setAddress("etcd3://127.0.0.1:2379");
+
+        RegistryConfig serviceRegistry = new RegistryConfig();
+        serviceRegistry.setId("serviceRegistry");
+        serviceRegistry.setAddress("etcd3://127.0.0.1:2379?registry.type=service");
+
+        ServiceConfig<EchoService> echoService = new ServiceConfig<>();
+        echoService.setInterface(EchoService.class.getName());
+        echoService.setRef(new EchoServiceImpl());
+//        echoService.setRegistries(Arrays.asList(interfaceRegistry, serviceRegistry));
+
+        ServiceConfig<UserService> userService = new ServiceConfig<>();
+        userService.setInterface(UserService.class.getName());
+        userService.setRef(new UserServiceImpl());
+        userService.setProtocol(restProtocol);
+//        userService.setRegistries(Arrays.asList(interfaceRegistry, serviceRegistry));
+
+        ApplicationConfig applicationConfig = new ApplicationConfig("dubbo-provider-demo");
+        applicationConfig.setMetadata("remote");
+        new DubboBootstrap()
+                .application(applicationConfig)
+                // Zookeeper in service registry type
+//                .registry("zookeeper", builder -> builder.address("zookeeper://127.0.0.1:2181?registry.type=service"))
+                // Nacos
+//                .registry("zookeeper", builder -> builder.address("nacos://127.0.0.1:8848?registry.type=service"))
+                .registries(Arrays.asList(interfaceRegistry, serviceRegistry))
+//                .registry(RegistryBuilder.newBuilder().address("consul://127.0.0.1:8500?registry.type=service").build())
+                .protocol(builder -> builder.port(-1).name("dubbo"))
+                .metadataReport(new MetadataReportConfig("etcd://127.0.0.1:2379"))
+                .service(echoService)
+                .service(userService)
+                .start()
+                .await();
+    }
+
+    private static void testSCCallDubbo() {
+
+    }
+
+    private static void testDubboCallSC() {
+
+    }
+
+    private static void testDubboTansormation() {
+
+    }
+
+}
diff --git a/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/NacosDubboServiceConsumerBootstrap.java b/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/NacosDubboServiceConsumerBootstrap.java
new file mode 100644
index 0000000..3f57736
--- /dev/null
+++ b/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/NacosDubboServiceConsumerBootstrap.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.dubbo.bootstrap;
+
+import org.apache.dubbo.bootstrap.rest.UserService;
+import org.apache.dubbo.config.MetadataReportConfig;
+import org.apache.dubbo.config.ReferenceConfig;
+import org.apache.dubbo.config.context.ConfigManager;
+
+/**
+ * Dubbo Provider Bootstrap
+ *
+ * @since 2.7.4
+ */
+public class NacosDubboServiceConsumerBootstrap {
+
+    public static void main(String[] args) throws Exception {
+
+        new DubboBootstrap()
+                .application("dubbo-consumer-demo")
+                // Zookeeper
+                .registry("zookeeper", builder -> builder.address("zookeeper://127.0.0.1:2181?registry.type=service&subscribed.services=dubbo-provider-demo"))
+                .metadataReport(new MetadataReportConfig("zookeeper://127.0.0.1:2181"))
+                // Nacos
+//                .registry("consul", builder -> builder.address("consul://127.0.0.1:8500?registry.type=service&subscribed.services=dubbo-provider-demo").group("namespace1"))
+                .reference("echo", builder -> builder.interfaceClass(EchoService.class).protocol("dubbo"))
+                .reference("user", builder -> builder.interfaceClass(UserService.class).protocol("rest"))
+                .onlyRegisterProvider(true)
+                .start()
+                .await();
+
+        ConfigManager configManager = ConfigManager.getInstance();
+
+        ReferenceConfig<EchoService> referenceConfig = configManager.getReference("echo");
+
+        EchoService echoService = referenceConfig.get();
+
+        for (int i = 0; i < 500; i++) {
+            Thread.sleep(2000L);
+            System.out.println(echoService.echo("Hello,World"));
+        }
+
+    }
+}
diff --git a/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/DubboServiceProvider2Bootstrap.java b/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/NacosDubboServiceProviderBootstrap.java
similarity index 97%
rename from dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/DubboServiceProvider2Bootstrap.java
rename to dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/NacosDubboServiceProviderBootstrap.java
index ad87adb..c631aa1 100644
--- a/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/DubboServiceProvider2Bootstrap.java
+++ b/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/NacosDubboServiceProviderBootstrap.java
@@ -21,7 +21,7 @@ package org.apache.dubbo.bootstrap;
  *
  * @since 2.7.4
  */
-public class DubboServiceProvider2Bootstrap {
+public class NacosDubboServiceProviderBootstrap {
 
     public static void main(String[] args) {
         new DubboBootstrap()
diff --git a/dubbo-registry/dubbo-registry-etcd3/src/main/java/org/apache/dubbo/registry/etcd/EtcdServiceDiscovery.java b/dubbo-registry/dubbo-registry-etcd3/src/main/java/org/apache/dubbo/registry/etcd/EtcdServiceDiscovery.java
index a684c2c..612e34c 100644
--- a/dubbo-registry/dubbo-registry-etcd3/src/main/java/org/apache/dubbo/registry/etcd/EtcdServiceDiscovery.java
+++ b/dubbo-registry/dubbo-registry-etcd3/src/main/java/org/apache/dubbo/registry/etcd/EtcdServiceDiscovery.java
@@ -19,10 +19,12 @@ package org.apache.dubbo.registry.etcd;
 import org.apache.dubbo.common.URL;
 import org.apache.dubbo.common.logger.Logger;
 import org.apache.dubbo.common.logger.LoggerFactory;
+import org.apache.dubbo.common.utils.CollectionUtils;
 import org.apache.dubbo.common.utils.ConcurrentHashSet;
 import org.apache.dubbo.event.EventDispatcher;
 import org.apache.dubbo.event.EventListener;
 import org.apache.dubbo.registry.NotifyListener;
+import org.apache.dubbo.registry.client.DefaultServiceInstance;
 import org.apache.dubbo.registry.client.ServiceDiscovery;
 import org.apache.dubbo.registry.client.ServiceInstance;
 import org.apache.dubbo.registry.client.event.ServiceInstancesChangedEvent;
@@ -37,13 +39,17 @@ import org.apache.dubbo.rpc.RpcException;
 import com.google.gson.Gson;
 
 import java.io.File;
+import java.util.ArrayList;
 import java.util.Collections;
+import java.util.List;
 import java.util.Map;
 import java.util.Optional;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 
+import static org.apache.dubbo.common.constants.RegistryConstants.DYNAMIC_KEY;
+
 /**
  * 2019-07-08
  */
@@ -101,6 +107,7 @@ public class EtcdServiceDiscovery implements ServiceDiscovery, EventListener<Ser
         try {
             this.serviceInstance = serviceInstance;
             String path = toPath(serviceInstance);
+//            etcdClient.createEphemeral(path);
             etcdClient.putEphemeral(path, new Gson().toJson(serviceInstance));
             services.add(serviceInstance.getServiceName());
         } catch (Throwable e) {
@@ -116,6 +123,10 @@ public class EtcdServiceDiscovery implements ServiceDiscovery, EventListener<Ser
                 + ":" + serviceInstance.getPort();
     }
 
+    String toParentPath(String serviceName) {
+        return root + File.separator + serviceName;
+    }
+
     @Override
     public void update(ServiceInstance serviceInstance) throws RuntimeException {
         try {
@@ -153,6 +164,21 @@ public class EtcdServiceDiscovery implements ServiceDiscovery, EventListener<Ser
         dispatcher.addEventListener(listener);
     }
 
+    @Override
+    public List<ServiceInstance> getInstances(String serviceName) {
+        List<String> children = etcdClient.getChildren(toParentPath(serviceName));
+        if (CollectionUtils.isEmpty(children)) {
+            return Collections.EMPTY_LIST;
+        }
+        List<ServiceInstance> list = new ArrayList<>(children.size());
+        for (String child : children) {
+            ServiceInstance serviceInstance = new Gson().fromJson(etcdClient.getKVValue(child), DefaultServiceInstance.class);
+            list.add(serviceInstance);
+        }
+        return list;
+    }
+
+
     protected void registerServiceWatcher(String serviceName) {
         String path = root + File.separator + serviceName;
         /*


[dubbo] 04/06: Merge branch 'cloud-native' of github.com:apache/incubator-dubbo into cloud-native

Posted by vi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

victory pushed a commit to branch cloud-native
in repository https://gitbox.apache.org/repos/asf/dubbo.git

commit 80d0c99aa5c4a1237a84097e64b4bb5252cd7210
Merge: 790de74 dea9507
Author: cvictory <sh...@gmail.com>
AuthorDate: Fri Aug 16 15:20:05 2019 +0800

    Merge branch 'cloud-native' of github.com:apache/incubator-dubbo into cloud-native

 .../org/apache/dubbo/bootstrap/DubboBootstrap.java | 242 +++++++++++----------
 .../bootstrap/DubboServiceConsumerBootstrap.java   |   1 +
 .../NacosDubboServiceProviderBootstrap.java        |   2 +-
 .../client/AbstractServiceDiscoveryFactory.java    |  43 +---
 .../client/DefaultServiceDiscoveryFactory.java     |  17 +-
 .../client/EventPublishingServiceDiscovery.java    |  10 +-
 .../registry/client/ServiceDiscoveryRegistry.java  |  41 ++--
 .../event/ServiceDiscoveryDestroyedEvent.java      |  10 +-
 .../event/ServiceDiscoveryDestroyingEvent.java     |  10 +-
 .../client/event/ServiceDiscoveryEvent.java        |  26 ++-
 .../event/ServiceDiscoveryExceptionEvent.java      |  10 +-
 .../event/ServiceDiscoveryInitializedEvent.java    |  11 +-
 .../event/ServiceDiscoveryInitializingEvent.java   |  10 +-
 .../event/listener/LoggingEventListenerTest.java   |   8 +-
 14 files changed, 218 insertions(+), 223 deletions(-)



[dubbo] 06/06: etcd test

Posted by vi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

victory pushed a commit to branch cloud-native
in repository https://gitbox.apache.org/repos/asf/dubbo.git

commit 21e75e02520d80ec8d1968130687a28e04ce3b9a
Merge: 572ee93 870782e
Author: cvictory <sh...@gmail.com>
AuthorDate: Fri Aug 16 17:54:56 2019 +0800

    etcd test

 dubbo-all/pom.xml                                  |  4 ++
 .../org/apache/dubbo/bootstrap/DubboBootstrap.java | 24 ++++----
 .../bootstrap/DubboServiceProviderBootstrap.java   |  6 +-
 .../EtcdDubboServiceProviderBootstrap.java         |  2 +-
 .../NacosDubboServiceProviderBootstrap.java        |  5 +-
 .../org/apache/dubbo/config/ApplicationConfig.java | 11 ++--
 .../dubbo/config/builders/ApplicationBuilder.java  |  2 +-
 .../ConfigurableMetadataServiceExporter.java       | 67 +++++++++++-----------
 .../dubbo/config/DubboProviderBootstrap.java       |  4 +-
 .../ConfigurableMetadataServiceExporterTest.java   |  4 +-
 dubbo-registry/dubbo-registry-api/pom.xml          |  8 +++
 .../registry/client/ServiceDiscoveryRegistry.java  |  2 +-
 .../metadata/RefreshServiceMetadataCustomizer.java | 10 ++--
 .../metadata/ServiceInstanceMetadataUtils.java     | 22 +++++--
 14 files changed, 99 insertions(+), 72 deletions(-)

diff --cc dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/EtcdDubboServiceProviderBootstrap.java
index 07f349a,0000000..013c0d8
mode 100644,000000..100644
--- a/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/EtcdDubboServiceProviderBootstrap.java
+++ b/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/EtcdDubboServiceProviderBootstrap.java
@@@ -1,96 -1,0 +1,96 @@@
 +/*
 + * 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.dubbo.bootstrap;
 +
 +import org.apache.dubbo.bootstrap.rest.UserService;
 +import org.apache.dubbo.bootstrap.rest.UserServiceImpl;
 +import org.apache.dubbo.config.ApplicationConfig;
 +import org.apache.dubbo.config.MetadataReportConfig;
 +import org.apache.dubbo.config.ProtocolConfig;
 +import org.apache.dubbo.config.RegistryConfig;
 +import org.apache.dubbo.config.ServiceConfig;
 +
 +import java.util.Arrays;
 +
 +/**
 + * Dubbo Provider Bootstrap
 + *
 + * @since 2.7.4
 + */
 +public class EtcdDubboServiceProviderBootstrap {
 +
 +    public static void main(String[] args) {
 +        multipleRegistries();
 +    }
 +
 +    private static void multipleRegistries() {
 +        ProtocolConfig restProtocol = new ProtocolConfig();
 +        restProtocol.setName("rest");
 +        restProtocol.setId("rest");
 +        restProtocol.setPort(-1);
 +
 +        RegistryConfig interfaceRegistry = new RegistryConfig();
 +        interfaceRegistry.setId("interfaceRegistry");
 +        interfaceRegistry.setAddress("etcd3://127.0.0.1:2379");
 +
 +        RegistryConfig serviceRegistry = new RegistryConfig();
 +        serviceRegistry.setId("serviceRegistry");
 +        serviceRegistry.setAddress("etcd3://127.0.0.1:2379?registry.type=service");
 +
 +        ServiceConfig<EchoService> echoService = new ServiceConfig<>();
 +        echoService.setInterface(EchoService.class.getName());
 +        echoService.setRef(new EchoServiceImpl());
 +//        echoService.setRegistries(Arrays.asList(interfaceRegistry, serviceRegistry));
 +
 +        ServiceConfig<UserService> userService = new ServiceConfig<>();
 +        userService.setInterface(UserService.class.getName());
 +        userService.setRef(new UserServiceImpl());
 +        userService.setProtocol(restProtocol);
 +//        userService.setRegistries(Arrays.asList(interfaceRegistry, serviceRegistry));
 +
 +        ApplicationConfig applicationConfig = new ApplicationConfig("dubbo-provider-demo");
-         applicationConfig.setMetadata("remote");
++        applicationConfig.setMetadataStorageType("remote");
 +        new DubboBootstrap()
 +                .application(applicationConfig)
 +                .defaultMetadataStorageType(true)
 +                // Zookeeper in service registry type
 +//                .registry("zookeeper", builder -> builder.address("zookeeper://127.0.0.1:2181?registry.type=service"))
 +                // Nacos
 +//                .registry("zookeeper", builder -> builder.address("nacos://127.0.0.1:8848?registry.type=service"))
 +                .registries(Arrays.asList(interfaceRegistry, serviceRegistry))
 +//                .registry(RegistryBuilder.newBuilder().address("consul://127.0.0.1:8500?registry.type=service").build())
 +                .protocol(builder -> builder.port(-1).name("dubbo"))
 +                .metadataReport(new MetadataReportConfig("etcd://127.0.0.1:2379"))
 +                .service(echoService)
 +                .service(userService)
 +                .start()
 +                .await();
 +    }
 +
 +    private static void testSCCallDubbo() {
 +
 +    }
 +
 +    private static void testDubboCallSC() {
 +
 +    }
 +
 +    private static void testDubboTansormation() {
 +
 +    }
 +
 +}


[dubbo] 02/06: Merge branch 'cloud-native' of github.com:apache/incubator-dubbo into cloud-native

Posted by vi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

victory pushed a commit to branch cloud-native
in repository https://gitbox.apache.org/repos/asf/dubbo.git

commit 3d5f3589f0958249c8ed31700da83a38689c5328
Merge: 5232971 d6d0bec
Author: cvictory <sh...@gmail.com>
AuthorDate: Fri Aug 16 11:11:49 2019 +0800

    Merge branch 'cloud-native' of github.com:apache/incubator-dubbo into cloud-native

 .../org/apache/dubbo/bootstrap/DubboBootstrap.java | 165 +++++++++++++--------
 .../bootstrap/DubboServiceConsumerBootstrap.java   |   9 +-
 .../NacosDubboServiceProviderBootstrap.java        |   9 +-
 .../file/FileSystemDynamicConfiguration.java       |   4 +
 .../dubbo/common/constants/RegistryConstants.java  |   2 +-
 .../org/apache/dubbo/common/context/Lifecycle.java |   2 +-
 .../dubbo/common/extension/ExtensionLoader.java    |  14 ++
 .../dubbo/common/function/ThrowableAction.java     |  33 +++--
 .../org/apache/dubbo/common/lang/Prioritized.java  |   3 +-
 .../org/apache/dubbo/config/DubboShutdownHook.java |   2 +-
 .../ConfigurableMetadataServiceExporter.java       |  59 ++++----
 .../dubbo/config/DubboProviderBootstrap.java       |  13 +-
 .../ConfigurableMetadataServiceExporterTest.java   |   2 +-
 .../org/apache/dubbo/metadata/MetadataService.java |   2 +-
 .../dubbo/metadata/MetadataServiceExporter.java    |  23 ++-
 .../dubbo/metadata/WritableMetadataService.java    |  28 +++-
 .../client/AbstractServiceDiscoveryFactory.java    |  16 +-
 .../client/DefaultServiceDiscoveryFactory.java     |  54 +++++++
 .../client/EventPublishingServiceDiscovery.java    | 125 +++++++++-------
 .../client/FileSystemServiceDiscovery.java         |  22 +--
 .../dubbo/registry/client/ServiceDiscovery.java    |  19 ++-
 .../registry/client/ServiceDiscoveryFactory.java   |  29 +++-
 .../ServiceDiscoveryRegistry.java}                 |  84 ++++++-----
 .../ServiceDiscoveryRegistryFactory.java}          |   6 +-
 .../ServiceDiscoveryRegistryProtocol.java}         |   4 +-
 ...nt.java => ServiceDiscoveryDestroyedEvent.java} |  17 +--
 ...t.java => ServiceDiscoveryDestroyingEvent.java} |  17 +--
 ...toppedEvent.java => ServiceDiscoveryEvent.java} |  17 ++-
 ...nt.java => ServiceDiscoveryExceptionEvent.java} |  28 ++--
 ....java => ServiceDiscoveryInitializedEvent.java} |  19 +--
 ...java => ServiceDiscoveryInitializingEvent.java} |  19 +--
 .../event/listener/LoggingEventListener.java       |  20 +--
 ...ExportedServicesRevisionMetadataCustomizer.java |  11 +-
 ...MetadataServiceURLParamsMetadataCustomizer.java |   9 +-
 .../metadata/RefreshServiceMetadataCustomizer.java |   7 +-
 .../metadata/ServiceInstanceMetadataUtils.java     |  43 ++++--
 .../SpringCloudMetadataServiceURLBuilder.java      |   4 +-
 ...bscribedServicesRevisionMetadataCustomizer.java |  11 +-
 .../org.apache.dubbo.registry.RegistryFactory      |   2 +-
 ...g.apache.dubbo.registry.client.ServiceDiscovery |   1 +
 ...e.dubbo.registry.client.ServiceDiscoveryFactory |   1 +
 .../dubbo/internal/org.apache.dubbo.rpc.Protocol   |   2 +-
 .../EventPublishingServiceDiscoveryTest.java       |  44 +++---
 .../registry/client/InMemoryServiceDiscovery.java  |   5 +-
 .../client/InMemoryServiceDiscoveryFactory.java    |  33 -----
 .../registry/client/ServiceDiscoveryTest.java      |   8 +-
 .../event/listener/LoggingEventListenerTest.java   |  23 +--
 .../support/ServiceOrientedRegistryTest.java       |  10 +-
 ....apache.dubbo.registry.client.ServiceDiscovery} |   2 +-
 .../registry/consul/ConsulServiceDiscovery.java    |  23 ++-
 .../consul/ConsulServiceDiscoveryFactory.java      |  31 ----
 ...g.apache.dubbo.registry.client.ServiceDiscovery |   1 +
 ...e.dubbo.registry.client.ServiceDiscoveryFactory |   1 -
 .../dubbo/registry/etcd/EtcdServiceDiscovery.java  |  36 ++---
 .../registry/etcd/EtcdServiceDiscoveryFactory.java |  39 -----
 ...g.apache.dubbo.registry.client.ServiceDiscovery |   1 +
 ...e.dubbo.registry.client.ServiceDiscoveryFactory |   1 -
 .../registry/nacos/NacosServiceDiscovery.java      |  16 +-
 .../nacos/NacosServiceDiscoveryFactory.java        |  36 -----
 ...g.apache.dubbo.registry.client.ServiceDiscovery |   1 +
 ...e.dubbo.registry.client.ServiceDiscoveryFactory |   1 -
 .../zookeeper/ZookeeperServiceDiscovery.java       |  34 ++---
 .../zookeeper/util/CuratorFrameworkUtils.java      |   5 -
 ....apache.dubbo.registry.client.ServiceDiscovery} |   2 +-
 ...e.dubbo.registry.client.ServiceDiscoveryFactory |   1 -
 .../zookeeper/ZookeeperServiceDiscoveryTest.java   |  10 +-
 66 files changed, 679 insertions(+), 642 deletions(-)

diff --cc dubbo-registry/dubbo-registry-etcd3/src/main/java/org/apache/dubbo/registry/etcd/EtcdServiceDiscovery.java
index 612e34c,b5705e9..45da96e
--- a/dubbo-registry/dubbo-registry-etcd3/src/main/java/org/apache/dubbo/registry/etcd/EtcdServiceDiscovery.java
+++ b/dubbo-registry/dubbo-registry-etcd3/src/main/java/org/apache/dubbo/registry/etcd/EtcdServiceDiscovery.java
@@@ -17,9 -17,9 +17,10 @@@
  package org.apache.dubbo.registry.etcd;
  
  import org.apache.dubbo.common.URL;
+ import org.apache.dubbo.common.extension.ExtensionLoader;
  import org.apache.dubbo.common.logger.Logger;
  import org.apache.dubbo.common.logger.LoggerFactory;
 +import org.apache.dubbo.common.utils.CollectionUtils;
  import org.apache.dubbo.common.utils.ConcurrentHashSet;
  import org.apache.dubbo.event.EventDispatcher;
  import org.apache.dubbo.event.EventListener;


[dubbo] 03/06: etcd test

Posted by vi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

victory pushed a commit to branch cloud-native
in repository https://gitbox.apache.org/repos/asf/dubbo.git

commit 790de7467e40c12cf4bff209a2218e16841fbc34
Author: cvictory <sh...@gmail.com>
AuthorDate: Fri Aug 16 15:19:52 2019 +0800

    etcd test
---
 .../EtcdDubboServiceConsumerBootstrap.java         |   1 +
 dubbo-dependencies-bom/pom.xml                     |   5 +
 ...g.apache.dubbo.registry.client.ServiceDiscovery |   2 +-
 dubbo-remoting/dubbo-remoting-etcd3/pom.xml        |  15 +++
 .../dubbo/remoting/etcd/jetcd/JEtcdClient.java     |   2 +-
 .../dubbo/remoting/etcd/jetcd/LeaseTest.java       | 122 +++++++++++++++++++++
 6 files changed, 145 insertions(+), 2 deletions(-)

diff --git a/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/EtcdDubboServiceConsumerBootstrap.java b/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/EtcdDubboServiceConsumerBootstrap.java
index db4e152..7b0fc47 100644
--- a/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/EtcdDubboServiceConsumerBootstrap.java
+++ b/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/EtcdDubboServiceConsumerBootstrap.java
@@ -33,6 +33,7 @@ public class EtcdDubboServiceConsumerBootstrap {
         new DubboBootstrap()
                 .application("dubbo-consumer-demo")
                 // Zookeeper
+                .protocol(builder -> builder.port(20887).name("dubbo"))
                 .registry("zookeeper", builder -> builder.address("etcd3://127.0.0.1:2379?registry.type=service&subscribed.services=dubbo-provider-demo"))
                 .metadataReport(new MetadataReportConfig("etcd://127.0.0.1:2379"))
                 // Nacos
diff --git a/dubbo-dependencies-bom/pom.xml b/dubbo-dependencies-bom/pom.xml
index 35c808f..ea55a65 100644
--- a/dubbo-dependencies-bom/pom.xml
+++ b/dubbo-dependencies-bom/pom.xml
@@ -428,6 +428,11 @@
                     </exclusion>
                 </exclusions>
             </dependency>
+            <dependency>
+                <groupId>io.etcd</groupId>
+                <artifactId>jetcd-launcher</artifactId>
+                <version>${jetcd_version}</version>
+            </dependency>
             <!-- Log libs -->
             <dependency>
                 <groupId>org.slf4j</groupId>
diff --git a/dubbo-registry/dubbo-registry-etcd3/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.registry.client.ServiceDiscovery b/dubbo-registry/dubbo-registry-etcd3/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.registry.client.ServiceDiscovery
index 60f47ac..804f787 100644
--- a/dubbo-registry/dubbo-registry-etcd3/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.registry.client.ServiceDiscovery
+++ b/dubbo-registry/dubbo-registry-etcd3/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.registry.client.ServiceDiscovery
@@ -1 +1 @@
-etcd=org.apache.dubbo.registry.etcd.EtcdServiceDiscovery
\ No newline at end of file
+etcd3=org.apache.dubbo.registry.etcd.EtcdServiceDiscovery
diff --git a/dubbo-remoting/dubbo-remoting-etcd3/pom.xml b/dubbo-remoting/dubbo-remoting-etcd3/pom.xml
index 285854b..266e3f6 100644
--- a/dubbo-remoting/dubbo-remoting-etcd3/pom.xml
+++ b/dubbo-remoting/dubbo-remoting-etcd3/pom.xml
@@ -32,6 +32,7 @@
     <description>The etcd3 remoting module of Dubbo project</description>
     <properties>
         <skip_maven_deploy>false</skip_maven_deploy>
+        <assertj.version>3.13.2</assertj.version>
     </properties>
     <dependencies>
         <dependency>
@@ -48,10 +49,24 @@
             <groupId>io.etcd</groupId>
             <artifactId>jetcd-core</artifactId>
         </dependency>
+        <!-- https://mvnrepository.com/artifact/io.etcd/jetcd-launcher -->
+        <dependency>
+            <groupId>io.etcd</groupId>
+            <artifactId>jetcd-launcher</artifactId>
+            <scope>test</scope>
+        </dependency>
+
         <dependency>
             <groupId>io.netty</groupId>
             <artifactId>netty-all</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.assertj</groupId>
+            <artifactId>assertj-core</artifactId>
+            <version>${assertj.version}</version>
+            <scope>test</scope>
+        </dependency>
+
     </dependencies>
 
 
diff --git a/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/jetcd/JEtcdClient.java b/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/jetcd/JEtcdClient.java
index d4512d4..784b5a0 100644
--- a/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/jetcd/JEtcdClient.java
+++ b/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/jetcd/JEtcdClient.java
@@ -205,7 +205,7 @@ public class JEtcdClient extends AbstractEtcdClient<JEtcdClient.EtcdWatcher> {
 
     @Override
     public boolean putEphemeral(String key, String value) {
-        return clientWrapper.put(key, value);
+        return clientWrapper.putEphemeral(key, value);
     }
 
     public ManagedChannel getChannel() {
diff --git a/dubbo-remoting/dubbo-remoting-etcd3/src/test/java/org/apache/dubbo/remoting/etcd/jetcd/LeaseTest.java b/dubbo-remoting/dubbo-remoting-etcd3/src/test/java/org/apache/dubbo/remoting/etcd/jetcd/LeaseTest.java
new file mode 100644
index 0000000..2e0d5af
--- /dev/null
+++ b/dubbo-remoting/dubbo-remoting-etcd3/src/test/java/org/apache/dubbo/remoting/etcd/jetcd/LeaseTest.java
@@ -0,0 +1,122 @@
+package org.apache.dubbo.remoting.etcd.jetcd;
+
+import com.google.common.base.Charsets;
+import io.etcd.jetcd.ByteSequence;
+import io.etcd.jetcd.Client;
+import io.etcd.jetcd.CloseableClient;
+import io.etcd.jetcd.KV;
+import io.etcd.jetcd.Lease;
+import io.etcd.jetcd.Observers;
+import io.etcd.jetcd.launcher.EtcdCluster;
+import io.etcd.jetcd.launcher.EtcdClusterFactory;
+import io.etcd.jetcd.lease.LeaseKeepAliveResponse;
+import io.etcd.jetcd.options.PutOption;
+import io.grpc.stub.StreamObserver;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicReference;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * @author cvictory ON 2019-08-16
+ */
+public class LeaseTest {
+
+    private static EtcdCluster cluster;
+
+    private KV kvClient;
+    private Client client;
+    private Lease leaseClient;
+
+    private static final ByteSequence KEY = ByteSequence.from("foo", Charsets.UTF_8);
+    private static final ByteSequence KEY_2 = ByteSequence.from("foo2", Charsets.UTF_8);
+    private static final ByteSequence VALUE = ByteSequence.from("bar", Charsets.UTF_8);
+
+    @BeforeAll
+    public static void beforeClass() {
+        cluster = EtcdClusterFactory.buildCluster("etcd-lease", 3, false);
+        cluster.start();
+    }
+
+    @AfterAll
+    public static void afterClass() {
+        cluster.close();
+    }
+
+    @BeforeEach
+    public void setUp() {
+        client = Client.builder().endpoints(cluster.getClientEndpoints()).build();
+        kvClient = client.getKVClient();
+        leaseClient = client.getLeaseClient();
+    }
+
+    @AfterEach
+    public void tearDown() {
+        if (client != null) {
+            client.close();
+        }
+
+    }
+
+    @Test
+    public void testGrant() throws Exception {
+        long leaseID = leaseClient.grant(5).get().getID();
+
+        kvClient.put(KEY, VALUE, PutOption.newBuilder().withLeaseId(leaseID).build()).get();
+        assertThat(kvClient.get(KEY).get().getCount()).isEqualTo(1);
+
+        Thread.sleep(6000);
+        assertThat(kvClient.get(KEY).get().getCount()).isEqualTo(0);
+    }
+
+    @Test
+    public void testRevoke() throws Exception {
+        long leaseID = leaseClient.grant(5).get().getID();
+        kvClient.put(KEY, VALUE, PutOption.newBuilder().withLeaseId(leaseID).build()).get();
+        assertThat(kvClient.get(KEY).get().getCount()).isEqualTo(1);
+        leaseClient.revoke(leaseID).get();
+        assertThat(kvClient.get(KEY).get().getCount()).isEqualTo(0);
+    }
+
+    @Test
+    public void testKeepAliveOnce() throws ExecutionException, InterruptedException {
+        long leaseID = leaseClient.grant(2).get().getID();
+        kvClient.put(KEY, VALUE, PutOption.newBuilder().withLeaseId(leaseID).build()).get();
+        assertThat(kvClient.get(KEY).get().getCount()).isEqualTo(1);
+        LeaseKeepAliveResponse rp = leaseClient.keepAliveOnce(leaseID).get();
+        assertThat(rp.getTTL()).isGreaterThan(0);
+    }
+
+    @Test
+    public void testKeepAlive() throws ExecutionException, InterruptedException {
+        long leaseID = leaseClient.grant(2).get().getID();
+        kvClient.put(KEY, VALUE, PutOption.newBuilder().withLeaseId(leaseID).build()).get();
+        assertThat(kvClient.get(KEY).get().getCount()).isEqualTo(1);
+
+        CountDownLatch latch = new CountDownLatch(1);
+        AtomicReference<LeaseKeepAliveResponse> responseRef = new AtomicReference<>();
+        StreamObserver<LeaseKeepAliveResponse> observer = Observers.observer(response -> {
+            responseRef.set(response);
+            latch.countDown();
+        });
+
+        try (CloseableClient c = leaseClient.keepAlive(leaseID, observer)) {
+            latch.await(5, TimeUnit.SECONDS);
+            LeaseKeepAliveResponse response = responseRef.get();
+            assertThat(response.getTTL()).isGreaterThan(0);
+        }
+
+        Thread.sleep(3000);
+        assertThat(kvClient.get(KEY).get().getCount()).isEqualTo(0);
+    }
+
+}


[dubbo] 05/06: etcd test

Posted by vi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

victory pushed a commit to branch cloud-native
in repository https://gitbox.apache.org/repos/asf/dubbo.git

commit 572ee931016244fd1643b37005c9a7af85bc35a6
Author: cvictory <sh...@gmail.com>
AuthorDate: Fri Aug 16 17:37:41 2019 +0800

    etcd test
---
 .../java/org/apache/dubbo/bootstrap/DubboServiceConsumerBootstrap.java | 3 ++-
 .../java/org/apache/dubbo/bootstrap/DubboServiceProviderBootstrap.java | 2 +-
 .../org/apache/dubbo/bootstrap/EtcdDubboServiceConsumerBootstrap.java  | 1 +
 .../org/apache/dubbo/bootstrap/EtcdDubboServiceProviderBootstrap.java  | 1 +
 4 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/DubboServiceConsumerBootstrap.java b/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/DubboServiceConsumerBootstrap.java
index 96a865f..e765643 100644
--- a/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/DubboServiceConsumerBootstrap.java
+++ b/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/DubboServiceConsumerBootstrap.java
@@ -31,11 +31,12 @@ public class DubboServiceConsumerBootstrap {
 
         new DubboBootstrap()
                 .application("dubbo-consumer-demo")
+                .protocol(builder -> builder.port(20887).name("dubbo"))
                 // Zookeeper
                 .registry("zookeeper", builder -> builder.address("zookeeper://127.0.0.1:2181?registry.type=service&subscribed.services=dubbo-provider-demo"))
 //                .metadataReport(new MetadataReportConfig("zookeeper://127.0.0.1:2181"))
                 // Nacos
-                .registry("nacos", builder -> builder.address("nacos://127.0.0.1:8848?registry.type=service&subscribed.services=dubbo-provider-demo"))
+//                .registry("nacos", builder -> builder.address("nacos://127.0.0.1:8848?registry.type=service&subscribed.services=dubbo-provider-demo"))
 //                .registry("consul", builder -> builder.address("consul://127.0.0.1:8500?registry.type=service&subscribed.services=dubbo-provider-demo").group("namespace1"))
                 .reference("echo", builder -> builder.interfaceClass(EchoService.class).protocol("dubbo"))
                 .reference("user", builder -> builder.interfaceClass(UserService.class).protocol("rest"))
diff --git a/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/DubboServiceProviderBootstrap.java b/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/DubboServiceProviderBootstrap.java
index d0b7e4a..c964abf 100644
--- a/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/DubboServiceProviderBootstrap.java
+++ b/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/DubboServiceProviderBootstrap.java
@@ -67,7 +67,7 @@ public class DubboServiceProviderBootstrap {
 //        userService.setRegistries(Arrays.asList(interfaceRegistry, serviceRegistry));
 
         ApplicationConfig applicationConfig = new ApplicationConfig("dubbo-provider-demo");
-        applicationConfig.setMetadata("remote");
+//        applicationConfig.setMetadata("remote");
         new DubboBootstrap()
                 .application(applicationConfig)
                 // Zookeeper in service registry type
diff --git a/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/EtcdDubboServiceConsumerBootstrap.java b/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/EtcdDubboServiceConsumerBootstrap.java
index 7b0fc47..01302f3 100644
--- a/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/EtcdDubboServiceConsumerBootstrap.java
+++ b/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/EtcdDubboServiceConsumerBootstrap.java
@@ -32,6 +32,7 @@ public class EtcdDubboServiceConsumerBootstrap {
 
         new DubboBootstrap()
                 .application("dubbo-consumer-demo")
+                .defaultMetadataStorageType(true)
                 // Zookeeper
                 .protocol(builder -> builder.port(20887).name("dubbo"))
                 .registry("zookeeper", builder -> builder.address("etcd3://127.0.0.1:2379?registry.type=service&subscribed.services=dubbo-provider-demo"))
diff --git a/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/EtcdDubboServiceProviderBootstrap.java b/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/EtcdDubboServiceProviderBootstrap.java
index d488ec6..07f349a 100644
--- a/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/EtcdDubboServiceProviderBootstrap.java
+++ b/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/EtcdDubboServiceProviderBootstrap.java
@@ -66,6 +66,7 @@ public class EtcdDubboServiceProviderBootstrap {
         applicationConfig.setMetadata("remote");
         new DubboBootstrap()
                 .application(applicationConfig)
+                .defaultMetadataStorageType(true)
                 // Zookeeper in service registry type
 //                .registry("zookeeper", builder -> builder.address("zookeeper://127.0.0.1:2181?registry.type=service"))
                 // Nacos