X-czh commented on code in PR #24230: URL: https://github.com/apache/flink/pull/24230#discussion_r1475705654
########## docs/content/docs/dev/datastream/fault-tolerance/serialization/types_serialization.md: ########## @@ -489,41 +516,39 @@ int, long, String etc. are handled by serializers we ship with Flink. For all other types, we fall back to [Kryo](https://github.com/EsotericSoftware/kryo). If Kryo is not able to handle the type, you can ask the `PojoTypeInfo` to serialize the POJO using [Avro](https://avro.apache.org). -To do so, you have to call +To do so, make sure to include the `flink-avro` module, and set: -```java -final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); -env.getConfig().enableForceAvro(); +```yaml +pipeline.force-avro: true ``` Note that Flink is automatically serializing POJOs generated by Avro with the Avro serializer. -If you want your **entire** POJO Type to be treated by the Kryo serializer, set +If you want your **entire** POJO Type to be treated by the Kryo serializer, set: -```java -final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); -env.getConfig().enableForceKryo(); +```yaml +pipeline.force-kryo: true ``` -If Kryo is not able to serialize your POJO, you can add a custom serializer to Kryo, using -```java -env.getConfig().addDefaultKryoSerializer(Class<?> type, Class<? extends Serializer<?>> serializerClass); -``` - -There are different variants of these methods available. +If Kryo is not able to serialize your POJO, you can add a custom serializer to Kryo, +using [pipeline.serialization-config]({{< ref "docs/deployment/config#pipeline-serialization-config" >}}): +```yaml +pipeline.serialization-config: + - org.example.MyCustomType: {type: kryo, kryo-type: registered, class: org.example.MyCustomSerializer} +``` ## Disabling Kryo Fallback There are cases when programs may want to explicitly avoid using Kryo as a fallback for generic types. The most common one is wanting to ensure that all types are efficiently serialized either through Flink's own serializers, -or via user-defined custom serializers. +or via user-defined custom serializers. To do that, set: -The setting below will raise an exception whenever a data type is encountered that would go through Kryo: -```java -env.getConfig().disableGenericTypes(); +```yaml +pipeline.generic-types: false ``` +An exception will be raised whenever a data type is encountered that would go through Kryo. ## Defining Type Information using a Factory Review Comment: @reswqa I've updated the doc accordingly, PTAL  -- 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]
