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 4239884
Show file tree
Hide file tree
Showing 20 changed files with 633 additions and 62 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"]
}
]
Loading

0 comments on commit 4239884

Please sign in to comment.