Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:update dubbo to 3.0.2.1,change alibaba to apache #1094

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 36 additions & 7 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@
<jaxrs.api.version>1.0.2.Final</jaxrs.api.version>
<cxf.version>3.0.14</cxf.version>
<jetty.version>7.5.4.v20111024</jetty.version>
<curator.version>4.0.1</curator.version>
<zookeeper.version>3.6.3</zookeeper.version>
<curator.version>5.2.0</curator.version>
<opentracing.version>0.22.0</opentracing.version>
<dubbo.version>2.6.7</dubbo.version>
<dubbo.version>3.0.2.1</dubbo.version>
<nacos.version>1.0.0</nacos.version>
<sofa.registry.version>5.2.0</sofa.registry.version>
<swagger.version>1.5.18</swagger.version>
Expand Down Expand Up @@ -298,25 +299,41 @@
<!-- zk client -->
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-recipes</artifactId>
<artifactId>curator-framework</artifactId>
<version>${curator.version}</version>
<exclusions>
<exclusion>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-test</artifactId>
<artifactId>curator-x-discovery</artifactId>
<version>${curator.version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>zookeeper</artifactId>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>${zookeeper.version}</version>
<exclusions>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty</artifactId>
</exclusion>
</exclusions>
</dependency>

<!--dubbo-->
<dependency>
<groupId>com.alibaba</groupId>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo</artifactId>
<version>${dubbo.version}</version>
<exclusions>
Expand Down Expand Up @@ -485,6 +502,18 @@
</dependency>

<!-- Test libs -->
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-test</artifactId>
<version>${curator.version}</version>
<exclusions>
<exclusion>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
</exclusion>
</exclusions>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion bootstrap/bootstrap-dubbo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</dependency>

<dependency>
<groupId>com.alibaba</groupId>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo</artifactId>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
package com.alipay.sofa.rpc.bootstrap.dubbo;

import com.alibaba.dubbo.config.ReferenceConfig;
import org.apache.dubbo.config.ReferenceConfig;
import com.alipay.sofa.rpc.bootstrap.ConsumerBootstrap;
import com.alipay.sofa.rpc.client.Cluster;
import com.alipay.sofa.rpc.client.ProviderGroup;
Expand Down Expand Up @@ -100,7 +100,7 @@ private void copyCommon(ConsumerConfig<T> consumerConfig, ReferenceConfig<T> ref

private void copyApplication(ConsumerConfig<T> consumerConfig, ReferenceConfig<T> referenceConfig) {
ApplicationConfig applicationConfig = consumerConfig.getApplication();
com.alibaba.dubbo.config.ApplicationConfig dubboConfig = new com.alibaba.dubbo.config.ApplicationConfig();
org.apache.dubbo.config.ApplicationConfig dubboConfig = new org.apache.dubbo.config.ApplicationConfig();
dubboConfig.setName(applicationConfig.getAppName());
referenceConfig.setApplication(dubboConfig);
}
Expand Down Expand Up @@ -140,11 +140,11 @@ private void copyConsumer(ConsumerConfig<T> consumerConfig, ReferenceConfig<T> r
private void copyMethods(ConsumerConfig<T> consumerConfig, ReferenceConfig<T> referenceConfig) {
Map<String, MethodConfig> methodConfigs = consumerConfig.getMethods();
if (CommonUtils.isNotEmpty(methodConfigs)) {
List<com.alibaba.dubbo.config.MethodConfig> dubboMethodConfigs =
new ArrayList<com.alibaba.dubbo.config.MethodConfig>();
List<org.apache.dubbo.config.MethodConfig> dubboMethodConfigs =
new ArrayList<org.apache.dubbo.config.MethodConfig>();
for (Map.Entry<String, MethodConfig> entry : methodConfigs.entrySet()) {
MethodConfig methodConfig = entry.getValue();
com.alibaba.dubbo.config.MethodConfig dubboMethodConfig = new com.alibaba.dubbo.config.MethodConfig();
org.apache.dubbo.config.MethodConfig dubboMethodConfig = new org.apache.dubbo.config.MethodConfig();
dubboMethodConfig.setName(methodConfig.getName());
dubboMethodConfig.setParameters(methodConfig.getParameters());
dubboMethodConfig.setTimeout(methodConfig.getTimeout());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@
public class DubboConvertor {

public static void copyRegistries(com.alipay.sofa.rpc.config.AbstractInterfaceConfig sofaConfig,
com.alibaba.dubbo.config.AbstractInterfaceConfig dubboConfig) {
org.apache.dubbo.config.AbstractInterfaceConfig dubboConfig) {
List<RegistryConfig> registryConfigs = sofaConfig.getRegistry();
if (CommonUtils.isNotEmpty(registryConfigs)) {
List<com.alibaba.dubbo.config.RegistryConfig> dubboRegistryConfigs =
new ArrayList<com.alibaba.dubbo.config.RegistryConfig>();
List<org.apache.dubbo.config.RegistryConfig> dubboRegistryConfigs =
new ArrayList<org.apache.dubbo.config.RegistryConfig>();
for (RegistryConfig registryConfig : registryConfigs) {
// 生成并丢到缓存里
com.alibaba.dubbo.config.RegistryConfig dubboRegistryConfig = DubboSingleton.REGISTRY_MAP
org.apache.dubbo.config.RegistryConfig dubboRegistryConfig = DubboSingleton.REGISTRY_MAP
.get(registryConfig);
if (dubboRegistryConfig == null) {
dubboRegistryConfig = new com.alibaba.dubbo.config.RegistryConfig();
dubboRegistryConfig = new org.apache.dubbo.config.RegistryConfig();
copyRegistryFields(registryConfig, dubboRegistryConfig);
com.alibaba.dubbo.config.RegistryConfig old = DubboSingleton.REGISTRY_MAP.putIfAbsent(
org.apache.dubbo.config.RegistryConfig old = DubboSingleton.REGISTRY_MAP.putIfAbsent(
registryConfig, dubboRegistryConfig);
if (old != null) {
dubboRegistryConfig = old;
Expand All @@ -51,14 +51,14 @@ public static void copyRegistries(com.alipay.sofa.rpc.config.AbstractInterfaceCo
}
dubboConfig.setRegistries(dubboRegistryConfigs);
} else {
com.alibaba.dubbo.config.RegistryConfig dubboRegistryConfig = new com.alibaba.dubbo.config.RegistryConfig();
dubboRegistryConfig.setAddress(com.alibaba.dubbo.config.RegistryConfig.NO_AVAILABLE);
org.apache.dubbo.config.RegistryConfig dubboRegistryConfig = new org.apache.dubbo.config.RegistryConfig();
dubboRegistryConfig.setAddress(org.apache.dubbo.config.RegistryConfig.NO_AVAILABLE);
dubboConfig.setRegistry(dubboRegistryConfig);
}
}

public static void copyRegistryFields(com.alipay.sofa.rpc.config.RegistryConfig sofaRegistryConfig,
com.alibaba.dubbo.config.RegistryConfig dubboRegistryConfig) {
org.apache.dubbo.config.RegistryConfig dubboRegistryConfig) {
dubboRegistryConfig.setAddress(sofaRegistryConfig.getAddress());
dubboRegistryConfig.setProtocol(sofaRegistryConfig.getProtocol());
dubboRegistryConfig.setRegister(sofaRegistryConfig.isRegister());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
*/
package com.alipay.sofa.rpc.bootstrap.dubbo;

import com.alibaba.dubbo.config.ProtocolConfig;
import com.alibaba.dubbo.config.ServiceConfig;
import org.apache.dubbo.config.ProtocolConfig;
import org.apache.dubbo.config.ServiceConfig;
import com.alipay.sofa.rpc.bootstrap.ProviderBootstrap;
import com.alipay.sofa.rpc.common.RpcConstants;
import com.alipay.sofa.rpc.common.Version;
Expand Down Expand Up @@ -87,7 +87,7 @@ private void covert(ProviderConfig<T> providerConfig, ServiceConfig<T> serviceCo

private void copyApplication(ProviderConfig<T> providerConfig, ServiceConfig<T> serviceConfig) {
ApplicationConfig applicationConfig = providerConfig.getApplication();
com.alibaba.dubbo.config.ApplicationConfig dubboConfig = new com.alibaba.dubbo.config.ApplicationConfig();
org.apache.dubbo.config.ApplicationConfig dubboConfig = new org.apache.dubbo.config.ApplicationConfig();
dubboConfig.setName(applicationConfig.getAppName());
serviceConfig.setApplication(dubboConfig);
}
Expand Down Expand Up @@ -157,11 +157,11 @@ private void copyProvider(ProviderConfig<T> providerConfig, ServiceConfig<T> ser
private void copyMethods(ProviderConfig<T> providerConfig, ServiceConfig<T> serviceConfig) {
Map<String, MethodConfig> methodConfigs = providerConfig.getMethods();
if (CommonUtils.isNotEmpty(methodConfigs)) {
List<com.alibaba.dubbo.config.MethodConfig> dubboMethodConfigs =
new ArrayList<com.alibaba.dubbo.config.MethodConfig>();
List<org.apache.dubbo.config.MethodConfig> dubboMethodConfigs =
new ArrayList<org.apache.dubbo.config.MethodConfig>();
for (Map.Entry<String, MethodConfig> entry : methodConfigs.entrySet()) {
MethodConfig methodConfig = entry.getValue();
com.alibaba.dubbo.config.MethodConfig dubboMethodConfig = new com.alibaba.dubbo.config.MethodConfig();
org.apache.dubbo.config.MethodConfig dubboMethodConfig = new org.apache.dubbo.config.MethodConfig();
dubboMethodConfig.setName(methodConfig.getName());
dubboMethodConfig.setParameters(methodConfig.getParameters());
dubboMethodConfigs.add(dubboMethodConfig);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
*/
package com.alipay.sofa.rpc.bootstrap.dubbo;

import com.alibaba.dubbo.config.DubboShutdownHook;
import com.alibaba.dubbo.config.ProtocolConfig;
import org.apache.dubbo.config.ProtocolConfig;
import com.alipay.sofa.rpc.base.Destroyable;
import com.alipay.sofa.rpc.config.RegistryConfig;
import com.alipay.sofa.rpc.config.ServerConfig;
import com.alipay.sofa.rpc.context.RpcRuntimeContext;
import org.apache.dubbo.config.DubboShutdownHook;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
Expand Down Expand Up @@ -50,17 +50,17 @@ public void postDestroy() {
/**
* sofa.SeverConfig --> dubbo.ProtocolConfig
*/
final static ConcurrentMap<ServerConfig, ProtocolConfig> SERVER_MAP = new ConcurrentHashMap<ServerConfig, ProtocolConfig>();
final static ConcurrentMap<ServerConfig, ProtocolConfig> SERVER_MAP = new ConcurrentHashMap<ServerConfig, ProtocolConfig>();

/**
* sofa.RegistryConfig --> dubbo.RegistryConfig
*/
final static ConcurrentMap<RegistryConfig, com.alibaba.dubbo.config.RegistryConfig> REGISTRY_MAP = new ConcurrentHashMap<RegistryConfig, com.alibaba.dubbo.config.RegistryConfig>();
final static ConcurrentMap<RegistryConfig, org.apache.dubbo.config.RegistryConfig> REGISTRY_MAP = new ConcurrentHashMap<RegistryConfig, org.apache.dubbo.config.RegistryConfig>();

/**
* Destroy all dubbo resources
*/
public static void destroyAll() {
DubboShutdownHook.getDubboShutdownHook().destroyAll();
DubboShutdownHook.getDubboShutdownHook().run();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
*/
package com.alipay.sofa.rpc.bootstrap.dubbo;

import com.alibaba.dubbo.common.Constants;
import com.alibaba.dubbo.common.utils.ConfigUtils;
import com.alibaba.dubbo.rpc.RpcContext;
import com.alibaba.dubbo.rpc.service.GenericService;
import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.utils.ConfigUtils;
import org.apache.dubbo.config.ConfigKeys;
import org.apache.dubbo.config.context.ConfigMode;
import org.apache.dubbo.rpc.RpcContext;
import org.apache.dubbo.rpc.service.GenericService;
import com.alipay.sofa.rpc.bootstrap.dubbo.demo.DemoService;
import com.alipay.sofa.rpc.bootstrap.dubbo.demo.DemoServiceImpl;
import com.alipay.sofa.rpc.common.RpcConstants;
Expand Down Expand Up @@ -53,9 +55,12 @@ public class DubooServerTest {
ConsumerConfig<DemoService> consumerConfig;

//dubbo close wait time
@AfterClass
@BeforeClass
public static void before() {
ConfigUtils.getProperties().put(Constants.SHUTDOWN_WAIT_KEY, "1");
RpcRunningState.setUnitTestMode(true);
System.setProperty(CommonConstants.SHUTDOWN_WAIT_KEY, "1");
System.setProperty(ConfigKeys.DUBBO_CONFIG_IGNORE_DUPLICATED_INTERFACE, "true");
System.setProperty(ConfigKeys.DUBBO_CONFIG_MODE, ConfigMode.IGNORE.name());
}

@Test
Expand Down Expand Up @@ -288,7 +293,7 @@ public void testWithParameterWithVersion() {
}
}

@Test(expected = com.alibaba.dubbo.rpc.RpcException.class)
@Test(expected = org.apache.dubbo.rpc.RpcException.class)
//同步调用,直连,dubbo 消费没有指定dubbo服务版本version
public void testConsumerWithNoDubboServiceVersion() {
// 只有1个线程 执行
Expand Down Expand Up @@ -325,11 +330,6 @@ public void testConsumerWithNoDubboServiceVersion() {

}

@BeforeClass
public static void adBeforeClass() {
RpcRunningState.setUnitTestMode(true);
}

@After
public void afterMethod() {
DubboSingleton.destroyAll();
Expand Down
2 changes: 1 addition & 1 deletion bootstrap/bootstrap-triple/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</dependency>

<dependency>
<groupId>com.alibaba</groupId>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo</artifactId>
</dependency>
<dependency>
Expand Down
9 changes: 7 additions & 2 deletions example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,19 @@

<!-- dependencies for dubbo -->
<dependency>
<groupId>com.alibaba</groupId>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo</artifactId>
</dependency>

<!-- dependencies for zookeeper -->
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-recipes</artifactId>
<artifactId>curator-framework</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-x-discovery</artifactId>
<scope>test</scope>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ public static void main(String[] args) throws InterruptedException {
* 运行需要pom.xml里增加依赖
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-recipes</artifactId>
<artifactId>curator-framework</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-x-discovery</artifactId>
<scope>test</scope>
</dependency>
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,14 @@ public static void main(String[] args) {
/**
* 运行需要pom.xml里增加依赖
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-recipes</artifactId>
<scope>test</scope>
<groupId>org.apache.curator</groupId>
<artifactId>curator-framework</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-x-discovery</artifactId>
<scope>test</scope>
</dependency>
*/
RegistryConfig registryConfig = new RegistryConfig()
Expand Down
10 changes: 9 additions & 1 deletion registry/registry-zk/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,15 @@

<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-recipes</artifactId>
<artifactId>curator-framework</artifactId>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-x-discovery</artifactId>
</dependency>
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
</dependency>

<dependency>
Expand Down
2 changes: 1 addition & 1 deletion test/test-integration-3rd/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
</dependency>

<dependency>
<groupId>com.alibaba</groupId>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo</artifactId>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import com.alipay.sofa.rpc.registry.base.BaseZkTest;
import com.alipay.sofa.rpc.test.HelloService;
import com.alipay.sofa.rpc.test.HelloServiceImpl;
import org.apache.dubbo.config.ConfigKeys;
import org.apache.dubbo.config.context.ConfigMode;
import org.junit.Assert;
import org.junit.Test;

Expand All @@ -42,6 +44,9 @@ public class DubboServerTest extends BaseZkTest {
@Test
//同步调用,走服务注册中心
public void testRegistrySync() {
System.setProperty(ConfigKeys.DUBBO_CONFIG_IGNORE_DUPLICATED_INTERFACE, "true");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is best to restore the System properties settings after this test case is completed

System.setProperty(ConfigKeys.DUBBO_CONFIG_MODE, ConfigMode.IGNORE.name());

// 只有1个线程 执行
ServerConfig serverConfig = new ServerConfig()
.setStopTimeout(10)
Expand Down