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

feature: support native-image for seata-client #5476

Merged
merged 39 commits into from
Jul 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
3528b03
add module `spring-framework-fake-for-java8`
wangliang181230 Feb 16, 2023
8041cef
Version to `1.7.0-native-SNAPSHOT`, upgrade `shade-plugin` to `3.2.4`
wangliang181230 Feb 16, 2023
f3e38d0
add some functions for native-image
wangliang181230 Feb 16, 2023
da2f61d
Change proxy `byte-buddy` to `JDK-Proxy`.
wangliang181230 Feb 16, 2023
f1f8374
Add support for `spring-boot-maven-plugin:process-aot`.
wangliang181230 Feb 16, 2023
f9f1248
Add reachability-metadata for `/META-INF/services/*` and `/META-INF/s…
wangliang181230 Feb 16, 2023
eb065bf
Add reachability-metadata for `Configuration`
wangliang181230 Feb 16, 2023
aec3f80
Add reachability-metadata for `seata-core`
wangliang181230 Feb 16, 2023
cd7ea26
Add reachability-metadata for AT mode
wangliang181230 Feb 16, 2023
d21be4c
Add reachability-metadata for XA mode
wangliang181230 Feb 16, 2023
7382e0f
Add reachability-metadata for TCC mode
wangliang181230 Feb 16, 2023
4a4f162
Revert "Add reachability-metadata for XA mode"
wangliang181230 Feb 16, 2023
154f9e9
Add reachability-metadata for XA mode
wangliang181230 Feb 16, 2023
4935939
Add reachability-metadata for `/META-INF/services/*` and `/META-INF/s…
wangliang181230 Feb 16, 2023
8dfe448
Fix the wrong reachability-metadata.
wangliang181230 Feb 16, 2023
4d24be8
Remove duplicate `resource-config.json`
wangliang181230 Feb 16, 2023
56e2cd1
Optimize log
wangliang181230 Feb 16, 2023
7e6b913
release: release for 1.7.0-native-rc1
wangliang181230 Feb 17, 2023
4714e9d
change the version to 1.7.0-NATIVE-RC2-SNAPSHOT
wangliang181230 Feb 18, 2023
d1d345f
Add reachability-metadata for `seata-server`
wangliang181230 Feb 18, 2023
73ad983
1) Fix license;
wangliang181230 Feb 18, 2023
135f5ae
Merge remote-tracking branch 'upstream/develop' into native
wangliang181230 Feb 22, 2023
58dc6aa
add VersionTest.java
wangliang181230 Feb 22, 2023
c93a5c0
add VersionTest.java
wangliang181230 Feb 22, 2023
bade349
release: release for 1.7.0-native-rc2
wangliang181230 Feb 22, 2023
fdf5451
optimize publishes.yml
wangliang181230 Feb 22, 2023
4903f02
release 1.7.0-native-rc2 (#5379)
slievrly Feb 22, 2023
c7a392e
change the version to 1.7.0-native-rc3-SNAPSHOT
wangliang181230 Feb 23, 2023
911c74d
Merge remote-tracking branch 'upstream/develop' into native
wangliang181230 Feb 23, 2023
71a645f
Merge remote-tracking branch 'upstream/develop' into native
wangliang181230 Mar 8, 2023
c8b225f
optimize actions
wangliang181230 Mar 8, 2023
8674671
Merge remote-tracking branch 'upstream/develop' into native
wangliang181230 Mar 30, 2023
f94dffa
optimize style
wangliang181230 Mar 30, 2023
9a14df3
optimize style
wangliang181230 Mar 30, 2023
803267c
恢复spring fake模块下的所有类的许可内容及作者。
wangliang181230 Mar 31, 2023
dfffb5b
style
wangliang181230 Mar 31, 2023
d90ef1c
Merge branch 'develop' into support-graalvm-native-image
funky-eyes Apr 29, 2023
94bd0b6
Merge branch 'develop' into support-graalvm-native-image
wangliang181230 Jun 20, 2023
a47d560
Merge branch 'develop' into support-graalvm-native-image
slievrly Jul 2, 2023
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
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:
# step 4
- name: "Test with Maven"
run: |
./mvnw -T 4C clean test -Dspring-boot.version=${{ matrix.springboot }} -Dcheckstyle.skip=false -Dlicense.skip=false -e -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn;
./mvnw -T 4C clean test -Dspring-boot.version=${{ matrix.springboot }} -Dcheckstyle.skip=true -Dlicense.skip=true -e -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn;

# job 3
arm64-test:
Expand Down
1 change: 1 addition & 0 deletions .licenserc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ header:
- 'ext/apm-seata-skywalking-plugin/config/agent.config'
- 'server/src/main/resources/lua/redislocker/redislock.lua'
- 'server/src/main/resources/banner.txt'
- '**/org/springframework/**'


comment: on-failure
Expand Down
33 changes: 23 additions & 10 deletions all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,16 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.seata</groupId>
<artifactId>seata-spring-aot-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.seata</groupId>
<artifactId>seata-spring-aot-client</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.seata</groupId>
<artifactId>seata-tcc</artifactId>
Expand Down Expand Up @@ -421,10 +431,6 @@
<artifactId>edas-sdk</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
</dependency>
<dependency>
<groupId>aopalliance</groupId>
<artifactId>aopalliance</artifactId>
Expand Down Expand Up @@ -623,6 +629,13 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<phase>package</phase>
Expand All @@ -641,17 +654,17 @@
</artifactSet>
<transformers>
<!-- META-INF/services -->
<transformer
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<!-- spring相关 -->
<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.handlers</resource>
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.schemas</resource>
</transformer>
<transformer implementation="org.springframework.boot.maven.PropertiesMergingResourceTransformer">
<resource>META-INF/spring/aot.factories</resource>
</transformer>
</transformers>
<filters>
<filter>
Expand Down
2 changes: 1 addition & 1 deletion build/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
<maven-source-plugin.version>2.2.1</maven-source-plugin.version>
<maven-resources-plugin.version>3.2.0</maven-resources-plugin.version>
<maven-jar-plugin.version>3.2.2</maven-jar-plugin.version>
<maven-shade-plugin.version>2.4.3</maven-shade-plugin.version>
<maven-shade-plugin.version>3.2.4</maven-shade-plugin.version>
<maven-dependency-plugin.version>3.0.2</maven-dependency-plugin.version>
<maven-assembly-plugin.version>3.0.0</maven-assembly-plugin.version>
<jib-maven-plugin.version>3.2.0</jib-maven-plugin.version>
Expand Down
2 changes: 1 addition & 1 deletion changes/en-us/develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Add changes here for all PR submitted to the develop branch.
<!-- Please add the `changes` to the following location(feature/bugfix/optimize/test) based on the type of PR -->

### feature:
- [[#xxx](https://github.com/seata/seata/pull/xxx)] support xxx
- [[#5476](https://github.com/seata/seata/pull/5476)] First support `native-image` for `seata-client`

### bugfix:
- [[#5682](https://github.com/seata/seata/pull/5682)] fix saga mode replay context lost startParams
Expand Down
2 changes: 1 addition & 1 deletion changes/zh-cn/develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!-- 请根据PR的类型添加 `变更记录` 到以下对应位置(feature/bugfix/optimize/test) 下 -->

### feature:
- [[#xxx](https://github.com/seata/seata/pull/xxx)] 支持 xxx
- [[#5476](https://github.com/seata/seata/pull/5476)] seata客户端,首次支持 `native-image`

### bugfix:
- [[#5682](https://github.com/seata/seata/pull/5682)] 修复saga模式下replay context丢失startParams问题
Expand Down
63 changes: 63 additions & 0 deletions common/src/main/java/io/seata/common/aot/NativeUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed 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 io.seata.common.aot;

/**
* The native utils
*
* @author wang.liang
*/
public class NativeUtils {

/**
* The native-image code
*
* @see <a href="https://github.com/oracle/graal/blob/master/sdk/src/org.graalvm.nativeimage/src/org/graalvm/nativeimage/ImageInfo.java">ImageInfo.java</a>
*/
private static final String NATIVE_IMAGE_CODE = System.getProperty("org.graalvm.nativeimage.imagecode");


public static final String SPRING_AOT_PROCESSING = "spring.aot.processing";


/**
* Whether Spring-AOT processing
*
* @return the boolean
*/
public static boolean isSpringAotProcessing() {
return "true".equalsIgnoreCase(System.getProperty(SPRING_AOT_PROCESSING));
}

/**
* Gets the native-image code.
*
* @return the native-image code
*/
public static String getNativeImageCode() {
return NATIVE_IMAGE_CODE;
}

/**
* Whether run in native-image
*
* @return the boolean
* @see org.springframework.core.NativeDetector#inNativeImage()
*/
public static boolean inNativeImage() {
return NATIVE_IMAGE_CODE != null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
*/
public class EnhancedServiceLoader {

public static final String SERVICES_DIRECTORY = "META-INF/services/";
public static final String SEATA_DIRECTORY = "META-INF/seata/";

/**
* Class->InnerEnhancedServiceLoader map
*/
Expand Down Expand Up @@ -245,8 +248,6 @@ private static ClassLoader findClassLoader() {

private static class InnerEnhancedServiceLoader<S> {
private static final Logger LOGGER = LoggerFactory.getLogger(InnerEnhancedServiceLoader.class);
private static final String SERVICES_DIRECTORY = "META-INF/services/";
private static final String SEATA_DIRECTORY = "META-INF/seata/";

private final Class<S> type;
private final Holder<List<ExtensionDefinition<S>>> definitionsHolder = new Holder<>();
Expand Down Expand Up @@ -555,7 +556,9 @@ private void loadFile(String dir, ClassLoader loader, List<ExtensionDefinition<S

if (LOGGER.isDebugEnabled()) {
if (!hasServiceFile) {
LOGGER.warn("Load [{}] class fail: no service files found in '{}'.", type.getName(), dir);
if (!SEATA_DIRECTORY.equals(dir)) {
LOGGER.warn("Load [{}] class fail: no service files found in '{}'.", type.getName(), dir);
}
} else if (!hasClasses) {
LOGGER.warn("Load [{}] class fail: the service files in '{}' is all empty.", type.getName(), dir);
}
Expand Down
19 changes: 19 additions & 0 deletions common/src/main/java/io/seata/common/util/ReflectionUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,25 @@ public static Class<?> getWrappedClass(Class<?> clazz) {
return clazz;
}

public static boolean isJavaClass(Class<?> clazz) {
return clazz != null && clazz.getClassLoader() == null;
}

/**
* Whether the class exists
*
* @param className the class name
* @return the boolean
*/
public static boolean existsClass(String className) {
try {
getClassByName(className);
return true;
} catch (ClassNotFoundException e) {
return false;
}
}

//endregion


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"resources": {
"includes": [
{
"condition": {
"typeReachable": "io.seata.common.loader.EnhancedServiceLoader"
},
"pattern": "\\QMETA-INF\/services\/io.seata.\\E.*"
},
{
"condition": {
"typeReachable": "io.seata.common.loader.EnhancedServiceLoader"
},
"pattern": "\\QMETA-INF\/seata\/io.seata.\\E.*"
},
{
"condition": {
"typeReachable": "io.seata.common.loader.EnhancedServiceLoader"
},
"pattern": "\\QMETA-INF\/services\/com.alibaba.dubbo.rpc.Filter\\E"
},
{
"condition": {
"typeReachable": "io.seata.common.loader.EnhancedServiceLoader"
},
"pattern": "\\QMETA-INF\/seata\/com.alibaba.dubbo.rpc.Filter\\E"
},
{
"condition": {
"typeReachable": "io.seata.common.loader.EnhancedServiceLoader"
},
"pattern": "\\QMETA-INF\/services\/com.alipay.sofa.rpc.filter.Filter\\E"
},
{
"condition": {
"typeReachable": "io.seata.common.loader.EnhancedServiceLoader"
},
"pattern": "\\QMETA-INF\/seata\/com.alipay.sofa.rpc.filter.Filter\\E"
},
{
"condition": {
"typeReachable": "io.seata.common.loader.EnhancedServiceLoader"
},
"pattern": "\\QMETA-INF\/services\/com.taobao.hsf.invocation.filter.RPCFilter\\E"
},
{
"condition": {
"typeReachable": "io.seata.common.loader.EnhancedServiceLoader"
},
"pattern": "\\QMETA-INF\/seata\/com.taobao.hsf.invocation.filter.RPCFilter\\E"
},
{
"condition": {
"typeReachable": "io.seata.common.loader.EnhancedServiceLoader"
},
"pattern": "\\QMETA-INF\/services\/com.weibo.api.motan.filter.Filter\\E"
},
{
"condition": {
"typeReachable": "io.seata.common.loader.EnhancedServiceLoader"
},
"pattern": "\\QMETA-INF\/seata\/com.weibo.api.motan.filter.Filter\\E"
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[
{
"condition": {
"typeReachable": "io.seata.common.loader.Hello"
},
"name": "io.seata.common.loader.ChineseHello",
"methods": [
{
"name": "<init>",
"parameterTypes": []
}
]
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[
{
"condition": {
"typeReachable": "io.seata.core.compressor.Compressor"
},
"name": "io.seata.compressor.sevenz.SevenZCompressor",
"methods": [
{
"name": "<init>",
"parameterTypes": []
}
]
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[
{
"condition": {
"typeReachable": "io.seata.core.compressor.Compressor"
},
"name": "io.seata.compressor.bzip2.BZip2Compressor",
"methods": [
{
"name": "<init>",
"parameterTypes": []
}
]
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[
{
"condition": {
"typeReachable": "io.seata.core.compressor.Compressor"
},
"name": "io.seata.compressor.deflater.DeflaterCompressor",
"methods": [
{
"name": "<init>",
"parameterTypes": []
}
]
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[
{
"condition": {
"typeReachable": "io.seata.core.compressor.Compressor"
},
"name": "io.seata.compressor.gzip.GzipCompressor",
"methods": [
{
"name": "<init>",
"parameterTypes": []
}
]
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[
{
"condition": {
"typeReachable": "io.seata.core.compressor.Compressor"
},
"name": "io.seata.compressor.lz4.Lz4Compressor",
"methods": [
{
"name": "<init>",
"parameterTypes": []
}
]
}
]
Loading