zhuzhurk commented on code in PR #24185:
URL: https://github.com/apache/flink/pull/24185#discussion_r1465198985
##########
flink-runtime/src/main/java/org/apache/flink/runtime/util/ConfigurationParserUtils.java:
##########
@@ -212,4 +217,59 @@ public static List<String>
loadAndModifyConfiguration(String[] args, String cmdL
return ConfigurationUtils.convertConfigToWritableLines(
configuration, modifiableClusterConfiguration.flattenConfig());
}
+
+ public static List<String> migrateLegacyConfigurationToStandardYaml(
+ String[] args, String cmdLineSyntax) throws FlinkParseException {
+ final CommandLineParser<ClusterConfiguration> commandLineParser =
+ new CommandLineParser<>(new
ClusterConfigurationParserFactory());
+
+ final ClusterConfiguration clusterConfiguration;
+
+ try {
+ clusterConfiguration = commandLineParser.parse(args);
+ } catch (FlinkParseException e) {
+ LOG.error("Could not parse the command line options.", e);
+ commandLineParser.printHelp(cmdLineSyntax);
+ throw e;
+ }
+
+ checkState(
+ new File(
+ clusterConfiguration.getConfigDir(),
+ GlobalConfiguration.LEGACY_FLINK_CONF_FILENAME)
+ .exists());
+ Configuration configuration =
+
GlobalConfiguration.loadConfiguration(clusterConfiguration.getConfigDir(),
null);
+
+ Configuration standardYamlConfig = new Configuration(true);
+ standardYamlConfig.addAll(configuration);
+
+ // Below config options type is String or List<String>, but it will be
used as Collection
+ // type, so we should explicitly reset the value
+ configuration
Review Comment:
Is this really needed?
It's weird that we have to handle some of the config options in a special
way.
##########
flink-dist/src/main/flink-bin/bin/migrate-config-tool.sh:
##########
@@ -0,0 +1,41 @@
+#!/usr/bin/env bash
+################################################################################
+# 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.
+################################################################################
+
+USAGE="Usage: migrate-config-tool.sh FLINK_CONF_DIR FLINK_BIN_DIR
FLINK_LIB_DIR"
Review Comment:
I prefer to name it as `migrate-config-file.sh`.
`FLINK_CONF_DIR` and `FLINK_BIN_DIR` and `FLINK_LIB_DIR` should be
automatically decided for ease of use.
Optionally, we may make it to accept the legacy file path as a param.
##########
flink-dist/src/test/resources/flink-conf.yaml:
##########
@@ -0,0 +1,311 @@
+################################################################################
+# 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.
+################################################################################
+
+# These parameters are required for Java 17 support.
Review Comment:
Looks to me most of the lines are not needed. Let's avoid adding them.
##########
flink-dist/src/test/java/org/apache/flink/dist/BashJavaUtilsITCase.java:
##########
@@ -133,6 +133,46 @@ void testGetConfiguration() throws Exception {
assertThat(lines).hasSize(expectedResultLines);
}
+ @Test
+ void testMigrateLegacyConfigToStandardYaml() throws Exception {
+ int expectedResultLines = 26;
+ String[] commands = {
+ RUN_BASH_JAVA_UTILS_CMD_SCRIPT,
+
BashJavaUtils.Command.MIGRATE_LEGACY_FLINK_CONFIGURATION_TO_STANDARD_YAML.toString(),
+ String.valueOf(expectedResultLines)
+ };
+ List<String> lines =
Arrays.asList(executeScript(commands).split(System.lineSeparator()));
+ assertThat(lines)
Review Comment:
Is it possible that the result be unstable and make the test unstable? e.g.
keys are organized in a different order.
--
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]