Class KafkaDynamicSink
- java.lang.Object
-
- org.apache.flink.streaming.connectors.kafka.table.KafkaDynamicSink
-
- All Implemented Interfaces:
org.apache.flink.table.connector.sink.abilities.SupportsWritingMetadata,org.apache.flink.table.connector.sink.DynamicTableSink
@Internal public class KafkaDynamicSink extends Object implements org.apache.flink.table.connector.sink.DynamicTableSink, org.apache.flink.table.connector.sink.abilities.SupportsWritingMetadata
A version-agnostic KafkaDynamicTableSink.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.flink.table.connector.sink.DynamicTableSink
org.apache.flink.table.connector.sink.DynamicTableSink.Context, org.apache.flink.table.connector.sink.DynamicTableSink.DataStructureConverter, org.apache.flink.table.connector.sink.DynamicTableSink.SinkRuntimeProvider
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.flink.table.types.DataTypeconsumedDataTypeData type of consumed data type.protected SinkBufferFlushModeflushModeSink buffer flush config which only supported in upsert mode now.protected org.apache.flink.table.connector.format.EncodingFormat<org.apache.flink.api.common.serialization.SerializationSchema<org.apache.flink.table.data.RowData>>keyEncodingFormatOptional format for encoding keys to Kafka.protected StringkeyPrefixPrefix that needs to be removed from fields when constructing the physical data type.protected int[]keyProjectionIndices that determine the key fields and the source position in the consumed row.protected List<String>metadataKeysMetadata that is appended at the end of a physical sink row.protected IntegerparallelismParallelism of the physical Kafka producer.protected FlinkKafkaPartitioner<org.apache.flink.table.data.RowData>partitionerPartitioner to select Kafka partition for each item.protected org.apache.flink.table.types.DataTypephysicalDataTypeData type to configure the formats.protected PropertiespropertiesProperties for the Kafka producer.protected StringtopicThe Kafka topic to write to.protected booleanupsertModeFlag to determine sink mode.protected org.apache.flink.table.connector.format.EncodingFormat<org.apache.flink.api.common.serialization.SerializationSchema<org.apache.flink.table.data.RowData>>valueEncodingFormatFormat for encoding values to Kafka.protected int[]valueProjectionIndices that determine the value fields and the source position in the consumed row.
-
Constructor Summary
Constructors Constructor Description KafkaDynamicSink(org.apache.flink.table.types.DataType consumedDataType, org.apache.flink.table.types.DataType physicalDataType, org.apache.flink.table.connector.format.EncodingFormat<org.apache.flink.api.common.serialization.SerializationSchema<org.apache.flink.table.data.RowData>> keyEncodingFormat, org.apache.flink.table.connector.format.EncodingFormat<org.apache.flink.api.common.serialization.SerializationSchema<org.apache.flink.table.data.RowData>> valueEncodingFormat, int[] keyProjection, int[] valueProjection, String keyPrefix, String topic, Properties properties, FlinkKafkaPartitioner<org.apache.flink.table.data.RowData> partitioner, org.apache.flink.connector.base.DeliveryGuarantee deliveryGuarantee, boolean upsertMode, SinkBufferFlushMode flushMode, Integer parallelism, String transactionalIdPrefix)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidapplyWritableMetadata(List<String> metadataKeys, org.apache.flink.table.types.DataType consumedDataType)StringasSummaryString()org.apache.flink.table.connector.sink.DynamicTableSinkcopy()booleanequals(Object o)org.apache.flink.table.connector.ChangelogModegetChangelogMode(org.apache.flink.table.connector.ChangelogMode requestedMode)org.apache.flink.table.connector.sink.DynamicTableSink.SinkRuntimeProvidergetSinkRuntimeProvider(org.apache.flink.table.connector.sink.DynamicTableSink.Context context)inthashCode()Map<String,org.apache.flink.table.types.DataType>listWritableMetadata()
-
-
-
Field Detail
-
metadataKeys
protected List<String> metadataKeys
Metadata that is appended at the end of a physical sink row.
-
consumedDataType
protected org.apache.flink.table.types.DataType consumedDataType
Data type of consumed data type.
-
physicalDataType
protected final org.apache.flink.table.types.DataType physicalDataType
Data type to configure the formats.
-
keyEncodingFormat
@Nullable protected final org.apache.flink.table.connector.format.EncodingFormat<org.apache.flink.api.common.serialization.SerializationSchema<org.apache.flink.table.data.RowData>> keyEncodingFormat
Optional format for encoding keys to Kafka.
-
valueEncodingFormat
protected final org.apache.flink.table.connector.format.EncodingFormat<org.apache.flink.api.common.serialization.SerializationSchema<org.apache.flink.table.data.RowData>> valueEncodingFormat
Format for encoding values to Kafka.
-
keyProjection
protected final int[] keyProjection
Indices that determine the key fields and the source position in the consumed row.
-
valueProjection
protected final int[] valueProjection
Indices that determine the value fields and the source position in the consumed row.
-
keyPrefix
@Nullable protected final String keyPrefix
Prefix that needs to be removed from fields when constructing the physical data type.
-
topic
protected final String topic
The Kafka topic to write to.
-
properties
protected final Properties properties
Properties for the Kafka producer.
-
partitioner
@Nullable protected final FlinkKafkaPartitioner<org.apache.flink.table.data.RowData> partitioner
Partitioner to select Kafka partition for each item.
-
upsertMode
protected final boolean upsertMode
Flag to determine sink mode. In upsert mode sink transforms the delete/update-before message to tombstone message.
-
flushMode
protected final SinkBufferFlushMode flushMode
Sink buffer flush config which only supported in upsert mode now.
-
-
Constructor Detail
-
KafkaDynamicSink
public KafkaDynamicSink(org.apache.flink.table.types.DataType consumedDataType, org.apache.flink.table.types.DataType physicalDataType, @Nullable org.apache.flink.table.connector.format.EncodingFormat<org.apache.flink.api.common.serialization.SerializationSchema<org.apache.flink.table.data.RowData>> keyEncodingFormat, org.apache.flink.table.connector.format.EncodingFormat<org.apache.flink.api.common.serialization.SerializationSchema<org.apache.flink.table.data.RowData>> valueEncodingFormat, int[] keyProjection, int[] valueProjection, @Nullable String keyPrefix, String topic, Properties properties, @Nullable FlinkKafkaPartitioner<org.apache.flink.table.data.RowData> partitioner, org.apache.flink.connector.base.DeliveryGuarantee deliveryGuarantee, boolean upsertMode, SinkBufferFlushMode flushMode, @Nullable Integer parallelism, @Nullable String transactionalIdPrefix)
-
-
Method Detail
-
getChangelogMode
public org.apache.flink.table.connector.ChangelogMode getChangelogMode(org.apache.flink.table.connector.ChangelogMode requestedMode)
- Specified by:
getChangelogModein interfaceorg.apache.flink.table.connector.sink.DynamicTableSink
-
getSinkRuntimeProvider
public org.apache.flink.table.connector.sink.DynamicTableSink.SinkRuntimeProvider getSinkRuntimeProvider(org.apache.flink.table.connector.sink.DynamicTableSink.Context context)
- Specified by:
getSinkRuntimeProviderin interfaceorg.apache.flink.table.connector.sink.DynamicTableSink
-
listWritableMetadata
public Map<String,org.apache.flink.table.types.DataType> listWritableMetadata()
- Specified by:
listWritableMetadatain interfaceorg.apache.flink.table.connector.sink.abilities.SupportsWritingMetadata
-
applyWritableMetadata
public void applyWritableMetadata(List<String> metadataKeys, org.apache.flink.table.types.DataType consumedDataType)
- Specified by:
applyWritableMetadatain interfaceorg.apache.flink.table.connector.sink.abilities.SupportsWritingMetadata
-
copy
public org.apache.flink.table.connector.sink.DynamicTableSink copy()
- Specified by:
copyin interfaceorg.apache.flink.table.connector.sink.DynamicTableSink
-
asSummaryString
public String asSummaryString()
- Specified by:
asSummaryStringin interfaceorg.apache.flink.table.connector.sink.DynamicTableSink
-
-