Skip to content

Commit 0e9ab54

Browse files
committed
feat: pass -Dtsfile.locale=zh to JVM under with-zh-locale build
TsFile (apache/tsfile#820) selects its message locale at runtime via the -Dtsfile.locale system property. Wire IoTDB's with-zh-locale build to emit a filtered conf/iotdb-locale.{sh,bat} that the env scripts source on startup, appending -Dtsfile.locale=zh to IOTDB_JMX_OPTS / CONFIGNODE_JMX_OPTS so packaged Chinese builds also get Chinese log/exception messages from tsfile.
1 parent a37621b commit 0e9ab54

13 files changed

Lines changed: 154 additions & 0 deletions

File tree

distribution/src/assembly/all.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,21 @@
6464
<excludes>
6565
<exclude>ainode-env.*</exclude>
6666
<exclude>**/ainode-env.*</exclude>
67+
<exclude>iotdb-locale.*</exclude>
68+
<exclude>**/iotdb-locale.*</exclude>
6769
</excludes>
6870
<fileMode>0755</fileMode>
6971
</fileSet>
72+
<fileSet>
73+
<outputDirectory>conf</outputDirectory>
74+
<directory>${project.basedir}/../scripts/conf</directory>
75+
<includes>
76+
<include>iotdb-locale.sh</include>
77+
<include>windows/iotdb-locale.bat</include>
78+
</includes>
79+
<filtered>true</filtered>
80+
<fileMode>0755</fileMode>
81+
</fileSet>
7082
<fileSet>
7183
<outputDirectory>sbin</outputDirectory>
7284
<directory>${project.basedir}/../scripts/sbin</directory>

distribution/src/assembly/confignode.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,16 @@
5555
</includes>
5656
<fileMode>0755</fileMode>
5757
</fileSet>
58+
<fileSet>
59+
<directory>${project.basedir}/../scripts/conf</directory>
60+
<outputDirectory>conf</outputDirectory>
61+
<includes>
62+
<include>iotdb-locale.sh</include>
63+
<include>windows/iotdb-locale.bat</include>
64+
</includes>
65+
<filtered>true</filtered>
66+
<fileMode>0755</fileMode>
67+
</fileSet>
5868
<fileSet>
5969
<directory>${project.basedir}/../scripts/sbin</directory>
6070
<outputDirectory>sbin</outputDirectory>

distribution/src/assembly/datanode.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,16 @@
5151
</includes>
5252
<fileMode>0755</fileMode>
5353
</fileSet>
54+
<fileSet>
55+
<directory>${project.basedir}/../scripts/conf</directory>
56+
<outputDirectory>conf</outputDirectory>
57+
<includes>
58+
<include>iotdb-locale.sh</include>
59+
<include>windows/iotdb-locale.bat</include>
60+
</includes>
61+
<filtered>true</filtered>
62+
<fileMode>0755</fileMode>
63+
</fileSet>
5464
<fileSet>
5565
<directory>${project.basedir}/../scripts/sbin</directory>
5666
<outputDirectory>sbin</outputDirectory>

integration-test/src/assembly/mpp-test.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,20 @@
4949
<fileSet>
5050
<outputDirectory>conf</outputDirectory>
5151
<directory>${project.basedir}/../scripts/conf</directory>
52+
<excludes>
53+
<exclude>iotdb-locale.*</exclude>
54+
<exclude>**/iotdb-locale.*</exclude>
55+
</excludes>
56+
<fileMode>0755</fileMode>
57+
</fileSet>
58+
<fileSet>
59+
<outputDirectory>conf</outputDirectory>
60+
<directory>${project.basedir}/../scripts/conf</directory>
61+
<includes>
62+
<include>iotdb-locale.sh</include>
63+
<include>windows/iotdb-locale.bat</include>
64+
</includes>
65+
<filtered>true</filtered>
5266
<fileMode>0755</fileMode>
5367
</fileSet>
5468
<fileSet>

iotdb-core/confignode/src/assembly/confignode.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@
4545
</includes>
4646
<fileMode>0755</fileMode>
4747
</fileSet>
48+
<fileSet>
49+
<directory>${project.basedir}/../../scripts/conf</directory>
50+
<outputDirectory>conf</outputDirectory>
51+
<includes>
52+
<include>iotdb-locale.sh</include>
53+
<include>windows/iotdb-locale.bat</include>
54+
</includes>
55+
<filtered>true</filtered>
56+
<fileMode>0755</fileMode>
57+
</fileSet>
4858
<fileSet>
4959
<directory>${project.basedir}/../../scripts/sbin</directory>
5060
<outputDirectory>sbin</outputDirectory>

iotdb-core/datanode/src/assembly/server.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@
4545
</includes>
4646
<fileMode>0755</fileMode>
4747
</fileSet>
48+
<fileSet>
49+
<directory>${project.basedir}/../../scripts/conf</directory>
50+
<outputDirectory>conf</outputDirectory>
51+
<includes>
52+
<include>iotdb-locale.sh</include>
53+
<include>windows/iotdb-locale.bat</include>
54+
</includes>
55+
<filtered>true</filtered>
56+
<fileMode>0755</fileMode>
57+
</fileSet>
4858
<fileSet>
4959
<directory>${project.basedir}/../../scripts/sbin</directory>
5060
<outputDirectory>sbin</outputDirectory>

pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@
166166
<zstd-jni.version>1.5.6-3</zstd-jni.version>
167167
<tsfile.version>2.3.0-260422-SNAPSHOT</tsfile.version>
168168
<i18n.locale>en</i18n.locale>
169+
<tsfile.locale.opt></tsfile.locale.opt>
169170
</properties>
170171
<!--
171172
if we claim dependencies in dependencyManagement, then we do not claim
@@ -2026,6 +2027,7 @@
20262027
<id>with-zh-locale</id>
20272028
<properties>
20282029
<i18n.locale>zh</i18n.locale>
2030+
<tsfile.locale.opt>-Dtsfile.locale=zh</tsfile.locale.opt>
20292031
</properties>
20302032
</profile>
20312033
</profiles>

scripts/conf/confignode-env.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,16 @@ if [[ ! "$CONFIGNODE_JMX_OPTS" =~ -XX:MaxDirectMemorySize ]]; then CONFIGNODE_JM
321321
CONFIGNODE_JMX_OPTS="$CONFIGNODE_JMX_OPTS -Djdk.nio.maxCachedBufferSize=${MAX_CACHED_BUFFER_SIZE}"
322322
CONFIGNODE_JMX_OPTS="$CONFIGNODE_JMX_OPTS -XX:+CrashOnOutOfMemoryError"
323323
CONFIGNODE_JMX_OPTS="$CONFIGNODE_JMX_OPTS -Dsun.jnu.encoding=UTF-8 -Dfile.encoding=UTF-8"
324+
325+
# Apply tsfile locale option populated by Maven at package time
326+
# (see conf/iotdb-locale.sh; empty in default build, "-Dtsfile.locale=zh" under with-zh-locale).
327+
if [ -f "${CONFIGNODE_CONF}/iotdb-locale.sh" ]; then
328+
. "${CONFIGNODE_CONF}/iotdb-locale.sh"
329+
if [ -n "$TSFILE_LOCALE_JVM_OPT" ]; then
330+
CONFIGNODE_JMX_OPTS="$CONFIGNODE_JMX_OPTS $TSFILE_LOCALE_JVM_OPT"
331+
fi
332+
fi
333+
324334
# if you want to dump the heap memory while OOM happening, you can use the following command, remember to replace ${heap_dump_dir}/confignode_heapdump.hprof with your own file path and the folder where this file is located needs to be created in advance
325335
#CONFIGNODE_JMX_OPTS="$CONFIGNODE_JMX_OPTS -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=${heap_dump_dir}/confignode_heapdump.hprof"
326336

scripts/conf/datanode-env.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,15 @@ IOTDB_JMX_OPTS="$IOTDB_JMX_OPTS -XX:SafepointTimeoutDelay=1000"
339339
IOTDB_JMX_OPTS="$IOTDB_JMX_OPTS -XX:+SafepointTimeout"
340340
IOTDB_JMX_OPTS="$IOTDB_JMX_OPTS -Dsun.jnu.encoding=UTF-8 -Dfile.encoding=UTF-8"
341341

342+
# Apply tsfile locale option populated by Maven at package time
343+
# (see conf/iotdb-locale.sh; empty in default build, "-Dtsfile.locale=zh" under with-zh-locale).
344+
if [ -f "${IOTDB_CONF}/iotdb-locale.sh" ]; then
345+
. "${IOTDB_CONF}/iotdb-locale.sh"
346+
if [ -n "$TSFILE_LOCALE_JVM_OPT" ]; then
347+
IOTDB_JMX_OPTS="$IOTDB_JMX_OPTS $TSFILE_LOCALE_JVM_OPT"
348+
fi
349+
fi
350+
342351
# option below tries to optimize safepoint stw time for large counted loop.
343352
# NOTE: it may have an impact on JIT's black-box optimization.
344353
# IOTDB_JMX_OPTS="$IOTDB_JMX_OPTS -XX:+UseCountedLoopSafepoints"

scripts/conf/iotdb-locale.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one
4+
# or more contributor license agreements. See the NOTICE file
5+
# distributed with this work for additional information
6+
# regarding copyright ownership. The ASF licenses this file
7+
# to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance
9+
# with the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing,
14+
# software distributed under the License is distributed on an
15+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
# KIND, either express or implied. See the License for the
17+
# specific language governing permissions and limitations
18+
# under the License.
19+
#
20+
21+
# JVM option for selecting tsfile's runtime locale (log/exception messages).
22+
# This file is filtered by Maven at package time:
23+
# - Default build: TSFILE_LOCALE_JVM_OPT is empty (English).
24+
# - `with-zh-locale` profile: TSFILE_LOCALE_JVM_OPT="-Dtsfile.locale=zh".
25+
TSFILE_LOCALE_JVM_OPT="@tsfile.locale.opt@"

0 commit comments

Comments
 (0)