|
18 | 18 |
|
19 | 19 | package com.dtstack.flink.sql.sink.kafka;
|
20 | 20 |
|
21 |
| -import com.dtstack.flink.sql.sink.IStreamSinkGener; |
22 | 21 | import com.dtstack.flink.sql.sink.kafka.table.KafkaSinkTableInfo;
|
23 | 22 | import com.dtstack.flink.sql.table.AbstractTargetTableInfo;
|
24 |
| -import org.apache.commons.lang3.StringUtils; |
25 |
| -import org.apache.flink.api.common.typeinfo.TypeInformation; |
26 |
| -import org.apache.flink.api.java.tuple.Tuple2; |
27 |
| -import org.apache.flink.api.java.typeutils.RowTypeInfo; |
28 |
| -import org.apache.flink.api.java.typeutils.TupleTypeInfo; |
29 |
| -import org.apache.flink.streaming.api.datastream.DataStream; |
30 |
| -import org.apache.flink.streaming.api.datastream.DataStreamSink; |
31 |
| -import org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer; |
32 |
| -import org.apache.flink.streaming.connectors.kafka.partitioner.FlinkKafkaPartitioner; |
33 |
| -import org.apache.flink.table.api.TableSchema; |
34 |
| -import org.apache.flink.table.sinks.RetractStreamTableSink; |
35 |
| -import org.apache.flink.table.sinks.TableSink; |
36 |
| -import org.apache.flink.types.Row; |
37 | 23 |
|
38 | 24 | import java.util.Optional;
|
39 | 25 | import java.util.Properties;
|
|
46 | 32 | public class KafkaSink extends AbstractKafkaSink {
|
47 | 33 | @Override
|
48 | 34 | public KafkaSink genStreamSink(AbstractTargetTableInfo targetTableInfo) {
|
49 |
| - KafkaSinkTableInfo kafka11SinkTableInfo = (KafkaSinkTableInfo) targetTableInfo; |
| 35 | + KafkaSinkTableInfo kafkaSinkTableInfo = (KafkaSinkTableInfo) targetTableInfo; |
50 | 36 |
|
51 |
| - Properties kafkaProperties = getKafkaProperties(kafka11SinkTableInfo); |
52 |
| - this.tableName = kafka11SinkTableInfo.getName(); |
53 |
| - this.topic = kafka11SinkTableInfo.getTopic(); |
| 37 | + Properties kafkaProperties = getKafkaProperties(kafkaSinkTableInfo); |
| 38 | + this.tableName = kafkaSinkTableInfo.getName(); |
| 39 | + this.topic = kafkaSinkTableInfo.getTopic(); |
54 | 40 | this.partitioner = Optional.of(new CustomerFlinkPartition<>());
|
55 |
| - this.partitionKeys = getPartitionKeys(kafka11SinkTableInfo); |
56 |
| - this.fieldNames = kafka11SinkTableInfo.getFields(); |
57 |
| - this.fieldTypes = getTypeInformations(kafka11SinkTableInfo); |
| 41 | + this.partitionKeys = getPartitionKeys(kafkaSinkTableInfo); |
| 42 | + this.fieldNames = kafkaSinkTableInfo.getFields(); |
| 43 | + this.fieldTypes = getTypeInformations(kafkaSinkTableInfo); |
58 | 44 | this.schema = buildTableSchema(fieldNames, fieldTypes);
|
59 |
| - this.parallelism = kafka11SinkTableInfo.getParallelism(); |
| 45 | + this.parallelism = kafkaSinkTableInfo.getParallelism(); |
60 | 46 | this.sinkOperatorName = SINK_OPERATOR_NAME_TPL.replace("${topic}", topic).replace("${table}", tableName);
|
61 |
| - this.kafkaProducer011 = new KafkaProducerFactory() |
62 |
| - .createKafkaProducer(kafka11SinkTableInfo, getOutputType().getTypeAt(1), kafkaProperties, partitioner, partitionKeys); |
| 47 | + this.kafkaProducer011 = new KafkaProducerFactory().createKafkaProducer(kafkaSinkTableInfo, getOutputType(), kafkaProperties, partitioner, partitionKeys); |
63 | 48 | return this;
|
64 | 49 | }
|
65 | 50 | }
|
0 commit comments