PatrickRen commented on a change in pull request #16949: URL: https://github.com/apache/flink/pull/16949#discussion_r694464061
########## File path: docs/content.zh/docs/dev/datastream/application_parameters.md ########## @@ -24,28 +24,23 @@ specific language governing permissions and limitations under the License. --> -# Handling Application Parameters +# 应用程序参数处理 - - -Handling Application Parameters +应用程序参数处理 ------------------------------- -Almost all Flink applications, both batch and streaming, rely on external configuration parameters. -They are used to specify input and output sources (like paths or addresses), system parameters (parallelism, runtime configuration), and application specific parameters (typically used within user functions). +几乎所有的批和流的 Flink 应用程序,都依赖于外部配置参数。这些配置参数可以用于指定输入和输出源(如路径或地址)、系统参数(并行度,运行时配置)和特定的应用程序参数(通常使用在用户自定义函数)。 -Flink provides a simple utility called `ParameterTool` to provide some basic tooling for solving these problems. -Please note that you don't have to use the `ParameterTool` described here. Other frameworks such as [Commons CLI](https://commons.apache.org/proper/commons-cli/) and -[argparse4j](http://argparse4j.sourceforge.net/) also work well with Flink. +为解决以上问题,Flink 提供一个名为 `Parametertool` 的简单公共类,其中包含了一些基本的工具。请注意,这里说的 `Parametertool` 并不是必须使用的。[Commons CLI](https://commons.apache.org/proper/commons-cli/) 和 [argparse4j](http://argparse4j.sourceforge.net/) 等其他框架也可以非常好地兼容 Flink。 +### `ParameterTool` 读取配置值 -### Getting your configuration values into the `ParameterTool` +`ParameterTool` 已经定义好了一组静态方法,用于读取配置信息。该工具类内部使用了 `Map<string,string>` 类型,这样使得它可以很容易地与你的配置集成在一起。 -The `ParameterTool` provides a set of predefined static methods for reading the configuration. The tool is internally expecting a `Map<String, String>`, so it's very easy to integrate it with your own configuration style. +#### 配置值来自 `.properties` 文件 Review comment: `.properties` 文件中的配置 ########## File path: docs/content.zh/docs/dev/datastream/application_parameters.md ########## @@ -57,33 +52,33 @@ InputStream propertiesFileInputStream = new FileInputStream(file); ParameterTool parameter = ParameterTool.fromPropertiesFile(propertiesFileInputStream); ``` +#### 配置值来自命令行 -#### From the command line arguments +以下方法可以从命令行中获取参数,如 `--input hdfs:///mydata --elements 42`。 -This allows getting arguments like `--input hdfs:///mydata --elements 42` from the command line. ```java public static void main(String[] args) { ParameterTool parameter = ParameterTool.fromArgs(args); // .. regular code .. ``` -#### From system properties +#### 配置值来自系统属性 Review comment: 系统属性中的配置 ########## File path: docs/content.zh/docs/dev/datastream/application_parameters.md ########## @@ -93,29 +88,28 @@ parameter.getNumberOfParameters() // .. there are more methods available. ``` -You can use the return values of these methods directly in the `main()` method of the client submitting the application. -For example, you could set the parallelism of a operator like this: +你可以在提交应用程序时直接在客户端的 `main()` 方法中使用这些方法的返回值。例如,你可以这样设置算子的并行度: ```java ParameterTool parameters = ParameterTool.fromArgs(args); int parallelism = parameters.get("mapParallelism", 2); DataStream<Tuple2<String, Integer>> counts = text.flatMap(new Tokenizer()).setParallelism(parallelism); ``` -Since the `ParameterTool` is serializable, you can pass it to the functions itself: +由于 `ParameterTool` 是序列化的,你可以将其传递给函数本身: ```java ParameterTool parameters = ParameterTool.fromArgs(args); DataStream<Tuple2<String, Integer>> counts = text.flatMap(new Tokenizer(parameters)); ``` -and then use it inside the function for getting values from the command line. +然后在函数内使用它以获取命令行的传递的参数。 -#### Register the parameters globally +#### 全局注册参数 -Parameters registered as global job parameters in the `ExecutionConfig` can be accessed as configuration values from the JobManager web interface and in all functions defined by the user. +从 JobManager web 界面和用户定义的所有函数中可以以配置值的方式访问在 `ExecutionConfig` 中注册的全局作业参数。 -Register the parameters globally: +在全局注册参数: Review comment: 注册全局参数: ########## File path: docs/content.zh/docs/dev/datastream/application_parameters.md ########## @@ -57,33 +52,33 @@ InputStream propertiesFileInputStream = new FileInputStream(file); ParameterTool parameter = ParameterTool.fromPropertiesFile(propertiesFileInputStream); ``` +#### 配置值来自命令行 Review comment: 命令行参数中的配置 ########## File path: docs/content.zh/docs/dev/datastream/application_parameters.md ########## @@ -24,28 +24,23 @@ specific language governing permissions and limitations under the License. --> -# Handling Application Parameters +# 应用程序参数处理 - - -Handling Application Parameters +应用程序参数处理 ------------------------------- -Almost all Flink applications, both batch and streaming, rely on external configuration parameters. -They are used to specify input and output sources (like paths or addresses), system parameters (parallelism, runtime configuration), and application specific parameters (typically used within user functions). +几乎所有的批和流的 Flink 应用程序,都依赖于外部配置参数。这些配置参数可以用于指定输入和输出源(如路径或地址)、系统参数(并行度,运行时配置)和特定的应用程序参数(通常使用在用户自定义函数)。 -Flink provides a simple utility called `ParameterTool` to provide some basic tooling for solving these problems. -Please note that you don't have to use the `ParameterTool` described here. Other frameworks such as [Commons CLI](https://commons.apache.org/proper/commons-cli/) and -[argparse4j](http://argparse4j.sourceforge.net/) also work well with Flink. +为解决以上问题,Flink 提供一个名为 `Parametertool` 的简单公共类,其中包含了一些基本的工具。请注意,这里说的 `Parametertool` 并不是必须使用的。[Commons CLI](https://commons.apache.org/proper/commons-cli/) 和 [argparse4j](http://argparse4j.sourceforge.net/) 等其他框架也可以非常好地兼容 Flink。 +### `ParameterTool` 读取配置值 -### Getting your configuration values into the `ParameterTool` +`ParameterTool` 已经定义好了一组静态方法,用于读取配置信息。该工具类内部使用了 `Map<string,string>` 类型,这样使得它可以很容易地与你的配置集成在一起。 Review comment: `ParameterTool` 定义了一组静态方法用于读取配置。 -- 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]
