czy006 commented on code in PR #3090:
URL: https://github.com/apache/amoro/pull/3090#discussion_r1714937913
##########
amoro-ams/amoro-ams-server/src/main/java/org/apache/amoro/server/manager/FlinkOptimizerContainer.java:
##########
@@ -266,15 +254,62 @@ protected String buildOptimizerStartupArgsString(Resource
resource) {
jobArgs);
}
+ @VisibleForTesting
+ protected Map<String, String> loadFlinkConfigForYAML(URL path) {
+ this.flinkConfDir = Paths.get(path.getPath()).getParent().toString();
+ return loadFlinkConfig();
+ }
+
+ /**
+ * get flink config with config.yaml or flink-conf.yaml see <a
+ *
href="https://nightlies.apache.org/flink/flink-docs-release-1.20/docs/deployment/config/#flink-configuration-file"></a>
+ *
+ * @return flink config map
+ */
private Map<String, String> loadFlinkConfig() {
try {
- return new Yaml().load(Files.newInputStream(Paths.get(flinkConfDir +
FLINK_CONFIG_YAML)));
- } catch (IOException e) {
+ Path flinkConfPath = Paths.get(flinkConfDir + NEW_FLINK_CONFIG_YAML);
+ if (!Files.exists(flinkConfPath, LinkOption.NOFOLLOW_LINKS)) {
+ flinkConfPath = Paths.get(flinkConfDir + FLINK_CONFIG_YAML);
+ return new Yaml().load(Files.newInputStream(flinkConfPath));
+ }
+ Map<String, Object> configDocument =
+ YamlParserUtils.loadYamlFile(new File(flinkConfPath.toUri()));
+ return Maps.transformValues(
+ flatten(configDocument, ""), value -> value == null ? null :
value.toString());
+ } catch (Exception e) {
LOG.error("load flink conf yaml failed: {}", e.getMessage());
return Collections.emptyMap();
}
}
+ /**
+ * Copy from flink 1.20 GlobalConfiguration.flatten Utils
+ *
+ * @param config
+ * @param keyPrefix
+ * @return
+ */
+ private static Map<String, Object> flatten(Map<String, Object> config,
String keyPrefix) {
Review Comment:
The current implementation is to copy this method from the high version of
Flink for separate maintenance and compatibility with the low version of Flink,
if this method is feasible I will continue to keep this part of the code
WDYT?cc @reswqa @huyuanfeng2018
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]