From 3c7ea80d2c25689ad0221cd7aeb0a1e00cc78d5b Mon Sep 17 00:00:00 2001 From: v_nikeyang <1013195908@qq.com> Date: Fri, 20 Oct 2023 17:08:19 +0800 Subject: [PATCH] fix code review --- .../client/factory/LinkisYarnClusterClientFactory.java | 7 ++++--- .../flink/config/FlinkEnvConfiguration.scala | 4 ++++ .../flink/executor/FlinkJarOnceExecutor.scala | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/linkis-engineconn-plugins/flink/src/main/java/org/apache/linkis/engineconnplugin/flink/client/factory/LinkisYarnClusterClientFactory.java b/linkis-engineconn-plugins/flink/src/main/java/org/apache/linkis/engineconnplugin/flink/client/factory/LinkisYarnClusterClientFactory.java index 384bab8cc9..fefb48d1a4 100644 --- a/linkis-engineconn-plugins/flink/src/main/java/org/apache/linkis/engineconnplugin/flink/client/factory/LinkisYarnClusterClientFactory.java +++ b/linkis-engineconn-plugins/flink/src/main/java/org/apache/linkis/engineconnplugin/flink/client/factory/LinkisYarnClusterClientFactory.java @@ -39,6 +39,7 @@ import java.util.List; import java.util.Optional; +import org.apache.linkis.engineconnplugin.flink.config.FlinkEnvConfiguration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -66,13 +67,13 @@ private void initYarnClient(Configuration configuration) { String configurationDirectory = configuration.get(DeploymentOptionsInternal.CONF_DIR); List paths = configuration.get(YarnConfigOptions.SHIP_FILES); Optional firstLog4jPath = - paths.stream().filter(path -> path.contains("log4j.properties")).findFirst(); + paths.stream().filter(path -> path.contains(FlinkEnvConfiguration.FLINK_CONSTANT_CONFIGURATION().getValue())).findFirst(); if (firstLog4jPath.isPresent()) { Path parentAbsolutePath = Paths.get(firstLog4jPath.get()).toAbsolutePath().getParent(); configurationDirectory = parentAbsolutePath.toString(); - LOG.info("log4j.properties路径:" + configurationDirectory); + LOG.info(FlinkEnvConfiguration.FLINK_CONSTANT_CONFIGURATION().getValue()+ "path:" + configurationDirectory); } else { - LOG.info("未找到匹配的路径使用系统默认路径:" + configurationDirectory); + LOG.info("No matching path found,Use system default path :" + configurationDirectory); } YarnLogConfigUtil.setLogConfigFileInConfig(configuration, configurationDirectory); String yarnConfDir = configuration.getString(YARN_CONFIG_DIR); diff --git a/linkis-engineconn-plugins/flink/src/main/scala/org/apache/linkis/engineconnplugin/flink/config/FlinkEnvConfiguration.scala b/linkis-engineconn-plugins/flink/src/main/scala/org/apache/linkis/engineconnplugin/flink/config/FlinkEnvConfiguration.scala index 4077d70042..be4898dcca 100644 --- a/linkis-engineconn-plugins/flink/src/main/scala/org/apache/linkis/engineconnplugin/flink/config/FlinkEnvConfiguration.scala +++ b/linkis-engineconn-plugins/flink/src/main/scala/org/apache/linkis/engineconnplugin/flink/config/FlinkEnvConfiguration.scala @@ -145,4 +145,8 @@ object FlinkEnvConfiguration { val FLINK_ENV_JAVA_OPTS = CommonVars("flink.env.java.opts", "env.java.opts") + + val FLINK_CONSTANT_CONFIGURATION = + CommonVars("flink.constant.configuration", "log4j.properties") + } diff --git a/linkis-engineconn-plugins/flink/src/main/scala/org/apache/linkis/engineconnplugin/flink/executor/FlinkJarOnceExecutor.scala b/linkis-engineconn-plugins/flink/src/main/scala/org/apache/linkis/engineconnplugin/flink/executor/FlinkJarOnceExecutor.scala index c9a57850f4..37bc7c09e4 100644 --- a/linkis-engineconn-plugins/flink/src/main/scala/org/apache/linkis/engineconnplugin/flink/executor/FlinkJarOnceExecutor.scala +++ b/linkis-engineconn-plugins/flink/src/main/scala/org/apache/linkis/engineconnplugin/flink/executor/FlinkJarOnceExecutor.scala @@ -77,7 +77,7 @@ class FlinkJarOnceExecutor( configMap.load(Files.newBufferedReader(Paths.get(log4jPath))) } catch { case e: Exception => - logger.error("读取或解析文件时出现错误: " + e.getMessage) + logger.error("error occurred while reading or parsing the file: " + e.getMessage) } val ecOptions = onceExecutorExecutionContext.getEngineCreationContext.getOptions LINKIS_FLINK_LOG4J_CHECK_KEYWORDS.getValue(ecOptions).split(",").foreach {