Skip to content

Commit

Permalink
fix code review
Browse files Browse the repository at this point in the history
  • Loading branch information
yangwenzea committed Oct 20, 2023
1 parent e4780b5 commit 3c7ea80
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -66,13 +67,13 @@ private void initYarnClient(Configuration configuration) {
String configurationDirectory = configuration.get(DeploymentOptionsInternal.CONF_DIR);
List<String> paths = configuration.get(YarnConfigOptions.SHIP_FILES);
Optional<String> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")

}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 3c7ea80

Please sign in to comment.