未验证 提交 67ddf084 编写于 作者: 片刻小哥哥's avatar 片刻小哥哥 提交者: GitHub

Merge pull request #60 from apachecn/feature/flink_1.7_doc_zh_25

25 完成
# State Schema Evolution
# State Schema Evolution 状态架构演进
Apache Flink streaming applications are typically designed to run indefinitely or for long periods of time. As with all long-running services, the applications need to be updated to adapt to changing requirements. This goes the same for data schemas that the applications work against; they evolve along with the application.
Apache Flink流应用程序通常设计为无限期运行或长时间运行。与所有长期运行的服务一样,需要更新应用程序以适应不断变化的需求。对于应用程序所针对的数据模式,也是如此;它们随着应用程序的发展而发展。
This page provides an overview of how you can evolve your state type’s data schema. The current restrictions varies across different types and state structures (`ValueState`, `ListState`, etc.).
本页概述了如何发展状态类型的数据架构。当前的限制因不同类型和状态结构(`ValueState`, `ListState`,等)而异。
Note that the information on this page is relevant only if you are using state serializers that are generated by Flink’s own [type serialization framework](//ci.apache.org/projects/flink/flink-docs-release-1.7/dev/types_serialization.html). That is, when declaring your state, the provided state descriptor is not configured to use a specific `TypeSerializer` or `TypeInformation`, in which case Flink infers information about the state type:
请注意,只有在使用由flink的[类型序列化框架](//ci.apache.org/projects/flink/flink-docs-release-1.7/dev/types_serialization.html)生成的状态序列化程序时,此页上的信息才是相关的。也就是说,当声明您的状态时,所提供的状态描述符未配置为使用特定的 `TypeSerializer``TypeInformation`,在此情况下,flink推断有关该状态类型的信息:
......@@ -21,31 +21,31 @@ checkpointedState = getRuntimeContext().getListState(descriptor);
Under the hood, whether or not the schema of state can be evolved depends on the serializer used to read / write persisted state bytes. Simply put, a registered state’s schema can only be evolved if its serializer properly supports it. This is handled transparently by serializers generated by Flink’s type serialization framework (current scope of support is listed [below](//ci.apache.org/projects/flink/flink-docs-release-1.7/dev/stream/state/schema_evolution.html#supported-data-types-for-schema-evolution)).
在引擎罩下,是否可以演变状态模式取决于用于读/写持久状态字节的串行器。简单地说,只有在序列化程序正确支持它的情况下才能演变注册状态“S”模式。这是由flink的类型序列化框架(当前支持范围[下面](//ci.apache.org/projects/flink/flink-docs-release-1.7/dev/stream/state/schema_evolution.html#supported-data-types-for-schema-evolution))生成的序列化程序透明处理的。
If you intend to implement a custom `TypeSerializer` for your state type and would like to learn how to implement the serializer to support state schema evolution, please refer to [Custom State Serialization](//ci.apache.org/projects/flink/flink-docs-release-1.7/dev/stream/state/custom_serialization.html). The documentation there also covers necessary internal details about the interplay between state serializers and Flink’s state backends to support state schema evolution.
如果您打算为您的状态类型实现自定义的`TypeSerializer`,并且希望了解如何实现序列化程序以支持状态模式演化,请参阅[自定义状态Serialization](//ci.apache.org/projects/flink/flink-docs-release-1.7/dev/stream/state/custom_serialization.html).那里的文档还涵盖了关于状态序列化器和Flink的状态后端之间的相互作用的必要的内部细节,以支持状态模式的演化。
## Evolving state schema
## Evolving state schema 演化状态模式
To evolve the schema of a given state type, you would take the following steps:
要发展给定状态类型的架构,您需要执行以下步骤:
1. Take a savepoint of your Flink streaming job.
2. Update state types in your application (e.g., modifying your Avro type schema).
3. Restore the job from the savepoint. When accessing state for the first time, Flink will assess whether or not the schema had been changed for the state, and migrate state schema if necessary.
1. 获取FLink流作业的保存点。
2. 更新应用程序中的状态类型(例如,修改Avro类型模式)。
3. 从保存点恢复作业。首次访问状态时,flink将评估该模式是否已针对该状态进行了更改,并在必要时迁移状态模式。
The process of migrating state to adapt to changed schemas happens automatically, and independently for each state. This process is performed internally by Flink by first checking if the new serializer for the state has different serialization schema than the previous serializer; if so, the previous serializer is used to read the state to objects, and written back to bytes again with the new serializer.
迁移状态以适应改变的模式的过程自动发生,并且对于每个状态是独立的。通过首先检查该状态的新串行化器是否具有不同于先前串行器的串行化模式来在内部执行该过程;如果是,则使用先前的串行器将该状态读取到对象,并再次用新的串行器将其写回字节。
Further details about the migration process is out of the scope of this documentation; please refer to [here](//ci.apache.org/projects/flink/flink-docs-release-1.7/dev/stream/state/custom_serialization.html).
有关迁移过程的更多详细信息超出了本文档的范围;请参阅[here](//ci.apache.org/projects/flink/flink-docs-release-1.7/dev/stream/state/custom_serialization.html).。
## Supported data types for schema evolution
## Supported data types for schema evolution 支持模式演化的数据类型
Currently, schema evolution is supported only for Avro. Therefore, if you care about schema evolution for state, it is currently recommended to always use Avro for state data types.
目前,架构演进仅支持AVRO。因此,如果您关注状态的架构演进,当前建议始终使用AVRO来进行状态数据类型。
There are plans to extend the support for more composite types, such as POJOs; for more details, please refer to [FLINK-10897](https://issues.apache.org/jira/browse/FLINK-10897).
有计划将支持扩展到更多的复合类型,例如POJO;有关详细信息,请参阅[FLINK-10897](https://issues.apache.org/jira/browse/FLINK-10897)。
### Avro types
### Avro types Avro类型
Flink fully supports evolving schema of Avro type state, as long as the schema change is considered compatible by [Avro’s rules for schema resolution](http://avro.apache.org/docs/current/spec.html#Schema+Resolution).
Flink完全支持不断发展的Avro类型状态模式,只要模式更改被[Avro的模式resolution](http://avro.apache.org/docs/current/spec.html#Schema解析规则]认为是兼容的。
One limitation is that Avro generated classes used as the state type cannot be relocated or have different namespaces when the job is restored.
一个限制是,在还原作业时,Avro生成的类作为状态类型不能重新定位或具有不同的命名空间。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册