@Internal public class KafkaSerializationSchemaWrapper<T> extends Object implements KafkaSerializationSchema<T>, KafkaContextAware<T>
SerializationSchema, FlinkKafkaPartitioner to the KafkaSerializationSchema.| 构造器和说明 |
|---|
KafkaSerializationSchemaWrapper(String topic,
FlinkKafkaPartitioner<T> partitioner,
boolean writeTimestamp,
org.apache.flink.api.common.serialization.SerializationSchema<T> serializationSchema) |
| 限定符和类型 | 方法和说明 |
|---|---|
String |
getTargetTopic(T element)
Returns the topic that the presented element should be sent to.
|
void |
open(org.apache.flink.api.common.serialization.SerializationSchema.InitializationContext context)
Initialization method for the schema.
|
org.apache.kafka.clients.producer.ProducerRecord<byte[],byte[]> |
serialize(T element,
Long timestamp)
Serializes given element and returns it as a
ProducerRecord. |
void |
setNumParallelInstances(int numParallelInstances)
Sets the parallelism with which the parallel task of the Kafka Producer runs.
|
void |
setParallelInstanceId(int parallelInstanceId)
Sets the number of the parallel subtask that the Kafka Producer is running on.
|
void |
setPartitions(int[] partitions)
Sets the available partitions for the topic returned from
KafkaContextAware.getTargetTopic(Object). |
void |
setWriteTimestamp(boolean writeTimestamp) |
public KafkaSerializationSchemaWrapper(String topic, FlinkKafkaPartitioner<T> partitioner, boolean writeTimestamp, org.apache.flink.api.common.serialization.SerializationSchema<T> serializationSchema)
public void open(org.apache.flink.api.common.serialization.SerializationSchema.InitializationContext context)
throws Exception
KafkaSerializationSchemaKafkaSerializationSchema.serialize(Object, Long) and thus suitable for one time setup work.
The provided SerializationSchema.InitializationContext can be used to access
additional features such as e.g. registering user metrics.
open 在接口中 KafkaSerializationSchema<T>context - Contextual information that can be used during initialization.Exceptionpublic org.apache.kafka.clients.producer.ProducerRecord<byte[],byte[]> serialize(T element, @Nullable Long timestamp)
KafkaSerializationSchemaProducerRecord.serialize 在接口中 KafkaSerializationSchema<T>element - element to be serializedtimestamp - timestamp (can be null)ProducerRecordpublic String getTargetTopic(T element)
KafkaContextAwareProducerRecord that
is returned from KafkaSerializationSchema.serialize(Object, Long), it is only used
for getting the available partitions that are presented to KafkaContextAware.setPartitions(int[]).getTargetTopic 在接口中 KafkaContextAware<T>public void setPartitions(int[] partitions)
KafkaContextAwareKafkaContextAware.getTargetTopic(Object).setPartitions 在接口中 KafkaContextAware<T>public void setParallelInstanceId(int parallelInstanceId)
KafkaContextAwareKafkaContextAware.setNumParallelInstances(int)).setParallelInstanceId 在接口中 KafkaContextAware<T>public void setNumParallelInstances(int numParallelInstances)
KafkaContextAwaresetNumParallelInstances 在接口中 KafkaContextAware<T>public void setWriteTimestamp(boolean writeTimestamp)
Copyright © 2014–2023 The Apache Software Foundation. All rights reserved.