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

Updates documentation for using Java Agent when building ShardingSphere Proxy Native #29625

Merged
merged 1 commit into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ weight = 10
7. `C` 代表 chronology 的缩写,意为日历系统,必须遵循 Java `java.time.chrono.Chronology#getId()` 的格式。
例如:`Japanese`,`Minguo`,`ThaiBuddhist`。存在默认值为 `ISO`。

对于 `C` 的 Key 对应的 Value 是否可用,这取决于 JVM 所处的系统环境。
这意味着如果用户需要设置 `C=Japanese`,则可能需要在应用的启动类调用 `java.util.Locale.setDefault(java.util.Locale.JAPAN);` 以修改系统环境。
讨论两种 JVM 环境。

1. Hotspot JVM 在 RunTime 决定 `java.util.Locale.getDefault()` 的返回值。

2. GraalVM Native Image 在 BuildTime 决定 `java.util.Locale.Locale.getDefault()` 的返回值,与 Hotspot JVM 的表现并不一致,参考 https://github.com/oracle/graal/issues/8022 。

类型:INTERVAL

用例:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ It must follow the enumeration value of Java `java.time.temporal.ChronoUnit#toSt
7. `C` stands for the abbreviation of chronology, which means calendar system and must follow the format of Java `java.time.chrono.Chronology#getId()`.
For example: `Japanese`, `Minguo`, `ThaiBuddhist`. There is a default value of `ISO`.

Whether the Value corresponding to the Key of `C` is available depends on the system environment in which the JVM is located.
This means that if the user needs to set `C=Japanese`, they may need to call `java.util.Locale.setDefault(java.util.Locale.JAPAN);` in the application's startup class to modify the system environment.
Discuss two JVM environments.

1. Hotspot JVM determines the return value of `java.util.Locale.getDefault()` at RunTime.

2. GraalVM Native Image determines the return value of `java.util.Locale.Locale.getDefault()` at BuildTime, which is inconsistent with the performance of Hotspot JVM.
Refer to https://github.com/oracle/graal/issues/8022 .

Type: INTERVAL

Example:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ Apache ShardingSphere 为不同的运行模式提供了不同的元数据持久

`Consul` 实现的 `serverLists` 属性受设计使然,仅可通过 HTTP 端点连接到单个 Consul Agent。
`serverLists` 使用了宽松的 URL 匹配原则。
1. 当 `serverLists` 为空时,将解析到 `http://localhost:8500` 的 Consul Agent 实例。
2. 当 `serverLists` 为 `hostname` 时,将解析到 `http://hostname:8500` 的 Consul Agent 实例。
3. 当 `serverLists` 为 `hostname:port` 时,将解析到 `http://hostname:port` 的 Consul Agent 实例。
1. 当 `serverLists` 为空时,将解析到 `http://127.0.0.1:8500` 的 Consul Agent 实例。
2. 当 `serverLists` 为 `hostName` 时,将解析到 `http://hostName:8500` 的 Consul Agent 实例。
3. 当 `serverLists` 为 `hostName:port` 时,将解析到 `http://hostName:port` 的 Consul Agent 实例。
4. 当 `serverLists` 为 `http://hostName:port` 时,将解析到 `http://hostName:port` 的 Consul Agent 实例。
5. 当 `serverLists` 为 `https://hostName:port` 时,将解析到 `https://hostName:port` 的 Consul Agent 实例。

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ Due to the limitation of the Maven module of `com.ecwid.consul:consul-api:1.4.5`

