public abstract class KafkaTableSink extends Object implements StreamTableSink<Row>
StreamTableSink
.
The version-specific Kafka consumers need to extend this class and
override createKafkaProducer(String, Properties, SerializationSchema, KafkaPartitioner)
}.
Modifier and Type | Field and Description |
---|---|
protected String[] |
fieldNames |
protected TypeInformation[] |
fieldTypes |
protected KafkaPartitioner<Row> |
partitioner |
protected Properties |
properties |
protected SerializationSchema<Row> |
serializationSchema |
protected String |
topic |
Constructor and Description |
---|
KafkaTableSink(String topic,
Properties properties,
KafkaPartitioner<Row> partitioner)
Creates KafkaTableSink
|
Modifier and Type | Method and Description |
---|---|
KafkaTableSink |
configure(String[] fieldNames,
TypeInformation<?>[] fieldTypes)
Return a copy of this
TableSink configured with the field names and types of the
Table to emit. |
protected abstract KafkaTableSink |
createCopy()
Create a deep copy of this sink.
|
protected abstract FlinkKafkaProducerBase<Row> |
createKafkaProducer(String topic,
Properties properties,
SerializationSchema<Row> serializationSchema,
KafkaPartitioner<Row> partitioner)
Returns the version-specifid Kafka producer.
|
protected abstract SerializationSchema<Row> |
createSerializationSchema(String[] fieldNames)
Create serialization schema for converting table rows into bytes.
|
void |
emitDataStream(DataStream<Row> dataStream)
Emits the DataStream.
|
String[] |
getFieldNames()
Returns the names of the table fields.
|
TypeInformation<?>[] |
getFieldTypes()
Returns the types of the table fields.
|
TypeInformation<Row> |
getOutputType()
Return the type expected by this
TableSink . |
protected final String topic
protected final Properties properties
protected SerializationSchema<Row> serializationSchema
protected final KafkaPartitioner<Row> partitioner
protected String[] fieldNames
protected TypeInformation[] fieldTypes
public KafkaTableSink(String topic, Properties properties, KafkaPartitioner<Row> partitioner)
topic
- Kafka topic to write to.properties
- Properties for the Kafka consumer.partitioner
- Partitioner to select Kafka partition for each itemprotected abstract FlinkKafkaProducerBase<Row> createKafkaProducer(String topic, Properties properties, SerializationSchema<Row> serializationSchema, KafkaPartitioner<Row> partitioner)
topic
- Kafka topic to produce to.properties
- Properties for the Kafka producer.serializationSchema
- Serialization schema to use to create Kafka records.partitioner
- Partitioner to select Kafka partition.protected abstract SerializationSchema<Row> createSerializationSchema(String[] fieldNames)
fieldNames
- Field names in table rows.protected abstract KafkaTableSink createCopy()
public void emitDataStream(DataStream<Row> dataStream)
StreamTableSink
emitDataStream
in interface StreamTableSink<Row>
public TypeInformation<Row> getOutputType()
TableSink
TableSink
.
This type should depend on the types returned by getFieldNames
.
getOutputType
in interface TableSink<Row>
TableSink
.public String[] getFieldNames()
TableSink
getFieldNames
in interface TableSink<Row>
public TypeInformation<?>[] getFieldTypes()
TableSink
getFieldTypes
in interface TableSink<Row>
public KafkaTableSink configure(String[] fieldNames, TypeInformation<?>[] fieldTypes)
TableSink
TableSink
configured with the field names and types of the
Table
to emit.
Copyright © 2014–2017 The Apache Software Foundation. All rights reserved.