czy006 commented on code in PR #3090:
URL: https://github.com/apache/amoro/pull/3090#discussion_r1714711685


##########
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:
   It is worth noting that their implementation is completely different. There 
is new YAML file processing logic in the new version, so we may have 
inconsistent behavior on different versions
   
   - 
[FLINK-1.15](https://github.com/apache/flink/blob/release-1.15.1/flink-core/src/main/java/org/apache/flink/configuration/GlobalConfiguration.java#L105)
   - 
[FLINK-1.20](https://github.com/apache/flink/blob/release-1.20.0/flink-core/src/main/java/org/apache/flink/configuration/GlobalConfiguration.java#L99)
   
   cc @huyuanfeng2018 @reswqa 
   
   



-- 
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]

Reply via email to