Skip to content

Commit

Permalink
Sofaboot 4.0 support (#1356)
Browse files Browse the repository at this point in the history
* feat: let use of javassist compatible at jdk 17

* chore: use latest space id

* feat: update dubbo to 3.1.4

* fix: zk version

* version

* update version

* bump hessian

* update version

* add ci

* set verison as 51100

* fix: destory

* fix: unit test

* remove aci on sofaboot-4.0-support

* feat: update hessian to 3.5.0-SNAPSHOT

* release version

---------

Co-authored-by: junyuan <[email protected]>
Co-authored-by: Lo1nt <[email protected]>
  • Loading branch information
3 people authored Aug 28, 2023
1 parent bff853f commit 7177205
Show file tree
Hide file tree
Showing 18 changed files with 172 additions and 63 deletions.
6 changes: 3 additions & 3 deletions all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.alipay.sofa</groupId>
<artifactId>sofa-rpc-all</artifactId>
<version>5.11.0-SNAPSHOT</version>
<version>5.11.0</version>


<name>${project.groupId}:${project.artifactId}</name>
Expand Down Expand Up @@ -57,9 +57,9 @@
<project.build.sourceEncoding>utf-8</project.build.sourceEncoding>
<slf4j.version>1.7.21</slf4j.version>
<sofa.common.tools.version>1.3.2</sofa.common.tools.version>
<javassist.version>3.28.0-GA</javassist.version>
<javassist.version>3.29.2-GA</javassist.version>
<netty.version>4.1.44.Final</netty.version>
<hessian.version>3.4.0</hessian.version>
<hessian.version>3.5.0</hessian.version>
<resteasy.version>3.6.3.Final</resteasy.version>
<bolt.version>1.6.6</bolt.version>
<tracer.version>3.0.8</tracer.version>
Expand Down
49 changes: 39 additions & 10 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
<packaging>pom</packaging>

<properties>
<revision>5.11.0-SNAPSHOT</revision>
<javassist.version>3.28.0-GA</javassist.version>
<revision>5.11.0</revision>
<javassist.version>3.29.2-GA</javassist.version>
<bytebuddy.version>1.9.8</bytebuddy.version>
<netty.version>4.1.77.Final</netty.version>
<!-- 3rd extends libs -->
Expand All @@ -20,9 +20,10 @@
<jaxrs.api.version>1.0.2.Final</jaxrs.api.version>
<cxf.version>3.4.10</cxf.version>
<jetty.version>7.5.4.v20111024</jetty.version>
<curator.version>4.0.1</curator.version>
<zookeeper.version>3.5.7</zookeeper.version>
<curator.version>4.3.0</curator.version>
<opentracing.version>0.22.0</opentracing.version>
<dubbo.version>2.6.9</dubbo.version>
<dubbo.version>3.1.8</dubbo.version>
<nacos.version>2.0.3</nacos.version>
<sofa.registry.version>6.3.0</sofa.registry.version>
<polaris.version>1.2.2</polaris.version>
Expand All @@ -31,7 +32,7 @@
<guava.version>32.0.0-jre</guava.version>
<prometheus.client.version>0.16.0</prometheus.client.version>
<!-- serialization -->
<hessian.version>3.4.0</hessian.version>
<hessian.version>3.5.0</hessian.version>
<thrift.version>0.9.2</thrift.version>
<protobuf.version>3.22.0</protobuf.version>
<jackson.version>2.12.7</jackson.version>
Expand Down Expand Up @@ -300,25 +301,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 @@ -492,6 +509,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,10 @@ 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<>();
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,18 @@
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<>();
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 @@ -58,7 +57,7 @@ public static void copyRegistries(com.alipay.sofa.rpc.config.AbstractInterfaceCo
}

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
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.rpc.model.FrameworkModel;

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<>();

/**
* 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<>();

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

import com.alibaba.dubbo.common.Constants;
import com.alibaba.dubbo.common.utils.ConfigUtils;
import org.apache.dubbo.common.constants.CommonConstants;
import com.alibaba.dubbo.rpc.RpcContext;
import com.alibaba.dubbo.rpc.service.GenericService;
import com.alipay.sofa.rpc.bootstrap.dubbo.demo.DemoService;
Expand All @@ -32,6 +32,8 @@
import com.alipay.sofa.rpc.context.RpcInvokeContext;
import com.alipay.sofa.rpc.context.RpcRunningState;
import com.alipay.sofa.rpc.context.RpcRuntimeContext;
import org.apache.dubbo.config.ConfigKeys;
import org.apache.dubbo.config.context.ConfigMode;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
Expand All @@ -52,10 +54,50 @@ public class DubooServerTest {

ConsumerConfig<DemoService> consumerConfig;

private static String OLD_VALUE_SHUTDOWN_WAIT_KEY;
private static String OLD_VALUE_DUBBO_CONFIG_IGNORE_DUPLICATED_INTERFACE;
private static String OLD_VALUE_DUBBO_CONFIG_MODE;

//dubbo close wait time
@AfterClass
@BeforeClass
public static void before() {
ConfigUtils.getProperties().put(Constants.SHUTDOWN_WAIT_KEY, "1");
RpcRunningState.setUnitTestMode(true);
OLD_VALUE_SHUTDOWN_WAIT_KEY = System.getProperty(CommonConstants.SHUTDOWN_WAIT_KEY);
OLD_VALUE_DUBBO_CONFIG_IGNORE_DUPLICATED_INTERFACE = System
.getProperty(ConfigKeys.DUBBO_CONFIG_IGNORE_DUPLICATED_INTERFACE);
OLD_VALUE_DUBBO_CONFIG_MODE = System.getProperty(ConfigKeys.DUBBO_CONFIG_MODE);

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());
}

@AfterClass
public static void after() {
if (OLD_VALUE_SHUTDOWN_WAIT_KEY == null) {
System.clearProperty(CommonConstants.SHUTDOWN_WAIT_KEY);
} else {
System.setProperty(CommonConstants.SHUTDOWN_WAIT_KEY, OLD_VALUE_SHUTDOWN_WAIT_KEY);
}

if (OLD_VALUE_DUBBO_CONFIG_IGNORE_DUPLICATED_INTERFACE == null) {
System.clearProperty(ConfigKeys.DUBBO_CONFIG_IGNORE_DUPLICATED_INTERFACE);
} else {
System.setProperty(ConfigKeys.DUBBO_CONFIG_IGNORE_DUPLICATED_INTERFACE,
OLD_VALUE_DUBBO_CONFIG_IGNORE_DUPLICATED_INTERFACE);
}

if (OLD_VALUE_DUBBO_CONFIG_MODE == null) {
System.clearProperty(ConfigKeys.DUBBO_CONFIG_MODE);
} else {
System.setProperty(ConfigKeys.DUBBO_CONFIG_MODE, OLD_VALUE_DUBBO_CONFIG_MODE);
}
}

@After
public void afterMethod() {
RpcInternalContext.removeAllContext();
RpcInvokeContext.removeContext();
}

@Test
Expand Down Expand Up @@ -288,7 +330,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 @@ -324,17 +366,4 @@ public void testConsumerWithNoDubboServiceVersion() {
Assert.assertTrue(result.equalsIgnoreCase("hello xxx"));

}

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

@After
public void afterMethod() {
DubboSingleton.destroyAll();
RpcRuntimeContext.destroy();
RpcInternalContext.removeAllContext();
RpcInvokeContext.removeContext();
}
}
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
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ public final class Version {
/**
* 当前Build版本,每次发布修改
*/
public static final String BUILD_VERSION = "5.11.0_20230720235253";
public static final String BUILD_VERSION = "5.11.0_20230828164355";

}
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 @@ -43,11 +43,14 @@ 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>
*/
RegistryConfig registryConfig = new RegistryConfig()
.setProtocol(RpcConstants.REGISTRY_PROTOCOL_ZK)
Expand Down
Loading

0 comments on commit 7177205

Please sign in to comment.