The `serverLists` property of the `Consul` implementation is by design and can only be connected to a single Consul Agent via an HTTP endpoint.
`serverLists` uses relaxed URL matching principles.
1. When `serverLists` is empty, the Consul Agent instance at `http://localhost:8500` will be resolved.
2. When `serverLists` is `hostname`, it will be resolved to the Consul Agent instance of `http://hostname:8500`.
3. When `serverLists` is `hostname:port`, it will be resolved to the Consul Agent instance of `http://hostname:port`.
4. When `serverLists` is `http://hostName:port`, the Consul Agent instance of `http://hostName:port` will be resolved.
5. When `serverLists` is `https://hostName:port`, the Consul Agent instance of `https://hostName:port` will be resolved.
1. When `serverLists` is empty, it will be resolved to the Consul Agent instance of `http://127.0.0.1:8500`.
2. When `serverLists` is `hostName`, it will be resolved to the Consul Agent instance of `http://hostName:8500`.
3. When `serverLists` is `hostName:port`, it will be resolved to the Consul Agent instance of `http://hostName:port`.
4. When `serverLists` is `http://hostName:port`, it will be resolved to the Consul Agent instance of `http://hostName:port`.
5. When `serverLists` is `https://hostName:port`, it will be resolved to the Consul Agent instance of `https://hostName:port`.

Type: Consul

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,28 +133,7 @@ services:
及其后继。如果你使用的不是 Linux,则无法对 GraalVM Native Image 进行 Debug,请关注尚未关闭的
https://github.com/oracle/graal/issues/5648 。

- 对于使用 `ShardingSphere Agent` 等 APM Java Agent 的情形, GraalVM 的 `native-image` 组件尚未完全支持在构建 Native
- 对于使用 `ShardingSphere Agent` 等 Java Agent 的情形, GraalVM 的 `native-image` 组件尚未完全支持在构建 Native
Copy link

Choose a reason for hiding this comment

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

PR oracle/graal#8077 can support this scenario as well.

Image 时使用 javaagent,你需要关注尚未关闭的 https://github.com/oracle/graal/issues/1065 。

- 以下部分采用 `Apache SkyWalking Java Agent` 作为示例,可用于跟踪 GraalVM 社区的对应 issue。

1. 下载 https://archive.apache.org/dist/skywalking/java-agent/8.16.0/apache-skywalking-java-agent-8.16.0.tgz ,
并解压到 ShardingSphere Git Source 的 `distribution/proxy-native`。

2. 修改 `distribution/proxy-native/pom.xml` 的 `native profile`,
为 `org.graalvm.buildtools:native-maven-plugin` 的 `configuration` 添加如下的 `jvmArgs`。

```xml

<jvmArgs>
<arg>-Dskywalking.agent.service_name="your service name"</arg>
<arg>-Dskywalking.collector.backend_service="your skywalking oap ip and port"</arg>
<arg>-javaagent:./skywalking-agent/skywalking-agent.jar</arg>
</jvmArgs>
```

3. 通过命令行构建 GraalVM Native Image。

```bash
./mvnw -am -pl distribution/proxy-native -B -T1C -Prelease.native -DskipTests clean package
```
- 若用户期望在 ShardingSphere Proxy Native 下使用 OpenTelemetry Java Agent,则需要关注 https://github.com/oracle/graal/pull/8077 涉及的变动。
Original file line number Diff line number Diff line change
Expand Up @@ -151,23 +151,4 @@ services:
- The following sections use the `Apache SkyWalking Java Agent` as an example, which can be used to track corresponding
issues from the GraalVM community.

1. Download https://archive.apache.org/dist/skywalking/java-agent/8.16.0/apache-skywalking-java-agent-8.16.0.tgz and `untar` it
to `distribution/proxy-native` in ShardingSphere Git Source.

2. Modify the `native profile` of `distribution/proxy-native/pom.xml`,
Add the following `jvmArgs` to the `configuration` of `org.graalvm.buildtools:native-maven-plugin`.

```xml

<jvmArgs>
<arg>-Dskywalking.agent.service_name="your service name"</arg>
<arg>-Dskywalking.collector.backend_service="your skywalking oap ip and port"</arg>
<arg>-javaagent:./skywalking-agent/skywalking-agent.jar</arg>
</jvmArgs>
```

3. Build the GraalVM Native Image from the command line.

```bash
./mvnw -am -pl distribution/proxy-native -B -T1C -Prelease.native -DskipTests clean package
```
- If users expect to use OpenTelemetry Java Agent under ShardingSphere Proxy Native, they need to pay attention to the changes involved in https://github.com/oracle/graal/pull/8077 .