Skip to content

Commit

Permalink
Provides built-in GraalVM Reachability Metadata and nativeTest on Ela…
Browse files Browse the repository at this point in the history
…sticjob Spring Boot Starter under Spring Boot 3.2.8
  • Loading branch information
linghengqian committed Aug 10, 2024
1 parent 5334fc4 commit de2f3c5
Show file tree
Hide file tree
Showing 20 changed files with 580 additions and 60 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/graalvm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,15 @@ jobs:
os: [ 'ubuntu-latest' ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up GraalVM CE ${{ matrix.java }}
uses: graalvm/setup-graalvm@v1
with:
java-version: ${{ matrix.java }}
distribution: 'graalvm-community'
github-token: ${{ secrets.GITHUB_TOKEN }}
cache: 'maven'
native-image-job-reports: 'true'
- name: Run nativeTest with GraalVM CE for ${{ matrix.java-version }}
continue-on-error: true
run: ./mvnw -PnativeTestInElasticJob -T1C -B -e clean test
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
/**
* One off job bootstrap.
*/
public final class OneOffJobBootstrap implements JobBootstrap {
public class OneOffJobBootstrap implements JobBootstrap {

private final JobScheduler jobScheduler;

Expand Down
23 changes: 21 additions & 2 deletions docs/content/user-manual/configuration/graalvm-native-image.cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,29 @@ graalvmNative {
`script.command.line` 设置为构建 GraalVM Native Image 时, 私有项目的 classpath 下的某个 `.sh` 文件在 GraalVM Native Image 下的相对路径,
则此 `.sh` 文件至少提前设置 `rwxr-xr-x` 的 POSIX 文件权限。
因为 `com.oracle.svm.core.jdk.resources.NativeImageResourceFileSystem` 显然不支持 `java.nio.file.attribute.PosixFileAttributeView`
长话短说,用户应该避免在作业内包含类似如下的逻辑,

```java
import java.io.IOException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.PosixFilePermissions;

public class ExampleUtils {
public void setPosixFilePermissions() throws IOException {
URL resource = ExampleUtils.class.getResource("/script/demo.sh");
assert resource != null;
Path path = Paths.get(resource.getPath());
Files.setPosixFilePermissions(path, PosixFilePermissions.fromString("rwxr-xr-x"));
}
}
```

3. ElasticJob 的 Spring 命名空间集成模块 `org.apache.shardingsphere.elasticjob:elasticjob-spring-namespace` 尚未在 GraalVM Native Image 下可用。
3. `企业微信通知策略``钉钉通知策略``邮件通知策略`尚未在 GraalVM Native Image 下可用。

4. ElasticJob 的 Spring Boot Starter 集成模块 `org.apache.shardingsphere.elasticjob:elasticjob-spring-boot-starter` 尚未在 GraalVM Native Image 下可用。
4. ElasticJob 的 Spring 命名空间集成模块 `org.apache.shardingsphere.elasticjob:elasticjob-spring-namespace` 尚未在 GraalVM Native Image 下可用。

## 贡献 GraalVM Reachability Metadata

Expand Down
23 changes: 21 additions & 2 deletions docs/content/user-manual/configuration/graalvm-native-image.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,29 @@ Users can quickly collect GraalVM Reachability Metadata through the GraalVM Trac
if `script.command.line` is set to the relative path of a `.sh` file in the private project's classpath under the GraalVM Native Image when building the GraalVM Native Image,
then the `.sh` file must at least have the POSIX file permission of `rwxr-xr-x` set in advance.
This is because `com.oracle.svm.core.jdk.resources.NativeImageResourceFileSystem` obviously does not support `java.nio.file.attribute.PosixFileAttributeView`.
Long story short, users should avoid including logic like the following in their jobs,

```java
import java.io.IOException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.PosixFilePermissions;

public class ExampleUtils {
public void setPosixFilePermissions() throws IOException {
URL resource = ExampleUtils.class.getResource("/script/demo.sh");
assert resource != null;
Path path = Paths.get(resource.getPath());
Files.setPosixFilePermissions(path, PosixFilePermissions.fromString("rwxr-xr-x"));
}
}
```

3. The Spring namespace integration module `org.apache.shardingsphere.elasticjob:elasticjob-spring-namespace` of ElasticJob is not yet available under GraalVM Native Image.
3. `WeCom Notification Policy`, `DingTalk Notification Policy`, and `Email Notification Policy` are not yet available in GraalVM Native Image.

4. The Spring Boot Starter integration module `org.apache.shardingsphere.elasticjob:elasticjob-spring-boot-starter` for ElasticJob is not yet available under GraalVM Native Image.
4. The Spring namespace integration module `org.apache.shardingsphere.elasticjob:elasticjob-spring-namespace` of ElasticJob is not yet available under GraalVM Native Image.

## Contribute GraalVM Reachability Metadata

Expand Down
16 changes: 16 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@
<h2.version>2.2.224</h2.version>
<hikari-cp.version>4.0.3</hikari-cp.version>

<!-- For nativeTest under GraalVM Native Image -->
<spring-boot-dependencies.version>3.2.8</spring-boot-dependencies.version>

<!-- Compile plugin versions -->
<maven-enforcer-plugin.version>3.2.1</maven-enforcer-plugin.version>
<maven-compiler-plugin.version>3.11.0</maven-compiler-plugin.version>
Expand Down Expand Up @@ -1015,6 +1018,19 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot-dependencies.version}</version>
<executions>
<execution>
<id>process-test-aot</id>
<goals>
<goal>process-test-aot</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"condition":{"typeReachable":"org.apache.shardingsphere.elasticjob.tracing.rdb.storage.converter.RDBTracingStorageConfigurationConverter"},
"condition":{"typeReachable":"org.apache.shardingsphere.elasticjob.spring.boot.tracing.ElasticJobTracingConfiguration$RDBTracingConfiguration"},
"interfaces":["java.sql.Connection"]
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
"name":"[Lcom.zaxxer.hikari.util.ConcurrentBag$IConcurrentBagEntry;"
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.elasticjob.bootstrap.type.ScheduleJobBootstrap"},
"name":"java.util.Properties",
"methods":[{"name":"<init>","parameterTypes":[] }]
"condition":{"typeReachable":"org.apache.shardingsphere.elasticjob.spring.boot.tracing.ElasticJobTracingConfiguration$RDBTracingConfiguration"},
"name":"[Ljava.sql.Statement;"
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.elasticjob.kernel.executor.ElasticJobExecutor"},
Expand All @@ -23,11 +22,26 @@
"name":"java.util.Properties",
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.elasticjob.kernel.internal.sharding.ShardingListenerManager$ListenServersChangedJobListener"},
"name":"java.util.Properties",
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.elasticjob.kernel.internal.sharding.ShardingListenerManager$ShardingTotalCountChangedJobListener"},
"name":"java.util.Properties",
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.elasticjob.bootstrap.type.OneOffJobBootstrap$$SpringCGLIB$$0"},
"name":"org.apache.shardingsphere.elasticjob.bootstrap.type.OneOffJobBootstrap",
"queryAllDeclaredMethods":true,
"methods":[{"name":"execute","parameterTypes":[] }, {"name":"shutdown","parameterTypes":[] }]
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.elasticjob.bootstrap.type.OneOffJobBootstrap$$SpringCGLIB$$0"},
"name":"org.apache.shardingsphere.elasticjob.bootstrap.type.OneOffJobBootstrap$$SpringCGLIB$$0"
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.elasticjob.kernel.executor.item.JobItemExecutorFactory"},
"name":"org.apache.shardingsphere.elasticjob.dataflow.executor.DataflowJobExecutor"
Expand All @@ -48,7 +62,7 @@
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.elasticjob.kernel.executor.ElasticJobExecutor"},
"condition":{"typeReachable":"org.apache.shardingsphere.elasticjob.spring.boot.job.ElasticJobBootstrapConfiguration"},
"name":"org.apache.shardingsphere.elasticjob.http.executor.HttpJobExecutor"
},
{
Expand All @@ -59,21 +73,15 @@
"condition":{"typeReachable":"org.apache.shardingsphere.elasticjob.kernel.executor.threadpool.ExecutorServiceReloader"},
"name":"org.apache.shardingsphere.elasticjob.kernel.executor.threadpool.type.SingleThreadJobExecutorThreadPoolSizeProvider"
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.elasticjob.bootstrap.type.OneOffJobBootstrap"},
"name":"org.apache.shardingsphere.elasticjob.kernel.internal.config.JobConfigurationPOJO",
"queryAllPublicMethods":true
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.elasticjob.bootstrap.type.ScheduleJobBootstrap"},
"name":"org.apache.shardingsphere.elasticjob.kernel.internal.config.JobConfigurationPOJO",
"queryAllPublicMethods":true,
"methods":[{"name":"setCron","parameterTypes":["java.lang.String"] }, {"name":"setProps","parameterTypes":["java.util.Properties"] }]
"methods":[{"name":"setCron","parameterTypes":["java.lang.String"] }]
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.elasticjob.kernel.executor.ElasticJobExecutor"},
"name":"org.apache.shardingsphere.elasticjob.kernel.internal.config.JobConfigurationPOJO",
"methods":[{"name":"setCron","parameterTypes":["java.lang.String"] }, {"name":"setProps","parameterTypes":["java.util.Properties"] }]
"methods":[{"name":"setProps","parameterTypes":["java.util.Properties"] }]
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.elasticjob.kernel.infra.yaml.YamlEngine"},
Expand All @@ -98,15 +106,20 @@
"methods":[{"name":"setCron","parameterTypes":["java.lang.String"] }, {"name":"setProps","parameterTypes":["java.util.Properties"] }]
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.elasticjob.kernel.internal.schedule.JobScheduler"},
"condition":{"typeReachable":"org.apache.shardingsphere.elasticjob.kernel.internal.sharding.ShardingListenerManager$ListenServersChangedJobListener"},
"name":"org.apache.shardingsphere.elasticjob.kernel.internal.config.JobConfigurationPOJO",
"queryAllPublicMethods":true
"methods":[{"name":"setCron","parameterTypes":["java.lang.String"] }, {"name":"setProps","parameterTypes":["java.util.Properties"] }]
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.elasticjob.kernel.internal.sharding.ShardingListenerManager$ShardingTotalCountChangedJobListener"},
"name":"org.apache.shardingsphere.elasticjob.kernel.internal.config.JobConfigurationPOJO",
"methods":[{"name":"setCron","parameterTypes":["java.lang.String"] }, {"name":"setProps","parameterTypes":["java.util.Properties"] }]
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.elasticjob.spring.boot.job.ElasticJobBootstrapConfiguration"},
"name":"org.apache.shardingsphere.elasticjob.kernel.internal.config.JobConfigurationPOJO",
"queryAllPublicMethods":true
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.elasticjob.bootstrap.type.ScheduleJobBootstrap"},
"name":"org.apache.shardingsphere.elasticjob.kernel.internal.config.JobConfigurationPOJOBeanInfo"
Expand All @@ -115,22 +128,20 @@
"condition":{"typeReachable":"org.apache.shardingsphere.elasticjob.bootstrap.type.ScheduleJobBootstrap"},
"name":"org.apache.shardingsphere.elasticjob.kernel.internal.config.JobConfigurationPOJOCustomizer"
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.elasticjob.bootstrap.type.OneOffJobBootstrap"},
"name":"org.apache.shardingsphere.elasticjob.kernel.internal.schedule.JobShutdownHookPlugin",
"queryAllPublicMethods":true
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.elasticjob.bootstrap.type.ScheduleJobBootstrap"},
"name":"org.apache.shardingsphere.elasticjob.kernel.internal.schedule.JobShutdownHookPlugin",
"queryAllPublicMethods":true
"name":"org.apache.shardingsphere.elasticjob.kernel.internal.schedule.JobShutdownHookPlugin"
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.elasticjob.kernel.internal.schedule.JobScheduler"},
"name":"org.apache.shardingsphere.elasticjob.kernel.internal.schedule.JobShutdownHookPlugin",
"queryAllPublicMethods":true,
"methods":[{"name":"<init>","parameterTypes":[] }, {"name":"setCleanShutdown","parameterTypes":["boolean"] }]
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.elasticjob.spring.boot.job.ElasticJobBootstrapConfiguration"},
"name":"org.apache.shardingsphere.elasticjob.kernel.internal.schedule.JobShutdownHookPlugin",
"queryAllPublicMethods":true
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.elasticjob.bootstrap.type.ScheduleJobBootstrap"},
"name":"org.apache.shardingsphere.elasticjob.kernel.internal.schedule.JobShutdownHookPluginBeanInfo"
Expand All @@ -139,15 +150,9 @@
"condition":{"typeReachable":"org.apache.shardingsphere.elasticjob.bootstrap.type.ScheduleJobBootstrap"},
"name":"org.apache.shardingsphere.elasticjob.kernel.internal.schedule.JobShutdownHookPluginCustomizer"
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.elasticjob.bootstrap.type.OneOffJobBootstrap"},
"name":"org.apache.shardingsphere.elasticjob.kernel.internal.sharding.JobInstance",
"queryAllPublicMethods":true
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.elasticjob.bootstrap.type.ScheduleJobBootstrap"},
"name":"org.apache.shardingsphere.elasticjob.kernel.internal.sharding.JobInstance",
"queryAllPublicMethods":true
"name":"org.apache.shardingsphere.elasticjob.kernel.internal.sharding.JobInstance"
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.elasticjob.kernel.internal.instance.InstanceNode"},
Expand All @@ -156,18 +161,10 @@
"methods":[{"name":"getJobInstanceId","parameterTypes":[] }, {"name":"getLabels","parameterTypes":[] }, {"name":"getServerIp","parameterTypes":[] }]
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.elasticjob.kernel.internal.instance.InstanceService"},
"name":"org.apache.shardingsphere.elasticjob.kernel.internal.sharding.JobInstance"
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.elasticjob.kernel.internal.schedule.JobScheduler"},
"condition":{"typeReachable":"org.apache.shardingsphere.elasticjob.spring.boot.job.ElasticJobBootstrapConfiguration"},
"name":"org.apache.shardingsphere.elasticjob.kernel.internal.sharding.JobInstance",
"queryAllPublicMethods":true
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.elasticjob.kernel.internal.setup.SetUpFacade"},
"name":"org.apache.shardingsphere.elasticjob.kernel.internal.sharding.JobInstance"
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.elasticjob.bootstrap.type.ScheduleJobBootstrap"},
"name":"org.apache.shardingsphere.elasticjob.kernel.internal.sharding.JobInstanceBeanInfo"
Expand All @@ -191,25 +188,29 @@
"name":"org.apache.shardingsphere.elasticjob.reg.zookeeper.exception.ZookeeperCuratorIgnoredExceptionProvider"
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.elasticjob.kernel.executor.ElasticJobExecutor"},
"condition":{"typeReachable":"org.apache.shardingsphere.elasticjob.spring.boot.job.ElasticJobBootstrapConfiguration"},
"name":"org.apache.shardingsphere.elasticjob.script.executor.ScriptJobExecutor"
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.elasticjob.kernel.executor.item.JobItemExecutorFactory"},
"name":"org.apache.shardingsphere.elasticjob.simple.executor.SimpleJobExecutor"
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.elasticjob.kernel.tracing.event.JobTracingEventBus"},
"condition":{"typeReachable":"org.apache.shardingsphere.elasticjob.spring.boot.job.ElasticJobBootstrapConfiguration"},
"name":"org.apache.shardingsphere.elasticjob.spi.tracing.listener.TracingListener",
"queryAllDeclaredMethods":true
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.elasticjob.kernel.tracing.event.JobTracingEventBus"},
"condition":{"typeReachable":"org.apache.shardingsphere.elasticjob.kernel.internal.setup.JobClassNameProviderFactory"},
"name":"org.apache.shardingsphere.elasticjob.spring.core.setup.SpringProxyJobClassNameProvider"
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.elasticjob.spring.boot.job.ElasticJobBootstrapConfiguration"},
"name":"org.apache.shardingsphere.elasticjob.tracing.rdb.listener.RDBTracingListener",
"queryAllDeclaredMethods":true
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.elasticjob.kernel.tracing.event.JobTracingEventBus"},
"condition":{"typeReachable":"org.apache.shardingsphere.elasticjob.spring.boot.job.ElasticJobBootstrapConfiguration"},
"name":"org.apache.shardingsphere.elasticjob.tracing.rdb.listener.RDBTracingListenerFactory"
},
{
Expand Down
Loading

0 comments on commit de2f3c5

Please sign in to comment.