This is an automated email from the ASF dual-hosted git repository.
wanghailin pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/seatunnel.git
The following commit(s) were added to refs/heads/dev by this push:
new 150d30db74 [Fix][Zeta] Set `AsyncLogger.ThreadNameStrategy=UNCACHED`
to avoid thread name cache (#8215)
150d30db74 is described below
commit 150d30db742a5511cc7dfd5de8ec6ffeba16eeab
Author: Jia Fan <[email protected]>
AuthorDate: Fri Dec 6 13:06:52 2024 +0800
[Fix][Zeta] Set `AsyncLogger.ThreadNameStrategy=UNCACHED` to avoid thread
name cache (#8215)
---
pom.xml | 2 +-
.../src/main/bin/seatunnel-cluster.cmd | 2 +-
.../src/main/bin/seatunnel-cluster.sh | 2 +-
.../seatunnel/command/ServerExecuteCommand.java | 37 ++++++++++++++++++++++
.../command/ServerExecuteCommandTest.java | 37 ++++++++++++++++++++++
tools/dependencies/known-dependencies.txt | 2 +-
6 files changed, 78 insertions(+), 4 deletions(-)
diff --git a/pom.xml b/pom.xml
index 24b5e029fb..ee528ff743 100644
--- a/pom.xml
+++ b/pom.xml
@@ -103,7 +103,7 @@
<elasticsearch6.client.version>6.3.1</elasticsearch6.client.version>
<elasticsearch7.client.version>7.5.1</elasticsearch7.client.version>
<flink-shaded-hadoop-2.version>2.7.5-7.0</flink-shaded-hadoop-2.version>
- <commons-lang3.version>3.5</commons-lang3.version>
+ <commons-lang3.version>3.8</commons-lang3.version>
<commons-io.version>2.11.0</commons-io.version>
<commons-collections4.version>4.4</commons-collections4.version>
<commons-csv.version>1.10.0</commons-csv.version>
diff --git
a/seatunnel-core/seatunnel-starter/src/main/bin/seatunnel-cluster.cmd
b/seatunnel-core/seatunnel-starter/src/main/bin/seatunnel-cluster.cmd
index 89327e8e38..8abe993107 100644
--- a/seatunnel-core/seatunnel-starter/src/main/bin/seatunnel-cluster.cmd
+++ b/seatunnel-core/seatunnel-starter/src/main/bin/seatunnel-cluster.cmd
@@ -47,7 +47,7 @@ set "JAVA_OPTS=%JvmOption%"
set "SEATUNNEL_CONFIG=%CONF_DIR%\seatunnel.yaml"
set "JAVA_OPTS=%JAVA_OPTS%
-Dlog4j2.contextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector"
-set "JAVA_OPTS=%JAVA_OPTS% -Dlog4j2.isThreadContextMapInheritable=true"
+set "JAVA_OPTS=%JAVA_OPTS% -Dlog4j2.isThreadContextMapInheritable=true
-DAsyncLogger.ThreadNameStrategy=UNCACHED"
REM Server Debug Config
REM Usage instructions:
diff --git a/seatunnel-core/seatunnel-starter/src/main/bin/seatunnel-cluster.sh
b/seatunnel-core/seatunnel-starter/src/main/bin/seatunnel-cluster.sh
index 565644db22..ed90ddd846 100755
--- a/seatunnel-core/seatunnel-starter/src/main/bin/seatunnel-cluster.sh
+++ b/seatunnel-core/seatunnel-starter/src/main/bin/seatunnel-cluster.sh
@@ -83,7 +83,7 @@ done
# Log4j2 Config
JAVA_OPTS="${JAVA_OPTS}
-Dlog4j2.contextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector"
-JAVA_OPTS="${JAVA_OPTS} -Dlog4j2.isThreadContextMapInheritable=true"
+JAVA_OPTS="${JAVA_OPTS} -Dlog4j2.isThreadContextMapInheritable=true
-DAsyncLogger.ThreadNameStrategy=UNCACHED"
if [ -e "${CONF_DIR}/log4j2.properties" ]; then
JAVA_OPTS="${JAVA_OPTS} -Dhazelcast.logging.type=log4j2
-Dlog4j2.configurationFile=${CONF_DIR}/log4j2.properties"
JAVA_OPTS="${JAVA_OPTS} -Dseatunnel.logs.path=${APP_DIR}/logs"
diff --git
a/seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/command/ServerExecuteCommand.java
b/seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/command/ServerExecuteCommand.java
index 7c47617ce8..8a9d049a21 100644
---
a/seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/command/ServerExecuteCommand.java
+++
b/seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/command/ServerExecuteCommand.java
@@ -25,9 +25,17 @@ import
org.apache.seatunnel.engine.common.config.SeaTunnelConfig;
import org.apache.seatunnel.engine.common.exception.SeaTunnelEngineException;
import org.apache.seatunnel.engine.server.SeaTunnelServerStarter;
+import org.apache.commons.lang3.JavaVersion;
import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.SystemUtils;
+
+import lombok.extern.slf4j.Slf4j;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
/** This command is used to execute the SeaTunnel engine job by SeaTunnel API.
*/
+@Slf4j
public class ServerExecuteCommand implements Command<ServerCommandArgs> {
private final ServerCommandArgs serverCommandArgs;
@@ -38,6 +46,7 @@ public class ServerExecuteCommand implements
Command<ServerCommandArgs> {
@Override
public void execute() {
+ checkEnvironment();
SeaTunnelConfig seaTunnelConfig =
ConfigProvider.locateAndGetSeaTunnelConfig();
String clusterRole = this.serverCommandArgs.getClusterRole();
if (StringUtils.isNotBlank(clusterRole)) {
@@ -60,4 +69,32 @@ public class ServerExecuteCommand implements
Command<ServerCommandArgs> {
SeaTunnelServerStarter.createHazelcastInstance(
seaTunnelConfig, Thread.currentThread().getName());
}
+
+ private void checkEnvironment() {
+ if (isAllocatingThreadGetName()) {
+ log.warn(
+ "The current JDK version is not recommended. Please
upgrade to JDK 1.8.0_102 or higher. "
+ + "The current version will affect the performance
of log printing. "
+ + "For details, please refer to
https://issues.apache.org/jira/browse/LOG4J2-2052");
+ }
+ }
+
+ static boolean isAllocatingThreadGetName() {
+ // LOG4J2-2052, LOG4J2-2635 JDK 8u102 ("1.8.0_102") removed the String
allocation in
+ // Thread.getName()
+ if (SystemUtils.IS_JAVA_1_8) {
+ try {
+ Pattern javaVersionPattern =
Pattern.compile("(\\d+)\\.(\\d+)\\.(\\d+)_(\\d+)");
+ Matcher m =
javaVersionPattern.matcher(System.getProperty("java.version"));
+ if (m.matches()) {
+ return Integer.parseInt(m.group(3)) == 0 &&
Integer.parseInt(m.group(4)) < 102;
+ }
+ return true;
+ } catch (Exception e) {
+ return true;
+ }
+ } else {
+ return !SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_1_8);
+ }
+ }
}
diff --git
a/seatunnel-core/seatunnel-starter/src/test/java/org/apache/seatunnel/core/starter/seatunnel/command/ServerExecuteCommandTest.java
b/seatunnel-core/seatunnel-starter/src/test/java/org/apache/seatunnel/core/starter/seatunnel/command/ServerExecuteCommandTest.java
new file mode 100644
index 0000000000..0962ed5ada
--- /dev/null
+++
b/seatunnel-core/seatunnel-starter/src/test/java/org/apache/seatunnel/core/starter/seatunnel/command/ServerExecuteCommandTest.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.seatunnel.core.starter.seatunnel.command;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.DisabledOnJre;
+import org.junit.jupiter.api.condition.JRE;
+
+public class ServerExecuteCommandTest {
+
+ @Test
+ @DisabledOnJre(value = JRE.JAVA_11, disabledReason = "the test case only
works on Java 8")
+ public void testJavaVersionCheck() {
+ String realVersion = System.getProperty("java.version");
+ System.setProperty("java.version", "1.8.0_191");
+
Assertions.assertFalse(ServerExecuteCommand.isAllocatingThreadGetName());
+ System.setProperty("java.version", "1.8.0_60");
+
Assertions.assertTrue(ServerExecuteCommand.isAllocatingThreadGetName());
+ System.setProperty("java.version", realVersion);
+ }
+}
diff --git a/tools/dependencies/known-dependencies.txt
b/tools/dependencies/known-dependencies.txt
index 62924093d1..ce7d25b445 100755
--- a/tools/dependencies/known-dependencies.txt
+++ b/tools/dependencies/known-dependencies.txt
@@ -2,7 +2,7 @@ commons-codec-1.13.jar
commons-collections4-4.4.jar
commons-compress-1.20.jar
commons-io-2.11.0.jar
-commons-lang3-3.5.jar
+commons-lang3-3.8.jar
commons-csv-1.10.0.jar
config-1.3.3.jar
disruptor-3.4.4.jar