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:24 UTC

[dubbo] 06/06: etcd test

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() {
 +
 +    }
 +
 +}