This is an automated email from the ASF dual-hosted git repository. huweihua pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/flink.git
commit c5241e502ef6228b9f4ca44372025e88adff8800 Author: wangzzu <[email protected]> AuthorDate: Wed Sep 13 19:00:14 2023 +0800 [FLINK-33061][docs] Translate failure-enricher documentation to Chinese --- .../docs/deployment/advanced/failure_enrichers.md | 50 +++++++++++----------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/docs/content.zh/docs/deployment/advanced/failure_enrichers.md b/docs/content.zh/docs/deployment/advanced/failure_enrichers.md index 0bbf45efd68..b085947ea33 100644 --- a/docs/content.zh/docs/deployment/advanced/failure_enrichers.md +++ b/docs/content.zh/docs/deployment/advanced/failure_enrichers.md @@ -1,5 +1,5 @@ --- -title: "Failure Enrichers" +title: "故障丰富器" nav-title: failure-enrichers nav-parent_id: advanced nav-pos: 3 @@ -21,34 +21,33 @@ specific language governing permissions and limitations under the License. --> -## Custom failure enrichers -Flink provides a pluggable interface for users to register their custom logic and enrich failures with extra metadata labels (string key-value pairs). -This enables users to implement their own failure enrichment plugins to categorize job failures, expose custom metrics, or make calls to external notification systems. +## 自定义故障丰富器(Failure Enricher) -FailureEnrichers are triggered every time an exception is reported at runtime by the JobManager. -Every FailureEnricher may asynchronously return labels associated with the failure that are then exposed via the JobManager's REST API (e.g., a 'type:System' label implying the failure is categorized as a system error). +Flink 提供了一个可插拔的接口,供用户注册他们自定义的逻辑,并使用额外的元数据标签(字符串类型的 key-value 对)来丰富故障(Failure)信息。 +这使得用户可以实现自定义的故障丰富器插件,对作业故障进行分类、对外暴露自定义指标,或者调用外部通知系统。 +每当 JobManager 在运行时收到异常时,都会触发 FailureEnrichers。 +每个 FailureEnricher 可以异步返回故障对应的标签(labels),这些标签可以通过 JobManager 的 REST API 来查询(例如:"type:System" 的标签意味着该故障被分类为系统错误)。 -### Implement a plugin for your custom enricher +### 实现一个自定义的故障丰富器插件 -To implement a custom FailureEnricher plugin, you need to: +要实现自定义的 FailureEnricher 插件,需要按照下面的步骤: -- Add your own FailureEnricher by implementing the {{< gh_link file="/flink-core/src/main/java/org/apache/flink/core/failure/FailureEnricher.java" name="FailureEnricher" >}} interface. +- 通过实现 FailureEnricher 接口,添加自定义的 {{< gh_link file="/flink-core/src/main/java/org/apache/flink/core/failure/FailureEnricher.java" name="FailureEnricher" >}}; -- Add your own FailureEnricherFactory by implementing the {{< gh_link file="/flink-core/src/main/java/org/apache/flink/core/failure/FailureEnricherFactory.java" name="FailureEnricherFactory" >}} interface. +- 通过实现 FailureEnricherFactory 接口,添加自定义的 {{< gh_link file="/flink-core/src/main/java/org/apache/flink/core/failure/FailureEnricherFactory.java" name="FailureEnricherFactory" >}}; -- Add a service entry. Create a file `META-INF/services/org.apache.flink.core.failure.FailureEnricherFactory` which contains the class name of your failure enricher factory class (see [Java Service Loader](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/ServiceLoader.html) docs for more details). +- 添加一个 Service 入口,创建一个文件 `META-INF/services/org.apache.flink.core.failure.FailureEnricherFactory`,文件中包含自定义 FailureEnricherFactory 的类名(有关详细信息,请参阅 [Java Service Loader](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/ServiceLoader.html) 文档)。 - -Then, create a jar which includes your `FailureEnricher`, `FailureEnricherFactory`, `META-INF/services/` and all external dependencies. -Make a directory in `plugins/` of your Flink distribution with an arbitrary name, e.g. "failure-enrichment", and put the jar into this directory. -See [Flink Plugin]({% link deployment/filesystems/plugins.md %}) for more details. +然后,创建一个包含 `FailureEnricher`,`FailureEnricherFactory`,`META-INF/services/` 和所有外部依赖项的 jar 文件。 +在 Flink Deploy 目录中的 `plugins/` 目录中创建一个任意名称的目录,例如 "failure-enrichment",并将 jar 文件放入此目录中。 +使用方式与其它 Plugin 是类似的,有关的详细信息,请参考 [Flink Plugins]({{< ref "docs/deployment/filesystems/plugins" >}})。 {{< hint warning >}} -Note that every FailureEnricher should have defined a set of {{< gh_link file="/flink-core/src/main/java/org/apache/flink/core/failure/FailureEnricher.java" name="output keys" >}} that may be associated with values. This set of keys has to be unique otherwise all enrichers with overlapping keys will be ignored. +请注意,每个 FailureEnricher 都应该定义一组与对应 values 关联的 {{< gh_link file="/flink-core/src/main/java/org/apache/flink/core/failure/FailureEnricher.java" name="output keys" >}}。这组 keys 必须是唯一的,否则将忽略具有重复 key 的所有丰富器(enrichers)。 {{< /hint >}} -FailureEnricherFactory example: +FailureEnricherFactory 示例: ``` java package org.apache.flink.test.plugin.jar.failure; @@ -62,7 +61,7 @@ public class TestFailureEnricherFactory implements FailureEnricherFactory { } ``` -FailureEnricher example: +FailureEnricher 示例: ``` java package org.apache.flink.test.plugin.jar.failure; @@ -87,22 +86,25 @@ public class CustomEnricher implements FailureEnricher { } ``` -### Configuration +### 配置 + +JobManager 在启动时加载 FailureEnricher 插件。 为了确保您的 FailureEnrichers 已加载,所有类名都应该定义在 [jobmanager.failure-enrichers 配置]({{< ref "docs/deployment/config#jobmanager-failure-enrichers" >}}) 中。 +如果此配置为空,则不会启动任何 Enricher。 示例: -The JobManager loads FailureEnricher plugins at startup. To make sure your FailureEnrichers are loaded all class names should be defined as part of [jobmanager.failure-enrichers configuration]({{< ref "docs/deployment/config#jobmanager-failure-enrichers" >}}). -If this configuration is empty, NO enrichers will be started. Example: ``` jobmanager.failure-enrichers = org.apache.flink.test.plugin.jar.failure.CustomEnricher ``` -### Validation +### 验证 + +要验证 FailureEnricher 是否已加载,您可以检查 JobManager 日志中是否有下面的内容: -To validate that your FailureEnricher is loaded, you can check the JobManager logs for the following line: ``` Found failure enricher org.apache.flink.test.plugin.jar.failure.CustomEnricher at jar:file:/path/to/flink/plugins/failure-enrichment/flink-test-plugin.jar!/org/apache/flink/test/plugin/jar/failure/CustomEnricher.class ``` -Moreover, you can query the JobManager's [REST API]({{< ref "docs/ops/rest_api" >}}#jobs-jobid-exceptions) looking for the failureLabels field: +此外,还可以查询 JobManager 的 [REST API]({{< ref "docs/ops/rest_api" >}}#jobs-jobid-exceptions) 来查找 failureLabels 字段: + ``` "failureLabels": { "labelKey": "labelValue"
